http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_gatt_disc_c_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gatt_disc_c_test.c b/net/nimble/host/test/src/ble_gatt_disc_c_test.c index 6c384cd..7ecb48e 100644 --- a/net/nimble/host/test/src/ble_gatt_disc_c_test.c +++ b/net/nimble/host/test/src/ble_gatt_disc_c_test.c @@ -30,9 +30,8 @@ struct ble_gatt_disc_c_test_char { uint16_t def_handle; uint16_t val_handle; - uint16_t uuid16; /* 0 if not present. */ uint8_t properties; - uint8_t uuid128[16]; + const ble_uuid_t *uuid; }; #define BLE_GATT_DISC_C_TEST_MAX_CHARS 256 @@ -63,7 +62,7 @@ ble_gatt_disc_c_test_misc_rx_rsp_once( /* Send the pending ATT Read By Type Request. */ ble_hs_test_util_tx_all(); - if (chars[0].uuid16 != 0) { + if (chars[0].uuid->type == BLE_UUID_TYPE_16) { rsp.batp_length = BLE_ATT_READ_TYPE_ADATA_BASE_SZ + BLE_GATT_CHR_DECL_SZ_16; } else { @@ -81,11 +80,12 @@ ble_gatt_disc_c_test_misc_rx_rsp_once( } /* If the value length is changing, we need a separate response. */ - if (((chars[i].uuid16 == 0) ^ (chars[0].uuid16 == 0)) != 0) { + if (((chars[i].uuid->type == BLE_UUID_TYPE_16) ^ + (chars[0].uuid->type == BLE_UUID_TYPE_16)) != 0) { break; } - if (chars[i].uuid16 != 0) { + if (chars[i].uuid->type == BLE_UUID_TYPE_16) { if (off + BLE_ATT_READ_TYPE_ADATA_SZ_16 > ble_att_mtu(conn_handle)) { @@ -110,13 +110,8 @@ ble_gatt_disc_c_test_misc_rx_rsp_once( htole16(buf + off, chars[i].val_handle); off += 2; - if (chars[i].uuid16 != 0) { - htole16(buf + off, chars[i].uuid16); - off += 2; - } else { - memcpy(buf + off, chars[i].uuid128, 16); - off += 16; - } + ble_uuid_flat(chars[i].uuid, buf + off); + off += ble_uuid_length(chars[i].uuid); } rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, @@ -157,7 +152,6 @@ static void ble_gatt_disc_c_test_misc_verify_chars(struct ble_gatt_disc_c_test_char *chars, int stop_after) { - uint16_t uuid16; int i; if (stop_after == 0) { @@ -169,14 +163,8 @@ ble_gatt_disc_c_test_misc_verify_chars(struct ble_gatt_disc_c_test_char *chars, ble_gatt_disc_c_test_chars[i].def_handle); TEST_ASSERT(chars[i].val_handle == ble_gatt_disc_c_test_chars[i].val_handle); - if (chars[i].uuid16 != 0) { - uuid16 = ble_uuid_128_to_16(ble_gatt_disc_c_test_chars[i].uuid128); - TEST_ASSERT(chars[i].uuid16 == uuid16); - } else { - TEST_ASSERT(memcmp(chars[i].uuid128, - ble_gatt_disc_c_test_chars[i].uuid128, - 16) == 0); - } + TEST_ASSERT(ble_uuid_cmp(chars[i].uuid, + &ble_gatt_disc_c_test_chars[i].uuid.u) == 0); } TEST_ASSERT(i == ble_gatt_disc_c_test_num_chars); @@ -249,7 +237,7 @@ ble_gatt_disc_c_test_misc_all(uint16_t start_handle, uint16_t end_handle, static void ble_gatt_disc_c_test_misc_uuid(uint16_t start_handle, uint16_t end_handle, - int stop_after, uint8_t *uuid128, + int stop_after, const ble_uuid_t *uuid, struct ble_gatt_disc_c_test_char *rsp_chars, struct ble_gatt_disc_c_test_char *ret_chars) { @@ -261,7 +249,7 @@ ble_gatt_disc_c_test_misc_uuid(uint16_t start_handle, uint16_t end_handle, NULL, NULL); rc = ble_gattc_disc_chrs_by_uuid(2, start_handle, end_handle, - uuid128, + uuid, ble_gatt_disc_c_test_misc_cb, &stop_after); TEST_ASSERT(rc == 0); @@ -278,7 +266,7 @@ TEST_CASE(ble_gatt_disc_c_test_disc_all) { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { 0 } }); @@ -288,11 +276,11 @@ TEST_CASE(ble_gatt_disc_c_test_disc_all) { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 57, .val_handle = 58, - .uuid16 = 0x64ba, + .uuid = BLE_UUID16_DECLARE(0x64ba), }, { 0 } }); @@ -302,23 +290,23 @@ TEST_CASE(ble_gatt_disc_c_test_disc_all) { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 57, .val_handle = 58, - .uuid16 = 0x64ba, + .uuid = BLE_UUID16_DECLARE(0x64ba), }, { .def_handle = 59, .val_handle = 60, - .uuid16 = 0x5372, + .uuid = BLE_UUID16_DECLARE(0x5372), }, { .def_handle = 61, .val_handle = 62, - .uuid16 = 0xab93, + .uuid = BLE_UUID16_DECLARE(0xab93), }, { .def_handle = 63, .val_handle = 64, - .uuid16 = 0x0023, + .uuid = BLE_UUID16_DECLARE(0x0023), }, { 0 } }); @@ -328,23 +316,25 @@ TEST_CASE(ble_gatt_disc_c_test_disc_all) { .def_handle = 83, .val_handle = 84, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 87, .val_handle = 88, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15), }, { .def_handle = 91, .val_handle = 92, - .uuid16 = 0x0003, + .uuid = BLE_UUID16_DECLARE(0x0003), }, { .def_handle = 93, .val_handle = 94, - .uuid128 = { 1,0,4,0,6,9,17,7,8,43,7,4,12,43,19,35 }, + .uuid = BLE_UUID128_DECLARE(1, 0, 4, 0, 6, 9, 17, 7, + 8, 43, 7, 4, 12, 43, 19, 35), }, { .def_handle = 98, .val_handle = 99, - .uuid16 = 0xabfa, + .uuid = BLE_UUID16_DECLARE(0xabfa), }, { 0 } }); @@ -354,11 +344,11 @@ TEST_CASE(ble_gatt_disc_c_test_disc_all) { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 99, .val_handle = 100, - .uuid16 = 0x64ba, + .uuid = BLE_UUID16_DECLARE(0x64ba), }, { 0 } }); @@ -368,23 +358,23 @@ TEST_CASE(ble_gatt_disc_c_test_disc_all) { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 57, .val_handle = 58, - .uuid16 = 0x64ba, + .uuid = BLE_UUID16_DECLARE(0x64ba), }, { .def_handle = 59, .val_handle = 60, - .uuid16 = 0x5372, + .uuid = BLE_UUID16_DECLARE(0x5372), }, { .def_handle = 61, .val_handle = 62, - .uuid16 = 0xab93, + .uuid = BLE_UUID16_DECLARE(0xab93), }, { .def_handle = 63, .val_handle = 64, - .uuid16 = 0x0023, + .uuid = BLE_UUID16_DECLARE(0x0023), }, { 0 } }); } @@ -392,156 +382,156 @@ TEST_CASE(ble_gatt_disc_c_test_disc_all) TEST_CASE(ble_gatt_disc_c_test_disc_uuid) { /*** One 16-bit characteristic. */ - ble_gatt_disc_c_test_misc_uuid(50, 100, 0, BLE_UUID16(0x2010), + ble_gatt_disc_c_test_misc_uuid(50, 100, 0, BLE_UUID16_DECLARE(0x2010), (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { 0 } }, (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { 0 } } ); /*** No matching characteristics. */ - ble_gatt_disc_c_test_misc_uuid(50, 100, 0, BLE_UUID16(0x2010), + ble_gatt_disc_c_test_misc_uuid(50, 100, 0, BLE_UUID16_DECLARE(0x2010), (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x1234, + .uuid = BLE_UUID16_DECLARE(0x1234), }, { 0 } }, (struct ble_gatt_disc_c_test_char[]) { { 0 } } ); /*** 2/5 16-bit characteristics. */ - ble_gatt_disc_c_test_misc_uuid(50, 100, 0, BLE_UUID16(0x2010), + ble_gatt_disc_c_test_misc_uuid(50, 100, 0, BLE_UUID16_DECLARE(0x2010), (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 57, .val_handle = 58, - .uuid16 = 0x64ba, + .uuid = BLE_UUID16_DECLARE(0x64ba), }, { .def_handle = 59, .val_handle = 60, - .uuid16 = 0x5372, + .uuid = BLE_UUID16_DECLARE(0x5372), }, { .def_handle = 61, .val_handle = 62, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 63, .val_handle = 64, - .uuid16 = 0x0023, + .uuid = BLE_UUID16_DECLARE(0x0023), }, { 0 } }, (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 61, .val_handle = 62, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { 0 } } ); /*** Interleaved 16-bit and 128-bit characteristics. */ ble_gatt_disc_c_test_misc_uuid( 50, 100, 0, - ((uint8_t[]){ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }), + BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 83, .val_handle = 84, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 87, .val_handle = 88, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { .def_handle = 91, .val_handle = 92, - .uuid16 = 0x0003, + .uuid = BLE_UUID16_DECLARE(0x0003), }, { .def_handle = 93, .val_handle = 94, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { .def_handle = 98, .val_handle = 99, - .uuid16 = 0xabfa, + .uuid = BLE_UUID16_DECLARE(0xabfa), }, { 0 } }, (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 87, .val_handle = 88, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { .def_handle = 93, .val_handle = 94, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { 0 } } ); /*** Ends with final handle ID. */ - ble_gatt_disc_c_test_misc_uuid(50, 100, 0, BLE_UUID16(0x64ba), + ble_gatt_disc_c_test_misc_uuid(50, 100, 0, BLE_UUID16_DECLARE(0x64ba), (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 99, .val_handle = 100, - .uuid16 = 0x64ba, + .uuid = BLE_UUID16_DECLARE(0x64ba), }, { 0 } }, (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 99, .val_handle = 100, - .uuid16 = 0x64ba, + .uuid = BLE_UUID16_DECLARE(0x64ba), }, { 0 } } ); /*** Stop after first characteristic. */ - ble_gatt_disc_c_test_misc_uuid(50, 100, 1, BLE_UUID16(0x2010), + ble_gatt_disc_c_test_misc_uuid(50, 100, 1, BLE_UUID16_DECLARE(0x2010), (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 57, .val_handle = 58, - .uuid16 = 0x64ba, + .uuid = BLE_UUID16_DECLARE(0x64ba), }, { .def_handle = 59, .val_handle = 60, - .uuid16 = 0x5372, + .uuid = BLE_UUID16_DECLARE(0x5372), }, { .def_handle = 61, .val_handle = 62, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { .def_handle = 63, .val_handle = 64, - .uuid16 = 0x0023, + .uuid = BLE_UUID16_DECLARE(0x0023), }, { 0 } }, (struct ble_gatt_disc_c_test_char[]) { { .def_handle = 55, .val_handle = 56, - .uuid16 = 0x2010, + .uuid = BLE_UUID16_DECLARE(0x2010), }, { 0 } } ); } @@ -553,12 +543,12 @@ TEST_CASE(ble_gatt_disc_c_test_oom_all) { .def_handle = 93, .val_handle = 94, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { .def_handle = 95, .val_handle = 96, - .uuid128 = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }, + .uuid = BLE_UUID128_DECLARE(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), }, { 0 } }; @@ -641,12 +631,12 @@ TEST_CASE(ble_gatt_disc_c_test_oom_uuid) { .def_handle = 93, .val_handle = 94, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { .def_handle = 95, .val_handle = 96, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { 0 } }; @@ -664,7 +654,7 @@ TEST_CASE(ble_gatt_disc_c_test_oom_uuid) /* Initiate a discover characteristics by UUID procedure. */ stop_after = 0; - rc = ble_gattc_disc_chrs_by_uuid(1, 1, 0xffff, chrs[0].uuid128, + rc = ble_gattc_disc_chrs_by_uuid(1, 1, 0xffff, chrs[0].uuid, ble_gatt_disc_c_test_misc_cb, &stop_after); TEST_ASSERT_FATAL(rc == 0);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_gatt_disc_d_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gatt_disc_d_test.c b/net/nimble/host/test/src/ble_gatt_disc_d_test.c index 849f405..ce3fc4e 100644 --- a/net/nimble/host/test/src/ble_gatt_disc_d_test.c +++ b/net/nimble/host/test/src/ble_gatt_disc_d_test.c @@ -30,7 +30,7 @@ struct ble_gatt_disc_d_test_dsc { uint16_t chr_val_handle; /* 0 if last entry. */ uint16_t dsc_handle; - uint8_t dsc_uuid128[16]; + ble_uuid_any_t dsc_uuid; }; #define BLE_GATT_DISC_D_TEST_MAX_DSCS 256 @@ -54,8 +54,6 @@ ble_gatt_disc_d_test_misc_rx_rsp_once( { struct ble_att_find_info_rsp rsp; uint8_t buf[1024]; - uint16_t uuid16_cur; - uint16_t uuid16_0; int off; int rc; int i; @@ -63,8 +61,7 @@ ble_gatt_disc_d_test_misc_rx_rsp_once( /* Send the pending ATT Read By Type Request. */ ble_hs_test_util_tx_all(); - uuid16_0 = ble_uuid_128_to_16(dscs[0].dsc_uuid128); - if (uuid16_0 != 0) { + if (dscs[0].dsc_uuid.u.type == BLE_UUID_TYPE_16) { rsp.bafp_format = BLE_ATT_FIND_INFO_RSP_FORMAT_16BIT; } else { rsp.bafp_format = BLE_ATT_FIND_INFO_RSP_FORMAT_128BIT; @@ -79,9 +76,7 @@ ble_gatt_disc_d_test_misc_rx_rsp_once( break; } - uuid16_cur = ble_uuid_128_to_16(dscs[i].dsc_uuid128); - - if (uuid16_cur != 0) { + if (dscs[i].dsc_uuid.u.type == BLE_UUID_TYPE_16) { if (off + BLE_ATT_FIND_INFO_IDATA_16_SZ > ble_att_mtu(conn_handle)) { @@ -98,20 +93,16 @@ ble_gatt_disc_d_test_misc_rx_rsp_once( } /* If the value length is changing, we need a separate response. */ - if (((uuid16_0 == 0) ^ (uuid16_cur == 0)) != 0) { + if (((dscs[0].dsc_uuid.u.type == BLE_UUID_TYPE_16) ^ + (dscs[i].dsc_uuid.u.type == BLE_UUID_TYPE_16)) != 0) { break; } htole16(buf + off, dscs[i].dsc_handle); off += 2; - if (uuid16_cur != 0) { - htole16(buf + off, uuid16_cur); - off += 2; - } else { - memcpy(buf + off, dscs[i].dsc_uuid128, 16); - off += 16; - } + ble_uuid_flat(&dscs[i].dsc_uuid.u, buf + off); + off += ble_uuid_length(&dscs[i].dsc_uuid.u); } rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, @@ -162,9 +153,8 @@ ble_gatt_disc_d_test_misc_verify_dscs(struct ble_gatt_disc_d_test_dsc *dscs, ble_gatt_disc_d_test_dscs[i].chr_val_handle); TEST_ASSERT(dscs[i].dsc_handle == ble_gatt_disc_d_test_dscs[i].dsc_handle); - TEST_ASSERT(memcmp(dscs[i].dsc_uuid128, - ble_gatt_disc_d_test_dscs[i].dsc_uuid128, - 16) == 0); + TEST_ASSERT(ble_uuid_cmp(&dscs[i].dsc_uuid.u, + &ble_gatt_disc_d_test_dscs[i].dsc_uuid.u) == 0); } TEST_ASSERT(i == ble_gatt_disc_d_test_num_dscs); @@ -194,7 +184,7 @@ ble_gatt_disc_d_test_misc_cb(uint16_t conn_handle, dst = ble_gatt_disc_d_test_dscs + ble_gatt_disc_d_test_num_dscs++; dst->chr_val_handle = chr_val_handle; dst->dsc_handle = dsc->handle; - memcpy(dst->dsc_uuid128, dsc->uuid128, 16); + dst->dsc_uuid = dsc->uuid; break; case BLE_HS_EDONE: @@ -246,7 +236,7 @@ TEST_CASE(ble_gatt_disc_d_test_1) ((struct ble_gatt_disc_d_test_dsc[]) { { .chr_val_handle = 5, .dsc_handle = 6, - .dsc_uuid128 = BLE_UUID16_ARR(0x1234), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x1234), }, { 0 } }) @@ -257,11 +247,11 @@ TEST_CASE(ble_gatt_disc_d_test_1) ((struct ble_gatt_disc_d_test_dsc[]) { { .chr_val_handle = 50, .dsc_handle = 51, - .dsc_uuid128 = BLE_UUID16_ARR(0x1111), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x1111), }, { .chr_val_handle = 50, .dsc_handle = 52, - .dsc_uuid128 = BLE_UUID16_ARR(0x2222), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x2222), }, { 0 } }) @@ -272,23 +262,23 @@ TEST_CASE(ble_gatt_disc_d_test_1) ((struct ble_gatt_disc_d_test_dsc[]) { { .chr_val_handle = 50, .dsc_handle = 51, - .dsc_uuid128 = BLE_UUID16_ARR(0x1111), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x1111), }, { .chr_val_handle = 50, .dsc_handle = 52, - .dsc_uuid128 = BLE_UUID16_ARR(0x2222), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x2222), }, { .chr_val_handle = 50, .dsc_handle = 53, - .dsc_uuid128 = BLE_UUID16_ARR(0x3333), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x3333), }, { .chr_val_handle = 50, .dsc_handle = 54, - .dsc_uuid128 = BLE_UUID16_ARR(0x4444), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x4444), }, { .chr_val_handle = 50, .dsc_handle = 55, - .dsc_uuid128 = BLE_UUID16_ARR(0x5555), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x5555), }, { 0 } }) @@ -299,23 +289,23 @@ TEST_CASE(ble_gatt_disc_d_test_1) ((struct ble_gatt_disc_d_test_dsc[]) { { .chr_val_handle = 50, .dsc_handle = 51, - .dsc_uuid128 = BLE_UUID16_ARR(0x1111), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x1111), }, { .chr_val_handle = 50, .dsc_handle = 52, - .dsc_uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .dsc_uuid.u128 = BLE_UUID128_INIT( 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { .chr_val_handle = 50, .dsc_handle = 53, - .dsc_uuid128 = BLE_UUID16_ARR(0x3333), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x3333), }, { .chr_val_handle = 50, .dsc_handle = 54, - .dsc_uuid128 = { 1,0,4,0,6,9,17,7,8,43,7,4,12,43,19,35 }, + .dsc_uuid.u128 = BLE_UUID128_INIT(1,0,4,0,6,9,17,7,8,43,7,4,12,43,19,35), }, { .chr_val_handle = 50, .dsc_handle = 55, - .dsc_uuid128 = BLE_UUID16_ARR(0x5555), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x5555), }, { 0 } }) @@ -326,11 +316,11 @@ TEST_CASE(ble_gatt_disc_d_test_1) ((struct ble_gatt_disc_d_test_dsc[]) { { .chr_val_handle = 50, .dsc_handle = 51, - .dsc_uuid128 = BLE_UUID16_ARR(0x1111), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x1111), }, { .chr_val_handle = 50, .dsc_handle = 52, - .dsc_uuid128 = BLE_UUID16_ARR(0x2222), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x2222), }, { 0 } }) @@ -341,23 +331,23 @@ TEST_CASE(ble_gatt_disc_d_test_1) ((struct ble_gatt_disc_d_test_dsc[]) { { .chr_val_handle = 50, .dsc_handle = 51, - .dsc_uuid128 = BLE_UUID16_ARR(0x1111), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x1111), }, { .chr_val_handle = 50, .dsc_handle = 52, - .dsc_uuid128 = BLE_UUID16_ARR(0x2222), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x2222), }, { .chr_val_handle = 50, .dsc_handle = 53, - .dsc_uuid128 = BLE_UUID16_ARR(0x3333), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x3333), }, { .chr_val_handle = 50, .dsc_handle = 54, - .dsc_uuid128 = BLE_UUID16_ARR(0x4444), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x4444), }, { .chr_val_handle = 50, .dsc_handle = 55, - .dsc_uuid128 = BLE_UUID16_ARR(0x5555), + .dsc_uuid.u16 = BLE_UUID16_INIT(0x5555), }, { 0 } }) @@ -370,12 +360,12 @@ TEST_CASE(ble_gatt_disc_d_test_oom_all) { .chr_val_handle = 543, .dsc_handle = 548, - .dsc_uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .dsc_uuid.u128 = BLE_UUID128_INIT(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { .chr_val_handle = 543, .dsc_handle = 549, - .dsc_uuid128 = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }, + .dsc_uuid.u128 = BLE_UUID128_INIT(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), }, { 0 } }; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_gatt_disc_s_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gatt_disc_s_test.c b/net/nimble/host/test/src/ble_gatt_disc_s_test.c index cb3d575..8c8bf9a 100644 --- a/net/nimble/host/test/src/ble_gatt_disc_s_test.c +++ b/net/nimble/host/test/src/ble_gatt_disc_s_test.c @@ -28,8 +28,7 @@ struct ble_gatt_disc_s_test_svc { uint16_t start_handle; uint16_t end_handle; - uint16_t uuid16; - uint8_t uuid128[16]; + const ble_uuid_t *uuid; }; #define BLE_GATT_DISC_S_TEST_MAX_SERVICES 256 @@ -49,7 +48,7 @@ ble_gatt_disc_s_test_init(void) static int ble_gatt_disc_s_test_misc_svc_length(struct ble_gatt_disc_s_test_svc *service) { - if (service->uuid16 != 0) { + if (service->uuid->type == BLE_UUID_TYPE_16) { return 6; } else { return 20; @@ -86,7 +85,7 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once( break; } - if (services[i].uuid16 != 0) { + if (services[i].uuid->type == BLE_UUID_TYPE_16) { if (off + BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_16 > ble_att_mtu(conn_handle)) { @@ -108,13 +107,8 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once( htole16(buf + off, services[i].end_handle); off += 2; - if (services[i].uuid16 != 0) { - htole16(buf + off, services[i].uuid16); - off += 2; - } else { - memcpy(buf + off, services[i].uuid128, 16); - off += 16; - } + ble_uuid_flat(services[i].uuid, buf + off); + off += ble_uuid_length(services[i].uuid); } rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, @@ -217,8 +211,6 @@ static void ble_gatt_disc_s_test_misc_verify_services( struct ble_gatt_disc_s_test_svc *services) { - uint16_t uuid16; - uint8_t *uuid128; int i; for (i = 0; services[i].start_handle != 0; i++) { @@ -227,13 +219,8 @@ ble_gatt_disc_s_test_misc_verify_services( TEST_ASSERT(services[i].end_handle == ble_gatt_disc_s_test_svcs[i].end_handle); - uuid128 = ble_gatt_disc_s_test_svcs[i].uuid128; - uuid16 = ble_uuid_128_to_16(uuid128); - if (uuid16 != 0) { - TEST_ASSERT(services[i].uuid16 == uuid16); - } else { - TEST_ASSERT(memcmp(services[i].uuid128, uuid128, 16) == 0); - } + TEST_ASSERT(ble_uuid_cmp(services[i].uuid, + &ble_gatt_disc_s_test_svcs[i].uuid.u) == 0); } TEST_ASSERT(i == ble_gatt_disc_s_test_num_svcs); @@ -301,11 +288,7 @@ ble_gatt_disc_s_test_misc_good_uuid( ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}), NULL, NULL); - if (services[0].uuid16 != 0) { - rc = ble_uuid_16_to_128(services[0].uuid16, services[0].uuid128); - TEST_ASSERT_FATAL(rc == 0); - } - rc = ble_gattc_disc_svc_by_uuid(2, services[0].uuid128, + rc = ble_gattc_disc_svc_by_uuid(2, services[0].uuid, ble_gatt_disc_s_test_misc_disc_cb, NULL); TEST_ASSERT(rc == 0); @@ -317,38 +300,38 @@ TEST_CASE(ble_gatt_disc_s_test_disc_all) { /*** One 128-bit service. */ ble_gatt_disc_s_test_misc_good_all((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, { 0 } }); /*** Two 128-bit services. */ ble_gatt_disc_s_test_misc_good_all((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 10, 50, 0, {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 10, 50, BLE_UUID128_DECLARE(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ), }, { 0 } }); /*** Five 128-bit services. */ ble_gatt_disc_s_test_misc_good_all((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 10, 50, 0, {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, }, - { 80, 120, 0, {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, }, - { 123, 678, 0, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }, }, - { 751, 999, 0, {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 10, 50, BLE_UUID128_DECLARE(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ), }, + { 80, 120, BLE_UUID128_DECLARE(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ), }, + { 123, 678, BLE_UUID128_DECLARE(4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ), }, + { 751, 999, BLE_UUID128_DECLARE(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ), }, { 0 } }); /*** One 128-bit service, one 16-bit-service. */ ble_gatt_disc_s_test_misc_good_all((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 6, 7, 0x1234 }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 6, 7, BLE_UUID16_DECLARE(0x1234) }, { 0 } }); /*** End with handle 0xffff. */ ble_gatt_disc_s_test_misc_good_all((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 7, 0xffff, 0, {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 7, 0xffff,BLE_UUID128_DECLARE(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ), }, { 0 } }); } @@ -357,61 +340,61 @@ TEST_CASE(ble_gatt_disc_s_test_disc_uuid) { /*** 128-bit service; one entry. */ ble_gatt_disc_s_test_misc_good_uuid((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, { 0 } }); /*** 128-bit service; two entries. */ ble_gatt_disc_s_test_misc_good_uuid((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 8, 43, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 8, 43, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, { 0 } }); /*** 128-bit service; five entries. */ ble_gatt_disc_s_test_misc_good_uuid((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 8, 43, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 67, 100, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 102, 103, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 262, 900, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 8, 43, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 67, 100, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 102, 103, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 262, 900, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, { 0 } }); /*** 128-bit service; end with handle 0xffff. */ ble_gatt_disc_s_test_misc_good_uuid((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 7, 0xffff, 0, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 7, 0xffff,BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, { 0 } }); /*** 16-bit service; one entry. */ ble_gatt_disc_s_test_misc_good_uuid((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0x1234 }, + { 1, 5, BLE_UUID16_DECLARE(0x1234) }, { 0 } }); /*** 16-bit service; two entries. */ ble_gatt_disc_s_test_misc_good_uuid((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0x1234 }, - { 85, 243, 0x1234 }, + { 1, 5, BLE_UUID16_DECLARE(0x1234) }, + { 85, 243, BLE_UUID16_DECLARE(0x1234) }, { 0 } }); /*** 16-bit service; five entries. */ ble_gatt_disc_s_test_misc_good_uuid((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0x1234 }, - { 85, 243, 0x1234 }, - { 382, 383, 0x1234 }, - { 562, 898, 0x1234 }, - { 902, 984, 0x1234 }, + { 1, 5, BLE_UUID16_DECLARE(0x1234) }, + { 85, 243, BLE_UUID16_DECLARE(0x1234) }, + { 382, 383, BLE_UUID16_DECLARE(0x1234) }, + { 562, 898, BLE_UUID16_DECLARE(0x1234) }, + { 902, 984, BLE_UUID16_DECLARE(0x1234) }, { 0 } }); /*** 16-bit service; end with handle 0xffff. */ ble_gatt_disc_s_test_misc_good_uuid((struct ble_gatt_disc_s_test_svc[]) { - { 1, 5, 0x1234 }, - { 9, 0xffff, 0x1234 }, + { 1, 5, BLE_UUID16_DECLARE(0x1234) }, + { 9, 0xffff,BLE_UUID16_DECLARE(0x1234) }, { 0 } }); } @@ -419,8 +402,8 @@ TEST_CASE(ble_gatt_disc_s_test_disc_uuid) TEST_CASE(ble_gatt_disc_s_test_oom_all) { struct ble_gatt_disc_s_test_svc svcs[] = { - { 1, 5, 0, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 6, 10, 0, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 6, 10, BLE_UUID128_DECLARE(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ), }, { 0 }, }; @@ -493,12 +476,12 @@ TEST_CASE(ble_gatt_disc_s_test_oom_uuid) { /* Retrieve enough services to require two transactions. */ struct ble_gatt_disc_s_test_svc svcs[] = { - { 1, 5, 0, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 6, 10, 0, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 11, 15, 0, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 16, 20, 0, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 21, 25, 0, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 26, 30, 0, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 6, 10, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 11, 15, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 16, 20, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 21, 25, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 26, 30, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, { 0 }, }; @@ -513,7 +496,7 @@ TEST_CASE(ble_gatt_disc_s_test_oom_uuid) NULL, NULL); /* Initiate a discover all services procedure. */ - rc = ble_gattc_disc_svc_by_uuid(1, svcs[0].uuid128, + rc = ble_gattc_disc_svc_by_uuid(1, svcs[0].uuid, ble_gatt_disc_s_test_misc_disc_cb, NULL); TEST_ASSERT_FATAL(rc == 0); @@ -573,8 +556,8 @@ TEST_CASE(ble_gatt_disc_s_test_oom_uuid) TEST_CASE(ble_gatt_disc_s_test_oom_timeout) { struct ble_gatt_disc_s_test_svc svcs[] = { - { 1, 5, 0, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, - { 6, 10, 0, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, }, + { 1, 5, BLE_UUID128_DECLARE(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), }, + { 6, 10, BLE_UUID128_DECLARE(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ), }, { 0 }, }; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_gatt_find_s_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gatt_find_s_test.c b/net/nimble/host/test/src/ble_gatt_find_s_test.c index 79397d5..d8834f4 100644 --- a/net/nimble/host/test/src/ble_gatt_find_s_test.c +++ b/net/nimble/host/test/src/ble_gatt_find_s_test.c @@ -33,7 +33,7 @@ struct ble_gatt_find_s_test_entry { uint16_t inc_handle; /* 0 indicates no more entries. */ uint16_t start_handle; uint16_t end_handle; - uint8_t uuid128[16]; + const ble_uuid_t *uuid; }; static void @@ -81,8 +81,8 @@ ble_gatt_find_s_test_misc_verify_incs( entries[i].start_handle); TEST_ASSERT(ble_gatt_find_s_test_svcs[i].end_handle == entries[i].end_handle); - TEST_ASSERT(memcmp(ble_gatt_find_s_test_svcs[i].uuid128, - entries[i].uuid128, 16) == 0); + TEST_ASSERT(ble_uuid_cmp(&ble_gatt_find_s_test_svcs[i].uuid.u, + entries[i].uuid) == 0); } TEST_ASSERT(i == ble_gatt_find_s_test_num_svcs); @@ -94,7 +94,6 @@ ble_gatt_find_s_test_misc_rx_read_type( uint16_t conn_handle, struct ble_gatt_find_s_test_entry *entries) { struct ble_att_read_type_rsp rsp; - uint16_t uuid16; uint8_t buf[1024]; int off; int rc; @@ -108,8 +107,7 @@ ble_gatt_find_s_test_misc_rx_read_type( break; } - uuid16 = ble_uuid_128_to_16(entries[i].uuid128); - if (uuid16 == 0) { + if (entries[i].uuid->type != BLE_UUID_TYPE_16) { if (rsp.batp_length != 0) { break; } @@ -129,8 +127,8 @@ ble_gatt_find_s_test_misc_rx_read_type( htole16(buf + off, entries[i].end_handle); off += 2; - if (uuid16 != 0) { - htole16(buf + off, uuid16); + if (entries[i].uuid->type == BLE_UUID_TYPE_16) { + htole16(buf + off, ble_uuid_u16(entries[i].uuid)); off += 2; } } @@ -151,13 +149,15 @@ ble_gatt_find_s_test_misc_rx_read_type( } static void -ble_gatt_find_s_test_misc_rx_read(uint16_t conn_handle, uint8_t *uuid128) +ble_gatt_find_s_test_misc_rx_read(uint16_t conn_handle, const ble_uuid_t *uuid) { uint8_t buf[17]; int rc; + TEST_ASSERT(uuid->type == BLE_UUID_TYPE_128); + buf[0] = BLE_ATT_OP_READ_RSP; - memcpy(buf + 1, uuid128, 16); + ble_uuid_flat(uuid, buf + 1); rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, 17); @@ -229,12 +229,12 @@ ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle, break; } - if (ble_uuid_128_to_16(entries[idx].uuid128) == 0) { + if (entries[idx].uuid->type == BLE_UUID_TYPE_128) { TEST_ASSERT(num_found == 1); ble_gatt_find_s_test_misc_verify_tx_read( entries[idx].start_handle); ble_gatt_find_s_test_misc_rx_read(conn_handle, - entries[idx].uuid128); + entries[idx].uuid); } idx += num_found; @@ -248,8 +248,8 @@ ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle, entries[i].start_handle); TEST_ASSERT(ble_gatt_find_s_test_svcs[i].end_handle == entries[i].end_handle); - TEST_ASSERT(memcmp(ble_gatt_find_s_test_svcs[i].uuid128, - entries[i].uuid128, 16) == 0); + TEST_ASSERT(ble_uuid_cmp(&ble_gatt_find_s_test_svcs[i].uuid.u, + entries[i].uuid) == 0); } } @@ -264,12 +264,12 @@ TEST_CASE(ble_gatt_find_s_test_1) .inc_handle = 6, .start_handle = 35, .end_handle = 49, - .uuid128 = BLE_UUID16_ARR(0x5155), + .uuid = BLE_UUID16_DECLARE(0x5155), }, { .inc_handle = 9, .start_handle = 543, .end_handle = 870, - .uuid128 = BLE_UUID16_ARR(0x1122), + .uuid = BLE_UUID16_DECLARE(0x1122), }, { 0, } }) @@ -284,7 +284,7 @@ TEST_CASE(ble_gatt_find_s_test_1) .inc_handle = 36, .start_handle = 403, .end_handle = 859, - .uuid128 = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }, + .uuid = BLE_UUID128_DECLARE(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), }, { 0, } }) @@ -299,12 +299,12 @@ TEST_CASE(ble_gatt_find_s_test_1) .inc_handle = 36, .start_handle = 403, .end_handle = 859, - .uuid128 = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }, + .uuid = BLE_UUID128_DECLARE(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), }, { .inc_handle = 39, .start_handle = 900, .end_handle = 932, - .uuid128 = { 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 }, + .uuid = BLE_UUID128_DECLARE(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17), }, { 0, } }) @@ -319,27 +319,27 @@ TEST_CASE(ble_gatt_find_s_test_1) .inc_handle = 36, .start_handle = 403, .end_handle = 859, - .uuid128 = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }, + .uuid = BLE_UUID128_DECLARE(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), }, { .inc_handle = 37, .start_handle = 35, .end_handle = 49, - .uuid128 = BLE_UUID16_ARR(0x5155), + .uuid = BLE_UUID16_DECLARE(0x5155), }, { .inc_handle = 38, .start_handle = 543, .end_handle = 870, - .uuid128 = BLE_UUID16_ARR(0x1122), + .uuid = BLE_UUID16_DECLARE(0x1122), }, { .inc_handle = 39, .start_handle = 900, .end_handle = 932, - .uuid128 = { 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 }, + .uuid = BLE_UUID128_DECLARE(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17), }, { .inc_handle = 40, .start_handle = 940, .end_handle = 950, - .uuid128 = { 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 }, + .uuid = BLE_UUID128_DECLARE(3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18), }, { 0, } }) @@ -354,13 +354,13 @@ TEST_CASE(ble_gatt_find_s_test_oom) .inc_handle = 21, .start_handle = 800, .end_handle = 899, - .uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, + .uuid = BLE_UUID128_DECLARE(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), }, { .inc_handle = 22, .start_handle = 900, .end_handle = 999, - .uuid128 = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }, + .uuid = BLE_UUID128_DECLARE(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), }, { 0 } }; @@ -406,7 +406,7 @@ TEST_CASE(ble_gatt_find_s_test_oom) * follow-up request, so there is always an mbuf available. */ /* XXX: Find a way to test this. */ - ble_gatt_find_s_test_misc_rx_read(1, incs[0].uuid128); + ble_gatt_find_s_test_misc_rx_read(1, incs[0].uuid); ble_hs_test_util_tx_all(); /* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */ @@ -418,7 +418,7 @@ TEST_CASE(ble_gatt_find_s_test_oom) os_time_advance(ticks_until); ble_gattc_timer(); - ble_gatt_find_s_test_misc_rx_read(1, incs[1].uuid128); + ble_gatt_find_s_test_misc_rx_read(1, incs[1].uuid); ble_hs_test_util_tx_all(); ble_hs_test_util_rx_att_err_rsp(1, http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_gatt_read_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gatt_read_test.c b/net/nimble/host/test/src/ble_gatt_read_test.c index 6ffdc43..54c8a56 100644 --- a/net/nimble/host/test/src/ble_gatt_read_test.c +++ b/net/nimble/host/test/src/ble_gatt_read_test.c @@ -285,7 +285,7 @@ ble_gatt_read_test_misc_verify_bad(uint8_t att_status, static void ble_gatt_read_test_misc_uuid_verify_good( - uint16_t start_handle, uint16_t end_handle, void *uuid128, + uint16_t start_handle, uint16_t end_handle, const ble_uuid_t *uuid, int stop_after, struct ble_hs_test_util_flat_attr *attrs) { int num_read; @@ -297,7 +297,7 @@ ble_gatt_read_test_misc_uuid_verify_good( ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}), NULL, NULL); - rc = ble_gattc_read_by_uuid(2, start_handle, end_handle, uuid128, + rc = ble_gattc_read_by_uuid(2, start_handle, end_handle, uuid, ble_gatt_read_test_cb, &stop_after); TEST_ASSERT_FATAL(rc == 0); @@ -540,7 +540,7 @@ TEST_CASE(ble_gatt_read_test_by_handle) TEST_CASE(ble_gatt_read_test_by_uuid) { /* Read a single seven-byte attribute. */ - ble_gatt_read_test_misc_uuid_verify_good(1, 100, BLE_UUID16(0x1234), 0, + ble_gatt_read_test_misc_uuid_verify_good(1, 100, BLE_UUID16_DECLARE(0x1234), 0, (struct ble_hs_test_util_flat_attr[]) { { .handle = 43, .value = { 1,2,3,4,5,6,7 }, @@ -550,7 +550,7 @@ TEST_CASE(ble_gatt_read_test_by_uuid) } }); /* Read two seven-byte attributes; one response. */ - ble_gatt_read_test_misc_uuid_verify_good(1, 100, BLE_UUID16(0x1234), 0, + ble_gatt_read_test_misc_uuid_verify_good(1, 100, BLE_UUID16_DECLARE(0x1234), 0, (struct ble_hs_test_util_flat_attr[]) { { .handle = 43, .value = { 1,2,3,4,5,6,7 }, @@ -564,7 +564,7 @@ TEST_CASE(ble_gatt_read_test_by_uuid) } }); /* Read two attributes; two responses. */ - ble_gatt_read_test_misc_uuid_verify_good(1, 100, BLE_UUID16(0x1234), 0, + ble_gatt_read_test_misc_uuid_verify_good(1, 100, BLE_UUID16_DECLARE(0x1234), 0, (struct ble_hs_test_util_flat_attr[]) { { .handle = 43, .value = { 1,2,3,4,5,6,7 }, @@ -578,7 +578,7 @@ TEST_CASE(ble_gatt_read_test_by_uuid) } }); /* Stop after three reads. */ - ble_gatt_read_test_misc_uuid_verify_good(1, 100, BLE_UUID16(0x1234), 3, + ble_gatt_read_test_misc_uuid_verify_good(1, 100, BLE_UUID16_DECLARE(0x1234), 3, (struct ble_hs_test_util_flat_attr[]) { { .handle = 43, .value = { 1,2,3,4,5,6,7 }, http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_gatts_notify_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gatts_notify_test.c b/net/nimble/host/test/src/ble_gatts_notify_test.c index a1f1469..21f1afb 100644 --- a/net/nimble/host/test/src/ble_gatts_notify_test.c +++ b/net/nimble/host/test/src/ble_gatts_notify_test.c @@ -43,14 +43,14 @@ ble_gatts_notify_test_misc_reg_cb(struct ble_gatt_register_ctxt *ctxt, static const struct ble_gatt_svc_def ble_gatts_notify_test_svcs[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(BLE_GATTS_NOTIFY_TEST_CHR_1_UUID), + .uuid = BLE_UUID16_DECLARE(BLE_GATTS_NOTIFY_TEST_CHR_1_UUID), .access_cb = ble_gatts_notify_test_misc_access, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY | BLE_GATT_CHR_F_INDICATE, }, { - .uuid128 = BLE_UUID16(BLE_GATTS_NOTIFY_TEST_CHR_2_UUID), + .uuid = BLE_UUID16_DECLARE(BLE_GATTS_NOTIFY_TEST_CHR_2_UUID), .access_cb = ble_gatts_notify_test_misc_access, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY | BLE_GATT_CHR_F_INDICATE, @@ -369,7 +369,7 @@ ble_gatts_notify_test_misc_reg_cb(struct ble_gatt_register_ctxt *ctxt, uint16_t uuid16; if (ctxt->op == BLE_GATT_REGISTER_OP_CHR) { - uuid16 = ble_uuid_128_to_16(ctxt->chr.chr_def->uuid128); + uuid16 = ble_uuid_u16(ctxt->chr.chr_def->uuid); switch (uuid16) { case BLE_GATTS_NOTIFY_TEST_CHR_1_UUID: ble_gatts_notify_test_chr_1_def_handle = ctxt->chr.def_handle; @@ -979,19 +979,19 @@ TEST_CASE(ble_gatts_notify_test_disallowed) const struct ble_gatt_svc_def svcs[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(1), + .uuid = BLE_UUID16_DECLARE(1), .access_cb = ble_gatts_notify_test_misc_access, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY, .val_handle = &chr1_val_handle, }, { - .uuid128 = BLE_UUID16(2), + .uuid = BLE_UUID16_DECLARE(2), .access_cb = ble_gatts_notify_test_misc_access, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_INDICATE, .val_handle = &chr2_val_handle, }, { - .uuid128 = BLE_UUID16(3), + .uuid = BLE_UUID16_DECLARE(3), .access_cb = ble_gatts_notify_test_misc_access, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY | BLE_GATT_CHR_F_INDICATE, http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_gatts_read_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gatts_read_test.c b/net/nimble/host/test/src/ble_gatts_read_test.c index 9f321c6..bb5db1e 100644 --- a/net/nimble/host/test/src/ble_gatts_read_test.c +++ b/net/nimble/host/test/src/ble_gatts_read_test.c @@ -46,13 +46,13 @@ ble_gatts_read_test_misc_reg_cb(struct ble_gatt_register_ctxt *ctxt, static const struct ble_gatt_svc_def ble_gatts_read_test_svcs[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(BLE_GATTS_READ_TEST_CHR_1_UUID), + .uuid = BLE_UUID16_DECLARE(BLE_GATTS_READ_TEST_CHR_1_UUID), .access_cb = ble_gatts_read_test_util_access_1, .flags = BLE_GATT_CHR_F_READ }, { - .uuid128 = BLE_UUID16(BLE_GATTS_READ_TEST_CHR_2_UUID), + .uuid = BLE_UUID16_DECLARE(BLE_GATTS_READ_TEST_CHR_2_UUID), .access_cb = ble_gatts_read_test_util_access_2, .flags = BLE_GATT_CHR_F_READ }, { @@ -103,7 +103,7 @@ ble_gatts_read_test_misc_reg_cb(struct ble_gatt_register_ctxt *ctxt, uint16_t uuid16; if (ctxt->op == BLE_GATT_REGISTER_OP_CHR) { - uuid16 = ble_uuid_128_to_16(ctxt->chr.chr_def->uuid128); + uuid16 = ble_uuid_u16(ctxt->chr.chr_def->uuid); switch (uuid16) { case BLE_GATTS_READ_TEST_CHR_1_UUID: ble_gatts_read_test_chr_1_def_handle = ctxt->chr.def_handle; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_gatts_reg_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_gatts_reg_test.c b/net/nimble/host/test/src/ble_gatts_reg_test.c index 88a9b6c..1486690 100644 --- a/net/nimble/host/test/src/ble_gatts_reg_test.c +++ b/net/nimble/host/test/src/ble_gatts_reg_test.c @@ -29,7 +29,7 @@ struct ble_gatts_reg_test_entry { uint8_t op; - uint8_t uuid128[16]; + ble_uuid_any_t uuid; uint16_t handle; uint16_t val_handle; /* If a characteristic. */ @@ -64,13 +64,13 @@ ble_gatts_reg_test_misc_reg_cb(struct ble_gatt_register_ctxt *ctxt, void *arg) entry->op = ctxt->op; switch (ctxt->op) { case BLE_GATT_REGISTER_OP_SVC: - memcpy(entry->uuid128, ctxt->svc.svc_def->uuid128, 16); + ble_uuid_to_any(ctxt->svc.svc_def->uuid, &entry->uuid); entry->handle = ctxt->svc.handle; entry->svc = ctxt->svc.svc_def; break; case BLE_GATT_REGISTER_OP_CHR: - memcpy(entry->uuid128, ctxt->chr.chr_def->uuid128, 16); + ble_uuid_to_any(ctxt->chr.chr_def->uuid, &entry->uuid); entry->handle = ctxt->chr.def_handle; entry->val_handle = ctxt->chr.val_handle; entry->svc = ctxt->chr.svc_def; @@ -78,7 +78,7 @@ ble_gatts_reg_test_misc_reg_cb(struct ble_gatt_register_ctxt *ctxt, void *arg) break; case BLE_GATT_REGISTER_OP_DSC: - memcpy(entry->uuid128, ctxt->dsc.dsc_def->uuid128, 16); + ble_uuid_to_any(ctxt->dsc.dsc_def->uuid, &entry->uuid); entry->handle = ctxt->dsc.handle; entry->svc = ctxt->dsc.svc_def; entry->chr = ctxt->dsc.chr_def; @@ -102,13 +102,13 @@ ble_gatts_reg_test_misc_lookup_good(struct ble_gatts_reg_test_entry *entry) switch (entry->op) { case BLE_GATT_REGISTER_OP_SVC: - rc = ble_gatts_find_svc(entry->uuid128, &svc_handle); + rc = ble_gatts_find_svc(&entry->uuid.u, &svc_handle); TEST_ASSERT_FATAL(rc == 0); TEST_ASSERT(svc_handle == entry->handle); break; case BLE_GATT_REGISTER_OP_CHR: - rc = ble_gatts_find_chr(entry->svc->uuid128, entry->chr->uuid128, + rc = ble_gatts_find_chr(entry->svc->uuid, entry->chr->uuid, &chr_def_handle, &chr_val_handle); TEST_ASSERT_FATAL(rc == 0); TEST_ASSERT(chr_def_handle == entry->handle); @@ -116,8 +116,8 @@ ble_gatts_reg_test_misc_lookup_good(struct ble_gatts_reg_test_entry *entry) break; case BLE_GATT_REGISTER_OP_DSC: - rc = ble_gatts_find_dsc(entry->svc->uuid128, entry->chr->uuid128, - entry->dsc->uuid128, &dsc_handle); + rc = ble_gatts_find_dsc(entry->svc->uuid, entry->chr->uuid, + entry->dsc->uuid, &dsc_handle); break; default: @@ -130,30 +130,30 @@ static void ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) { struct ble_gatts_reg_test_entry *cur; - uint8_t wrong_uuid[16]; + ble_uuid_any_t wrong_uuid; int rc; int i; switch (entry->op) { case BLE_GATT_REGISTER_OP_SVC: /* Wrong service UUID. */ - memcpy(wrong_uuid, entry->svc->uuid128, 16); - wrong_uuid[15]++; - rc = ble_gatts_find_svc(wrong_uuid, NULL); + ble_uuid_to_any(entry->svc->uuid, &wrong_uuid); + wrong_uuid.u16.value++; + rc = ble_gatts_find_svc(&wrong_uuid.u, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); break; case BLE_GATT_REGISTER_OP_CHR: /* Correct service UUID, wrong characteristic UUID. */ - memcpy(wrong_uuid, entry->chr->uuid128, 16); - wrong_uuid[15]++; - rc = ble_gatts_find_chr(entry->svc->uuid128, wrong_uuid, NULL, NULL); + ble_uuid_to_any(entry->chr->uuid, &wrong_uuid); + wrong_uuid.u16.value++; + rc = ble_gatts_find_chr(entry->svc->uuid, &wrong_uuid.u, NULL, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); /* Incorrect service UUID, correct characteristic UUID. */ - memcpy(wrong_uuid, entry->svc->uuid128, 16); - wrong_uuid[15]++; - rc = ble_gatts_find_chr(wrong_uuid, entry->chr->uuid128, NULL, NULL); + ble_uuid_to_any(entry->svc->uuid, &wrong_uuid); + wrong_uuid.u16.value++; + rc = ble_gatts_find_chr(&wrong_uuid.u, entry->chr->uuid, NULL, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); /* Existing (but wrong) service, correct characteristic UUID. */ @@ -162,8 +162,8 @@ ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) switch (cur->op) { case BLE_GATT_REGISTER_OP_SVC: if (cur->svc != entry->svc) { - rc = ble_gatts_find_chr(cur->svc->uuid128, - entry->chr->uuid128, + rc = ble_gatts_find_chr(cur->svc->uuid, + entry->chr->uuid, NULL, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); } @@ -172,8 +172,8 @@ ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) case BLE_GATT_REGISTER_OP_CHR: /* Characteristic that isn't in this service. */ if (cur->svc != entry->svc) { - rc = ble_gatts_find_chr(entry->svc->uuid128, - cur->chr->uuid128, + rc = ble_gatts_find_chr(entry->svc->uuid, + cur->chr->uuid, NULL, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); } @@ -181,8 +181,8 @@ ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) case BLE_GATT_REGISTER_OP_DSC: /* Use descriptor UUID instead of characteristic UUID. */ - rc = ble_gatts_find_chr(entry->svc->uuid128, - cur->dsc->uuid128, + rc = ble_gatts_find_chr(entry->svc->uuid, + cur->dsc->uuid, NULL, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); break; @@ -196,17 +196,17 @@ ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) case BLE_GATT_REGISTER_OP_DSC: /* Correct svc/chr UUID, wrong dsc UUID. */ - memcpy(wrong_uuid, entry->dsc->uuid128, 16); - wrong_uuid[15]++; - rc = ble_gatts_find_dsc(entry->svc->uuid128, entry->chr->uuid128, - wrong_uuid, NULL); + ble_uuid_to_any(entry->dsc->uuid, &wrong_uuid); + wrong_uuid.u128.value[15]++; + rc = ble_gatts_find_dsc(entry->svc->uuid, entry->chr->uuid, + &wrong_uuid.u, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); /* Incorrect svc UUID, correct chr/dsc UUID. */ - memcpy(wrong_uuid, entry->svc->uuid128, 16); - wrong_uuid[15]++; - rc = ble_gatts_find_dsc(wrong_uuid, entry->chr->uuid128, - entry->dsc->uuid128, NULL); + ble_uuid_to_any(entry->svc->uuid, &wrong_uuid); + wrong_uuid.u128.value[15]++; + rc = ble_gatts_find_dsc(&wrong_uuid.u, entry->chr->uuid, + entry->dsc->uuid, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); for (i = 0; i < ble_gatts_reg_test_num_entries; i++) { @@ -215,9 +215,9 @@ ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) case BLE_GATT_REGISTER_OP_SVC: /* Existing (but wrong) svc, correct chr/dsc UUID. */ if (cur->svc != entry->svc) { - rc = ble_gatts_find_dsc(cur->svc->uuid128, - entry->chr->uuid128, - entry->dsc->uuid128, + rc = ble_gatts_find_dsc(cur->svc->uuid, + entry->chr->uuid, + entry->dsc->uuid, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); } @@ -226,9 +226,9 @@ ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) case BLE_GATT_REGISTER_OP_CHR: /* Existing (but wrong) svc/chr, correct dsc UUID. */ if (cur->chr != entry->chr) { - rc = ble_gatts_find_dsc(cur->svc->uuid128, - cur->chr->uuid128, - entry->dsc->uuid128, + rc = ble_gatts_find_dsc(cur->svc->uuid, + cur->chr->uuid, + entry->dsc->uuid, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); } @@ -237,9 +237,9 @@ ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) case BLE_GATT_REGISTER_OP_DSC: /* Descriptor that isn't in this characteristic. */ if (cur->chr != entry->chr) { - rc = ble_gatts_find_dsc(cur->svc->uuid128, - cur->chr->uuid128, - entry->dsc->uuid128, + rc = ble_gatts_find_dsc(cur->svc->uuid, + cur->chr->uuid, + entry->dsc->uuid, NULL); TEST_ASSERT(rc == BLE_HS_ENOENT); } @@ -259,14 +259,14 @@ ble_gatts_reg_test_misc_lookup_bad(struct ble_gatts_reg_test_entry *entry) } static void -ble_gatts_reg_test_misc_verify_entry(uint8_t op, const uint8_t *uuid128) +ble_gatts_reg_test_misc_verify_entry(uint8_t op, const ble_uuid_t *uuid) { struct ble_gatts_reg_test_entry *entry; int i; for (i = 0; i < ble_gatts_reg_test_num_entries; i++) { entry = ble_gatts_reg_test_entries + i; - if (entry->op == op && memcmp(entry->uuid128, uuid128, 16) == 0) { + if (entry->op == op && ble_uuid_cmp(&entry->uuid.u, uuid) == 0) { break; } } @@ -316,11 +316,11 @@ TEST_CASE(ble_gatts_reg_test_svc_return) ble_gatts_reg_test_init(); struct ble_gatt_svc_def svcs_circ[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .includes = (const struct ble_gatt_svc_def*[]) { svcs_circ + 1, NULL }, }, { .type = BLE_GATT_SVC_TYPE_SECONDARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .includes = (const struct ble_gatt_svc_def*[]) { svcs_circ + 0, NULL }, }, { 0 @@ -333,11 +333,11 @@ TEST_CASE(ble_gatts_reg_test_svc_return) ble_gatts_reg_test_init(); struct ble_gatt_svc_def svcs_good[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .includes = (const struct ble_gatt_svc_def*[]) { svcs_good + 1, NULL }, }, { .type = BLE_GATT_SVC_TYPE_SECONDARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), }, { 0 } }; @@ -354,9 +354,9 @@ TEST_CASE(ble_gatts_reg_test_chr_return) ble_gatts_reg_test_init(); struct ble_gatt_svc_def svcs_no_chr_cb[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x1111), + .uuid = BLE_UUID16_DECLARE(0x1111), .flags = BLE_GATT_CHR_F_READ, }, { 0 @@ -372,9 +372,9 @@ TEST_CASE(ble_gatts_reg_test_chr_return) ble_gatts_reg_test_init(); struct ble_gatt_svc_def svcs_good[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x1111), + .uuid = BLE_UUID16_DECLARE(0x1111), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, }, { @@ -396,13 +396,13 @@ TEST_CASE(ble_gatts_reg_test_dsc_return) ble_gatts_reg_test_init(); struct ble_gatt_svc_def svcs_no_dsc_cb[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x1111), + .uuid = BLE_UUID16_DECLARE(0x1111), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .descriptors = (struct ble_gatt_dsc_def[]) { { - .uuid128 = BLE_UUID16(0x8888), + .uuid = BLE_UUID16_DECLARE(0x8888), .att_flags = 5, }, { 0 @@ -421,13 +421,13 @@ TEST_CASE(ble_gatts_reg_test_dsc_return) ble_gatts_reg_test_init(); struct ble_gatt_svc_def svcs_good[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x1111), + .uuid = BLE_UUID16_DECLARE(0x1111), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .descriptors = (struct ble_gatt_dsc_def[]) { { - .uuid128 = BLE_UUID16(0x8888), + .uuid = BLE_UUID16_DECLARE(0x8888), .access_cb = ble_gatts_reg_test_misc_dummy_access, .att_flags = 5, }, { @@ -462,17 +462,17 @@ ble_gatts_reg_test_misc_svcs(struct ble_gatt_svc_def *svcs) /* Verify that the appropriate callbacks were executed. */ for (svc = svcs; svc->type != BLE_GATT_SVC_TYPE_END; svc++) { ble_gatts_reg_test_misc_verify_entry(BLE_GATT_REGISTER_OP_SVC, - svc->uuid128); + svc->uuid); if (svc->characteristics != NULL) { - for (chr = svc->characteristics; chr->uuid128 != NULL; chr++) { + for (chr = svc->characteristics; chr->uuid != NULL; chr++) { ble_gatts_reg_test_misc_verify_entry(BLE_GATT_REGISTER_OP_CHR, - chr->uuid128); + chr->uuid); if (chr->descriptors != NULL) { - for (dsc = chr->descriptors; dsc->uuid128 != NULL; dsc++) { + for (dsc = chr->descriptors; dsc->uuid != NULL; dsc++) { ble_gatts_reg_test_misc_verify_entry( - BLE_GATT_REGISTER_OP_DSC, dsc->uuid128); + BLE_GATT_REGISTER_OP_DSC, dsc->uuid); } } } @@ -485,7 +485,7 @@ TEST_CASE(ble_gatts_reg_test_svc_cb) /*** 1 primary. */ ble_gatts_reg_test_misc_svcs((struct ble_gatt_svc_def[]) { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), }, { 0 } }); @@ -493,13 +493,13 @@ TEST_CASE(ble_gatts_reg_test_svc_cb) /*** 3 primary. */ ble_gatts_reg_test_misc_svcs((struct ble_gatt_svc_def[]) { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), }, { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x2234), + .uuid = BLE_UUID16_DECLARE(0x2234), }, { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x3234), + .uuid = BLE_UUID16_DECLARE(0x3234), }, { 0 } }); @@ -508,10 +508,10 @@ TEST_CASE(ble_gatts_reg_test_svc_cb) /*** 1 primary, 1 secondary. */ ble_gatts_reg_test_misc_svcs((struct ble_gatt_svc_def[]) { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), }, { .type = BLE_GATT_SVC_TYPE_SECONDARY, - .uuid128 = BLE_UUID16(0x2222), + .uuid = BLE_UUID16_DECLARE(0x2222), }, { 0 } }); @@ -520,12 +520,12 @@ TEST_CASE(ble_gatts_reg_test_svc_cb) struct ble_gatt_svc_def svcs[] = { [0] = { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .includes = (const struct ble_gatt_svc_def*[]) { svcs + 1, NULL, }, }, [1] = { .type = BLE_GATT_SVC_TYPE_SECONDARY, - .uuid128 = BLE_UUID16(0x2222), + .uuid = BLE_UUID16_DECLARE(0x2222), }, { 0 } @@ -540,9 +540,9 @@ TEST_CASE(ble_gatts_reg_test_chr_cb) /*** 1 characteristic. */ ble_gatts_reg_test_misc_svcs((struct ble_gatt_svc_def[]) { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x1111), + .uuid = BLE_UUID16_DECLARE(0x1111), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .val_handle = val_handles + 0, @@ -556,14 +556,14 @@ TEST_CASE(ble_gatts_reg_test_chr_cb) /*** 3 characteristics. */ ble_gatts_reg_test_misc_svcs((struct ble_gatt_svc_def[]) { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x1111), + .uuid = BLE_UUID16_DECLARE(0x1111), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .val_handle = val_handles + 0, }, { - .uuid128 = BLE_UUID16(0x2222), + .uuid = BLE_UUID16_DECLARE(0x2222), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_WRITE, .val_handle = val_handles + 1, @@ -572,9 +572,9 @@ TEST_CASE(ble_gatts_reg_test_chr_cb) } }, }, { .type = BLE_GATT_SVC_TYPE_SECONDARY, - .uuid128 = BLE_UUID16(0x5678), + .uuid = BLE_UUID16_DECLARE(0x5678), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x3333), + .uuid = BLE_UUID16_DECLARE(0x3333), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .val_handle = val_handles + 2, @@ -593,14 +593,14 @@ TEST_CASE(ble_gatts_reg_test_dsc_cb) /*** 1 descriptor. */ ble_gatts_reg_test_misc_svcs((struct ble_gatt_svc_def[]) { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x1111), + .uuid = BLE_UUID16_DECLARE(0x1111), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .val_handle = val_handles + 0, .descriptors = (struct ble_gatt_dsc_def[]) { { - .uuid128 = BLE_UUID16(0x111a), + .uuid = BLE_UUID16_DECLARE(0x111a), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { @@ -616,21 +616,21 @@ TEST_CASE(ble_gatts_reg_test_dsc_cb) /*** 5+ descriptors. */ ble_gatts_reg_test_misc_svcs((struct ble_gatt_svc_def[]) { { .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid128 = BLE_UUID16(0x1234), + .uuid = BLE_UUID16_DECLARE(0x1234), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x1111), + .uuid = BLE_UUID16_DECLARE(0x1111), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .val_handle = val_handles + 0, .descriptors = (struct ble_gatt_dsc_def[]) { { - .uuid128 = BLE_UUID16(0x111a), + .uuid = BLE_UUID16_DECLARE(0x111a), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { 0 } }, }, { - .uuid128 = BLE_UUID16(0x2222), + .uuid = BLE_UUID16_DECLARE(0x2222), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_WRITE, .val_handle = val_handles + 1, @@ -639,50 +639,50 @@ TEST_CASE(ble_gatts_reg_test_dsc_cb) } }, }, { .type = BLE_GATT_SVC_TYPE_SECONDARY, - .uuid128 = BLE_UUID16(0x5678), + .uuid = BLE_UUID16_DECLARE(0x5678), .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid128 = BLE_UUID16(0x3333), + .uuid = BLE_UUID16_DECLARE(0x3333), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .val_handle = val_handles + 2, .descriptors = (struct ble_gatt_dsc_def[]) { { - .uuid128 = BLE_UUID16(0x333a), + .uuid = BLE_UUID16_DECLARE(0x333a), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { - .uuid128 = BLE_UUID16(0x333b), + .uuid = BLE_UUID16_DECLARE(0x333b), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { - .uuid128 = BLE_UUID16(0x333c), + .uuid = BLE_UUID16_DECLARE(0x333c), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { - .uuid128 = BLE_UUID16(0x333e), + .uuid = BLE_UUID16_DECLARE(0x333e), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { 0 } }, }, { - .uuid128 = BLE_UUID16(0x4444), + .uuid = BLE_UUID16_DECLARE(0x4444), .access_cb = ble_gatts_reg_test_misc_dummy_access, .flags = BLE_GATT_CHR_F_READ, .val_handle = val_handles + 3, .descriptors = (struct ble_gatt_dsc_def[]) { { - .uuid128 = BLE_UUID16(0x444a), + .uuid = BLE_UUID16_DECLARE(0x444a), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { - .uuid128 = BLE_UUID16(0x444b), + .uuid = BLE_UUID16_DECLARE(0x444b), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { - .uuid128 = BLE_UUID16(0x444c), + .uuid = BLE_UUID16_DECLARE(0x444c), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { - .uuid128 = BLE_UUID16(0x444e), + .uuid = BLE_UUID16_DECLARE(0x444e), .att_flags = 5, .access_cb = ble_gatts_reg_test_misc_dummy_access, }, { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_hs_test_util.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_hs_test_util.c b/net/nimble/host/test/src/ble_hs_test_util.c index 1470fc6..a4a57f8 100644 --- a/net/nimble/host/test/src/ble_hs_test_util.c +++ b/net/nimble/host/test/src/ble_hs_test_util.c @@ -991,11 +991,10 @@ int ble_hs_test_util_rx_att_read_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, - const void *uuid128) + const ble_uuid_t *uuid) { struct ble_att_read_type_req req; uint8_t buf[BLE_ATT_READ_TYPE_REQ_SZ_128]; - uint16_t uuid16; int req_len; int rc; @@ -1004,14 +1003,8 @@ ble_hs_test_util_rx_att_read_type_req(uint16_t conn_handle, ble_att_read_type_req_write(buf, sizeof buf, &req); - uuid16 = ble_uuid_128_to_16(uuid128); - if (uuid16 != 0) { - htole16(buf + BLE_ATT_READ_TYPE_REQ_BASE_SZ, uuid16); - req_len = BLE_ATT_READ_TYPE_REQ_BASE_SZ + 2; - } else { - memcpy(buf + BLE_ATT_READ_TYPE_REQ_BASE_SZ, uuid128, 16); - req_len = BLE_ATT_READ_TYPE_REQ_BASE_SZ + 16; - } + ble_uuid_flat(uuid, buf + BLE_ATT_READ_TYPE_REQ_BASE_SZ); + req_len = BLE_ATT_READ_TYPE_REQ_BASE_SZ + ble_uuid_length(uuid); rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, req_len); @@ -1024,14 +1017,11 @@ ble_hs_test_util_rx_att_read_type_req16(uint16_t conn_handle, uint16_t end_handle, uint16_t uuid16) { - uint8_t uuid128[16]; int rc; - rc = ble_uuid_16_to_128(uuid16, uuid128); - TEST_ASSERT_FATAL(rc == 0); - rc = ble_hs_test_util_rx_att_read_type_req(conn_handle, start_handle, - end_handle, uuid128); + end_handle, + BLE_UUID16_DECLARE(uuid16)); return rc; } @@ -1095,25 +1085,18 @@ int ble_hs_test_util_rx_att_read_group_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, - const void *uuid128) + const ble_uuid_t *uuid) { struct ble_att_read_group_type_req req; uint8_t buf[BLE_ATT_READ_GROUP_TYPE_REQ_SZ_128]; - uint16_t uuid16; int req_len; int rc; req.bagq_start_handle = start_handle; req.bagq_end_handle = end_handle; - uuid16 = ble_uuid_128_to_16(uuid128); - if (uuid16 != 0) { - htole16(buf + BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ, uuid16); - req_len = BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ + 2; - } else { - memcpy(buf + BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ, uuid128, 16); - req_len = BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ + 16; - } + ble_uuid_flat(uuid, buf + BLE_ATT_READ_TYPE_REQ_BASE_SZ); + req_len = BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ + ble_uuid_length(uuid); ble_att_read_group_type_req_write(buf, sizeof buf, &req); rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, @@ -1127,14 +1110,11 @@ ble_hs_test_util_rx_att_read_group_type_req16(uint16_t conn_handle, uint16_t end_handle, uint16_t uuid16) { - uint8_t uuid128[16]; int rc; - rc = ble_uuid_16_to_128(uuid16, uuid128); - TEST_ASSERT_FATAL(rc == 0); - rc = ble_hs_test_util_rx_att_read_group_type_req(conn_handle, start_handle, - end_handle, uuid128); + end_handle, + BLE_UUID16_DECLARE(uuid16)); return rc; } @@ -1538,9 +1518,8 @@ ble_hs_test_util_verify_tx_find_info_rsp( struct ble_att_find_info_rsp rsp; struct os_mbuf *om; uint16_t handle; - uint16_t uuid16; uint8_t buf[BLE_ATT_FIND_INFO_RSP_BASE_SZ]; - uint8_t uuid128[16]; + ble_uuid_any_t uuid; int off; int rc; @@ -1564,24 +1543,23 @@ ble_hs_test_util_verify_tx_find_info_rsp( handle = le16toh((void *)&handle); TEST_ASSERT(handle == entry->handle); - if (entry->uuid16 != 0) { + if (entry->uuid->type == BLE_UUID_TYPE_16) { TEST_ASSERT(rsp.bafp_format == BLE_ATT_FIND_INFO_RSP_FORMAT_16BIT); - rc = os_mbuf_copydata(om, off, 2, &uuid16); + + ble_uuid_init_from_mbuf(&uuid, om, off, 2); TEST_ASSERT(rc == 0); off += 2; - - uuid16 = le16toh((void *)&uuid16); - TEST_ASSERT(uuid16 == entry->uuid16); } else { TEST_ASSERT(rsp.bafp_format == BLE_ATT_FIND_INFO_RSP_FORMAT_128BIT); - rc = os_mbuf_copydata(om, off, 16, uuid128); + + rc = ble_uuid_init_from_mbuf(&uuid, om, off, 16); TEST_ASSERT(rc == 0); off += 16; - - TEST_ASSERT(memcmp(uuid128, entry->uuid128, 16) == 0); } + + TEST_ASSERT(ble_uuid_cmp(entry->uuid, &uuid.u) == 0); } /* Ensure there is no extra data in the response. */ @@ -1596,7 +1574,7 @@ ble_hs_test_util_verify_tx_read_group_type_rsp( struct ble_att_read_group_type_rsp rsp; struct os_mbuf *om; uint16_t u16; - uint8_t uuid128[16]; + ble_uuid_any_t uuid; int off; int rc; @@ -1608,7 +1586,7 @@ ble_hs_test_util_verify_tx_read_group_type_rsp( off = BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ; for (entry = entries; entry->start_handle != 0; entry++) { - if (entry->uuid16 != 0) { + if (entry->uuid->type == BLE_UUID_TYPE_16) { TEST_ASSERT(rsp.bagp_length == BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_16); } else { @@ -1628,18 +1606,16 @@ ble_hs_test_util_verify_tx_read_group_type_rsp( TEST_ASSERT(u16 == entry->end_handle); off += 2; - if (entry->uuid16 != 0) { - rc = os_mbuf_copydata(om, off, 2, &u16); + if (entry->uuid->type == BLE_UUID_TYPE_16) { + rc = ble_uuid_init_from_mbuf(&uuid, om, off, 2); TEST_ASSERT(rc == 0); - htole16(&u16, u16); - TEST_ASSERT(u16 == entry->uuid16); - off += 2; } else { - rc = os_mbuf_copydata(om, off, 16, uuid128); + rc = ble_uuid_init_from_mbuf(&uuid, om, off, 16); TEST_ASSERT(rc == 0); - TEST_ASSERT(memcmp(uuid128, entry->uuid128, 16) == 0); - off += 16; } + + TEST_ASSERT(ble_uuid_cmp(&uuid.u, entry->uuid) == 0); + off += ble_uuid_length(&uuid.u); } /* Ensure there is no extra data in the response. */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b1c14f3f/net/nimble/host/test/src/ble_hs_test_util.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/test/src/ble_hs_test_util.h b/net/nimble/host/test/src/ble_hs_test_util.h index 75865e2..8f3d94e 100644 --- a/net/nimble/host/test/src/ble_hs_test_util.h +++ b/net/nimble/host/test/src/ble_hs_test_util.h @@ -55,15 +55,13 @@ struct ble_hs_test_util_mbuf_params { struct ble_hs_test_util_att_info_entry { uint16_t handle; /* 0 on last entry */ - uint16_t uuid16; /* 0 if not present. */ - uint8_t uuid128[16]; + const ble_uuid_t *uuid; }; struct ble_hs_test_util_att_group_type_entry { uint16_t start_handle; /* 0 on last entry */ uint16_t end_handle; /* 0 on last entry */ - uint16_t uuid16; /* 0 if not present. */ - uint8_t uuid128[16]; + const ble_uuid_t *uuid; }; #define BLE_HS_TEST_UTIL_L2CAP_HCI_HDR(handle, pb, len) \ @@ -167,7 +165,7 @@ int ble_hs_test_util_rx_att_find_type_value_req(uint16_t conn_handle, int ble_hs_test_util_rx_att_read_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, - const void *uuid128); + const ble_uuid_t *uuid); int ble_hs_test_util_rx_att_read_type_req16(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, @@ -183,7 +181,7 @@ int ble_hs_test_util_rx_att_read_mult_req(uint16_t conn_handle, int ble_hs_test_util_rx_att_read_group_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, - const void *uuid128); + const ble_uuid_t *uuid); int ble_hs_test_util_rx_att_read_group_type_req16(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle,
