Skip to content

Commit

Permalink
Bluetooth: tester: Add support for indications in tester application
Browse files Browse the repository at this point in the history
This adds support for indications in tester application.

1/3   GATT   TC_GAN_SR_BV_01_C   PASS
2/3   GATT   TC_GAI_SR_BV_01_C   PASS
3/3   GATT   TC_GAT_SR_BV_01_C   PASS

Closes ZEP-403.

Change-Id: I3da8746641429388d38c2593344105f33fb43ee8
Signed-off-by: Mariusz Skamra <[email protected]>
  • Loading branch information
Mariusz Skamra authored and Johan Hedberg committed May 25, 2016
1 parent 076df0c commit edc4f30
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/bluetooth/tester/src/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,11 @@ static void add_characteristic(uint8_t *data, uint16_t len)
static bool ccc_added;

static struct bt_gatt_ccc_cfg ccc_cfg[CONFIG_BLUETOOTH_MAX_PAIRED] = {};
static uint8_t ccc_value;

static void ccc_cfg_changed(uint16_t value)
{
/* NOP */
ccc_value = value;
}

static struct bt_gatt_attr ccc = BT_GATT_CCC(ccc_cfg, ccc_cfg_changed);
Expand Down Expand Up @@ -729,6 +730,14 @@ struct set_value {
uint16_t len;
};

struct bt_gatt_indicate_params indicate_params;

static void indicate_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr,
uint8_t err)
{
BTTESTER_DBG("Indication %s\n", err != 0 ? "fail" : "success");
}

static uint8_t alloc_value(struct bt_gatt_attr *attr, struct set_value *data)
{
struct gatt_value *value;
Expand Down Expand Up @@ -759,8 +768,17 @@ static uint8_t alloc_value(struct bt_gatt_attr *attr, struct set_value *data)

memcpy(value->data, data->value, value->len);

if (tester_test_bit(value->flags, GATT_VALUE_CCC_FLAG)) {
bt_gatt_notify(NULL, attr, value->data, value->len);
if (tester_test_bit(value->flags, GATT_VALUE_CCC_FLAG) && ccc_value) {
if (ccc_value == BT_GATT_CCC_NOTIFY) {
bt_gatt_notify(NULL, attr, value->data, value->len);
} else {
indicate_params.attr = attr;
indicate_params.data = value->data;
indicate_params.len = value->len;
indicate_params.func = indicate_cb;

bt_gatt_indicate(NULL, &indicate_params);
}
}

return BTP_STATUS_SUCCESS;
Expand Down

0 comments on commit edc4f30

Please sign in to comment.