From 5880f3d74fa71d8fc177eccdf98b64541df8a455 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Tue, 18 Aug 2020 16:21:53 +0200 Subject: [PATCH] Bluetooth: UUID: Use BT_UUID_16_ENCODE to set UUIDs in adv data Use BT_UUID_16_ENCODE to set UUIDs in advertising data. Signed-off-by: Joakim Andersson --- samples/bluetooth/hci_pwr_ctrl/src/main.c | 2 +- samples/bluetooth/peripheral/src/main.c | 4 +++- samples/bluetooth/peripheral_csc/src/main.c | 4 +++- samples/bluetooth/peripheral_dis/src/main.c | 2 +- samples/bluetooth/peripheral_esp/src/main.c | 5 +++-- samples/bluetooth/peripheral_hids/src/main.c | 4 ++-- samples/bluetooth/peripheral_hr/src/main.c | 5 ++++- samples/bluetooth/peripheral_ht/src/main.c | 6 +++--- subsys/bluetooth/mesh/proxy.c | 17 ++++++++++++----- subsys/net/l2/bluetooth/bluetooth.c | 2 +- .../bsim_bt/bsim_test_app/src/test_connect2.c | 5 ++++- .../edtt_ble_test_app/gatt_test_app/src/main.c | 4 +++- tests/bluetooth/shell/src/main.c | 6 +++++- 13 files changed, 45 insertions(+), 21 deletions(-) diff --git a/samples/bluetooth/hci_pwr_ctrl/src/main.c b/samples/bluetooth/hci_pwr_ctrl/src/main.c index ab0afef08b7..8bfdc61fb4e 100644 --- a/samples/bluetooth/hci_pwr_ctrl/src/main.c +++ b/samples/bluetooth/hci_pwr_ctrl/src/main.c @@ -26,7 +26,7 @@ static uint16_t default_conn_handle; static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x0d, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(BT_UUID_HRS_VAL)), }; #define DEVICE_NAME CONFIG_BT_DEVICE_NAME diff --git a/samples/bluetooth/peripheral/src/main.c b/samples/bluetooth/peripheral/src/main.c index 7c18fbead1b..bf27d7ad1c0 100644 --- a/samples/bluetooth/peripheral/src/main.c +++ b/samples/bluetooth/peripheral/src/main.c @@ -220,7 +220,9 @@ BT_GATT_SERVICE_DEFINE(vnd_svc, static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_ALL, - 0x0d, 0x18, 0x0f, 0x18, 0x05, 0x18), + BT_UUID_16_ENCODE(BT_UUID_HRS_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL), + BT_UUID_16_ENCODE(BT_UUID_CTS_VAL)), BT_DATA_BYTES(BT_DATA_UUID128_ALL, 0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12), diff --git a/samples/bluetooth/peripheral_csc/src/main.c b/samples/bluetooth/peripheral_csc/src/main.c index 908dacdd9be..95affdf2a75 100644 --- a/samples/bluetooth/peripheral_csc/src/main.c +++ b/samples/bluetooth/peripheral_csc/src/main.c @@ -363,7 +363,9 @@ static struct bt_conn_cb conn_callbacks = { static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x16, 0x18, 0x0f, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_UUID_16_ENCODE(BT_UUID_CSC_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL)) }; static void bt_ready(void) diff --git a/samples/bluetooth/peripheral_dis/src/main.c b/samples/bluetooth/peripheral_dis/src/main.c index 7bee14ace65..c043afa354a 100644 --- a/samples/bluetooth/peripheral_dis/src/main.c +++ b/samples/bluetooth/peripheral_dis/src/main.c @@ -23,7 +23,7 @@ static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x0a, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(BT_UUID_DIS_VAL)), }; static void connected(struct bt_conn *conn, uint8_t err) diff --git a/samples/bluetooth/peripheral_esp/src/main.c b/samples/bluetooth/peripheral_esp/src/main.c index aeb2c864945..1345d41ac67 100644 --- a/samples/bluetooth/peripheral_esp/src/main.c +++ b/samples/bluetooth/peripheral_esp/src/main.c @@ -341,8 +341,9 @@ static void ess_simulate(void) static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, 0x00, 0x03), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x1a, 0x18), - /* TODO: Include Service Data AD */ + BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_UUID_16_ENCODE(BT_UUID_ESS_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL)), }; static void connected(struct bt_conn *conn, uint8_t err) diff --git a/samples/bluetooth/peripheral_hids/src/main.c b/samples/bluetooth/peripheral_hids/src/main.c index a2a40097d3b..eb28f88b3cf 100644 --- a/samples/bluetooth/peripheral_hids/src/main.c +++ b/samples/bluetooth/peripheral_hids/src/main.c @@ -27,8 +27,8 @@ static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_ALL, - 0x12, 0x18, /* HID Service */ - 0x0f, 0x18), /* Battery Service */ + BT_UUID_16_ENCODE(BT_UUID_HIDS_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL)), }; static void connected(struct bt_conn *conn, uint8_t err) diff --git a/samples/bluetooth/peripheral_hr/src/main.c b/samples/bluetooth/peripheral_hr/src/main.c index 44fc6ef77bb..42ec6071338 100644 --- a/samples/bluetooth/peripheral_hr/src/main.c +++ b/samples/bluetooth/peripheral_hr/src/main.c @@ -26,7 +26,10 @@ struct bt_conn *default_conn; static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x0d, 0x18, 0x0f, 0x18, 0x0a, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_UUID_16_ENCODE(BT_UUID_HRS_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL), + BT_UUID_16_ENCODE(BT_UUID_DIS_VAL)) }; static void connected(struct bt_conn *conn, uint8_t err) diff --git a/samples/bluetooth/peripheral_ht/src/main.c b/samples/bluetooth/peripheral_ht/src/main.c index 2d0dd41fb33..4af12342219 100644 --- a/samples/bluetooth/peripheral_ht/src/main.c +++ b/samples/bluetooth/peripheral_ht/src/main.c @@ -28,9 +28,9 @@ struct bt_conn *default_conn; static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_ALL, - 0x09, 0x18, /* Health Thermometer Service */ - 0x0a, 0x18, /* Device Information Service */ - 0x0f, 0x18), /* Battery Service */ + BT_UUID_16_ENCODE(BT_UUID_HTS_VAL), + BT_UUID_16_ENCODE(BT_UUID_DIS_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL)), }; static void connected(struct bt_conn *conn, uint8_t err) diff --git a/subsys/bluetooth/mesh/proxy.c b/subsys/bluetooth/mesh/proxy.c index c1385b75ee9..bd2af892d72 100644 --- a/subsys/bluetooth/mesh/proxy.c +++ b/subsys/bluetooth/mesh/proxy.c @@ -1026,11 +1026,14 @@ int bt_mesh_proxy_send(struct bt_conn *conn, uint8_t type, } #if defined(CONFIG_BT_MESH_PB_GATT) -static uint8_t prov_svc_data[20] = { 0x27, 0x18, }; +static uint8_t prov_svc_data[20] = { + BT_UUID_16_ENCODE(BT_UUID_MESH_PROV_VAL), +}; static const struct bt_data prov_ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x27, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_UUID_16_ENCODE(BT_UUID_MESH_PROV_VAL)), BT_DATA(BT_DATA_SVC_DATA16, prov_svc_data, sizeof(prov_svc_data)), }; #endif /* PB_GATT */ @@ -1045,17 +1048,21 @@ static const struct bt_data prov_ad[] = { #define NODE_ID_TIMEOUT (CONFIG_BT_MESH_NODE_ID_TIMEOUT * MSEC_PER_SEC) -static uint8_t proxy_svc_data[NODE_ID_LEN] = { 0x28, 0x18, }; +static uint8_t proxy_svc_data[NODE_ID_LEN] = { + BT_UUID_16_ENCODE(BT_UUID_MESH_PROXY_VAL), +}; static const struct bt_data node_id_ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x28, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_UUID_16_ENCODE(BT_UUID_MESH_PROXY_VAL)), BT_DATA(BT_DATA_SVC_DATA16, proxy_svc_data, NODE_ID_LEN), }; static const struct bt_data net_id_ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x28, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_UUID_16_ENCODE(BT_UUID_MESH_PROXY_VAL)), BT_DATA(BT_DATA_SVC_DATA16, proxy_svc_data, NET_ID_LEN), }; diff --git a/subsys/net/l2/bluetooth/bluetooth.c b/subsys/net/l2/bluetooth/bluetooth.c index 46678a7b4aa..78fedad12e8 100644 --- a/subsys/net/l2/bluetooth/bluetooth.c +++ b/subsys/net/l2/bluetooth/bluetooth.c @@ -348,7 +348,7 @@ static struct bt_l2cap_server server = { static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x20, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(BT_UUID_IPSS_VAL)), }; static const struct bt_data sd[] = { diff --git a/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect2.c b/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect2.c index bc9efb03d36..d8b0d6f6a28 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect2.c +++ b/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect2.c @@ -71,7 +71,10 @@ static void test_con2_tick(bs_time_t HW_device_time) static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x0d, 0x18, 0x0f, 0x18, 0x05, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_UUID_16_ENCODE(BT_UUID_HRS_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL), + BT_UUID_16_ENCODE(BT_UUID_CTS_VAL)), }; static void connected(struct bt_conn *conn, uint8_t err) diff --git a/tests/bluetooth/bsim_bt/edtt_ble_test_app/gatt_test_app/src/main.c b/tests/bluetooth/bsim_bt/edtt_ble_test_app/gatt_test_app/src/main.c index 0bdb939e08e..8bdf9ce9e97 100644 --- a/tests/bluetooth/bsim_bt/edtt_ble_test_app/gatt_test_app/src/main.c +++ b/tests/bluetooth/bsim_bt/edtt_ble_test_app/gatt_test_app/src/main.c @@ -32,7 +32,9 @@ static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_ALL, - 0x0d, 0x18, 0x0f, 0x18, 0x05, 0x18), + BT_UUID_16_ENCODE(BT_UUID_HRS_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL), + BT_UUID_16_ENCODE(BT_UUID_CTS_VAL)), BT_DATA_BYTES(BT_DATA_UUID128_ALL, 0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12), diff --git a/tests/bluetooth/shell/src/main.c b/tests/bluetooth/shell/src/main.c index 38d3b49456b..79afda0234a 100644 --- a/tests/bluetooth/shell/src/main.c +++ b/tests/bluetooth/shell/src/main.c @@ -25,6 +25,7 @@ #include #include +#include #include #define DEVICE_NAME CONFIG_BT_DEVICE_NAME @@ -34,7 +35,10 @@ static bool hrs_simulate; static const struct bt_data ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), - BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x0d, 0x18, 0x0f, 0x18, 0x0a, 0x18), + BT_DATA_BYTES(BT_DATA_UUID16_ALL, + BT_UUID_16_ENCODE(BT_UUID_HRS_VAL), + BT_UUID_16_ENCODE(BT_UUID_BAS_VAL), + BT_UUID_16_ENCODE(BT_UUID_DIS_VAL)), }; static int cmd_hrs_simulate(const struct shell *shell,