samples: Bluetooth: use indication destroy cb

Update the `peripheral` and `peripheral_ht` samples to use the
indication `destroy` callback to determine when the indication has
completed, instead of using the value callback of the first active
connection.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2020-11-07 16:48:38 +10:00 committed by Carles Cufí
parent ffab099eb9
commit daa783ae1a
2 changed files with 12 additions and 2 deletions

View file

@ -78,6 +78,11 @@ static void indicate_cb(struct bt_conn *conn,
struct bt_gatt_indicate_params *params, uint8_t err)
{
printk("Indication %s\n", err != 0U ? "fail" : "success");
}
static void indicate_destroy(struct bt_gatt_indicate_params *params)
{
printk("Indication complete\n");
indicating = 0U;
}
@ -356,7 +361,7 @@ void main(void)
ind_params.attr = &vnd_svc.attrs[2];
ind_params.func = indicate_cb;
ind_params.destroy = NULL;
ind_params.destroy = indicate_destroy;
ind_params.data = &indicating;
ind_params.len = sizeof(indicating);

View file

@ -41,6 +41,11 @@ static void indicate_cb(struct bt_conn *conn,
struct bt_gatt_indicate_params *params, uint8_t err)
{
printk("Indication %s\n", err != 0U ? "fail" : "success");
}
static void indicate_destroy(struct bt_gatt_indicate_params *params)
{
printk("Indication complete\n");
indicating = 0U;
}
@ -117,7 +122,7 @@ gatt_indicate:
ind_params.attr = &hts_svc.attrs[2];
ind_params.func = indicate_cb;
ind_params.destroy = NULL;
ind_params.destroy = indicate_destroy;
ind_params.data = &htm;
ind_params.len = sizeof(htm);