From 68de9d5d66f37ece9982df18d6eda2bf6c00d85e Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 7 Jun 2018 14:17:32 +0300 Subject: [PATCH] Bluetooth: Use Characteristic attribute whenever possible With updates to bt_gatt_notify and bt_gatt_indicate it is now possible to pass the Characteristic attribute instead of its value which makes the code able to verify if attribute properties are set correctly. Signed-off-by: Luiz Augusto von Dentz --- samples/bluetooth/gatt/bas.c | 2 +- samples/bluetooth/gatt/cts.c | 2 +- samples/bluetooth/gatt/hrs.c | 2 +- samples/bluetooth/peripheral_csc/src/main.c | 4 ++-- samples/boards/microbit/pong/src/ble.c | 2 +- subsys/bluetooth/host/mesh/proxy.c | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/samples/bluetooth/gatt/bas.c b/samples/bluetooth/gatt/bas.c index e127de9f159..87e3e2fa9c8 100644 --- a/samples/bluetooth/gatt/bas.c +++ b/samples/bluetooth/gatt/bas.c @@ -69,5 +69,5 @@ void bas_notify(void) battery = 100; } - bt_gatt_notify(NULL, &attrs[2], &battery, sizeof(battery)); + bt_gatt_notify(NULL, &attrs[1], &battery, sizeof(battery)); } diff --git a/samples/bluetooth/gatt/cts.c b/samples/bluetooth/gatt/cts.c index eb16cb33e62..763c22c0592 100644 --- a/samples/bluetooth/gatt/cts.c +++ b/samples/bluetooth/gatt/cts.c @@ -110,5 +110,5 @@ void cts_notify(void) } ct_update = 0; - bt_gatt_notify(NULL, &attrs[3], &ct, sizeof(ct)); + bt_gatt_notify(NULL, &attrs[1], &ct, sizeof(ct)); } diff --git a/samples/bluetooth/gatt/hrs.c b/samples/bluetooth/gatt/hrs.c index bff8fe18c8d..0efe70f3929 100644 --- a/samples/bluetooth/gatt/hrs.c +++ b/samples/bluetooth/gatt/hrs.c @@ -78,5 +78,5 @@ void hrs_notify(void) hrm[0] = 0x06; /* uint8, sensor contact */ hrm[1] = heartrate; - bt_gatt_notify(NULL, &attrs[2], &hrm, sizeof(hrm)); + bt_gatt_notify(NULL, &attrs[1], &hrm, sizeof(hrm)); } diff --git a/samples/bluetooth/peripheral_csc/src/main.c b/samples/bluetooth/peripheral_csc/src/main.c index c27f7443c24..a0cad975053 100644 --- a/samples/bluetooth/peripheral_csc/src/main.c +++ b/samples/bluetooth/peripheral_csc/src/main.c @@ -246,7 +246,7 @@ static void ctrl_point_ind(struct bt_conn *conn, u8_t req_op, u8_t status, memcpy(ind->data, data, data_len); } - bt_gatt_notify(conn, &csc_attrs[9], buf, sizeof(buf)); + bt_gatt_notify(conn, &csc_attrs[8], buf, sizeof(buf)); } struct csc_measurement_nfy { @@ -299,7 +299,7 @@ static void measurement_nfy(struct bt_conn *conn, u32_t cwr, u16_t lwet, memcpy(nfy->data + len, &data, sizeof(data)); } - bt_gatt_notify(NULL, &csc_attrs[2], buf, sizeof(buf)); + bt_gatt_notify(NULL, &csc_attrs[1], buf, sizeof(buf)); } static u16_t lwet; /* Last Wheel Event Time */ diff --git a/samples/boards/microbit/pong/src/ble.c b/samples/boards/microbit/pong/src/ble.c index 9d8295b26ee..dddc11f6c27 100644 --- a/samples/boards/microbit/pong/src/ble.c +++ b/samples/boards/microbit/pong/src/ble.c @@ -541,6 +541,6 @@ void ble_init(void) bt_conn_cb_register(&conn_callbacks); - local_attr = &pong_attrs[2]; + local_attr = &pong_attrs[1]; bt_gatt_service_register(&pong_svc); } diff --git a/subsys/bluetooth/host/mesh/proxy.c b/subsys/bluetooth/host/mesh/proxy.c index 5f2e02c1fa7..5fa777c94a1 100644 --- a/subsys/bluetooth/host/mesh/proxy.c +++ b/subsys/bluetooth/host/mesh/proxy.c @@ -885,13 +885,13 @@ static int proxy_send(struct bt_conn *conn, const void *data, u16_t len) #if defined(CONFIG_BT_MESH_GATT_PROXY) if (gatt_svc == MESH_GATT_PROXY) { - return bt_gatt_notify(conn, &proxy_attrs[4], data, len); + return bt_gatt_notify(conn, &proxy_attrs[3], data, len); } #endif #if defined(CONFIG_BT_MESH_PB_GATT) if (gatt_svc == MESH_GATT_PROV) { - return bt_gatt_notify(conn, &prov_attrs[4], data, len); + return bt_gatt_notify(conn, &prov_attrs[3], data, len); } #endif