Skip to content
Permalink
Browse files

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 <luiz.von.dentz@intel.com>
  • Loading branch information...
Vudentz authored and nashif committed Jun 7, 2018
1 parent 679a0b3 commit 68de9d5d66f37ece9982df18d6eda2bf6c00d85e
@@ -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));
}
@@ -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));
}
@@ -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));
}
@@ -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 */
@@ -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);
}
@@ -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

0 comments on commit 68de9d5

Please sign in to comment.
You can’t perform that action at this time.