Bluetooth: shell: Add support to retrieve A2SRC record

Adds to BT shell app functionality to trigger to be found on remote
A2SRC UUID. Implements user callback to read resolved response data
and uses existing SDP client API to read attributes values.

> HCI Event: Number of Completed Packets (0x13) plen 5
        Num handles: 1
        Handle: 77
        Count: 1
> ACL Data RX: Handle 77 flags 0x02 dlen 48
      Channel: 64 len 44 [PSM 1 mode 0] {chan 0}
      SDP: Service Search Attribute Response (0x07) tid 2 len 39
        Attribute bytes: 36
        Continuation state: 0
        Combined attribute bytes: 89
          Attribute list: [len 84] {position 0}
            Attribute: Service Record Handle (0x0000) [len 2]
              0x00010005
            Attribute: Service Class ID List (0x0001) [len 2]
              UUID (3) with 2 bytes [0 extra bits] len 3
                Audio Source (0x110a)
            Attribute: Protocol Descriptor List (0x0004) [len 2]
              Sequence (6) with 6 bytes [8 extra bits] len 8
                UUID (3) with 2 bytes [0 extra bits] len 3
                  L2CAP (0x0100)
                Unsigned Integer (1) with 2 bytes [0 extra bits] len 3
                  0x0019
              Sequence (6) with 6 bytes [8 extra bits] len 8
                UUID (3) with 2 bytes [0 extra bits] len 3
                  AVDTP (0x0019)
                Unsigned Integer (1) with 2 bytes [0 extra bits] len 3
                  0x0102
            Attribute: Browse Group List (0x0005) [len 2]
              UUID (3) with 2 bytes [0 extra bits] len 3
                Public Browse Root (0x1002)
            Attribute: Bluetooth Profile Descriptor List (0x0009) [len 2]
              Sequence (6) with 6 bytes [8 extra bits] len 8
                UUID (3) with 2 bytes [0 extra bits] len 3
                  Advanced Audio Distribution (0x110d)
                Unsigned Integer (1) with 2 bytes [0 extra bits] len 3
                  0x0102
            Attribute: Unknown (0x0100) [len 2]
              Advanced Audio [len 15]
            Attribute: Unknown (0x0311) [len 2]
              0x0001
< ACL Data TX: Handle 77 flags 0x00 dlen 12
      L2CAP: Disconnection Request (0x06) ident 10 len 4
        Destination CID: 65

Change-Id: I8938d9eebda31f3d252ff49adc1a96abfcbc5751
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
Arkadiusz Lichwa 2017-01-06 13:12:51 +01:00 committed by Johan Hedberg
commit 9fff70dbe5

View file

@ -268,12 +268,75 @@ done:
return BT_SDP_DISCOVER_UUID_CONTINUE;
}
static uint8_t sdp_a2src_user(struct bt_conn *conn,
struct bt_sdp_client_result *result)
{
char addr[BT_ADDR_STR_LEN];
uint16_t param, version;
uint16_t features;
int res;
conn_addr_str(conn, addr, sizeof(addr));
if (result) {
printk("SDP A2SRC data@%p (len %u) hint %u from remote %s\n",
result->resp_buf, result->resp_buf->len,
result->next_record_hint, addr);
/*
* Focus to get BT_SDP_ATTR_PROTO_DESC_LIST attribute item to
* get A2SRC Server PSM Number.
*/
res = bt_sdp_get_proto_param(result->resp_buf,
BT_SDP_PROTO_L2CAP, &param);
if (res < 0) {
printk("A2SRC PSM Number not found, err %d\n", res);
goto done;
}
printk("A2SRC Server PSM Number param 0x%04x\n", param);
/*
* Focus to get BT_SDP_ATTR_PROFILE_DESC_LIST attribute item to
* get profile version number.
*/
res = bt_sdp_get_profile_version(result->resp_buf,
BT_SDP_ADVANCED_AUDIO_SVCLASS,
&version);
if (res < 0) {
printk("A2SRC version not found, err %d\n", res);
goto done;
}
printk("A2SRC version param 0x%04x\n", version);
/*
* Focus to get BT_SDP_ATTR_SUPPORTED_FEATURES attribute item to
* get profile supported features mask.
*/
res = bt_sdp_get_features(result->resp_buf, &features);
if (res < 0) {
printk("A2SRC Features not found, err %d\n", res);
goto done;
}
printk("A2SRC Supported Features param 0x%04x\n", features);
} else {
printk("No SDP A2SRC data from remote %s\n", addr);
}
done:
return BT_SDP_DISCOVER_UUID_CONTINUE;
}
static struct bt_sdp_discover_params discov_hfpag = {
.uuid = BT_UUID_DECLARE_16(BT_SDP_HANDSFREE_AGW_SVCLASS),
.func = sdp_hfp_ag_user,
.pool = &sdp_client_pool,
};
static struct bt_sdp_discover_params discov_a2src = {
.uuid = BT_UUID_DECLARE_16(BT_SDP_AUDIO_SOURCE_SVCLASS),
.func = sdp_a2src_user,
.pool = &sdp_client_pool,
};
static struct bt_sdp_discover_params discov;
#endif
@ -2306,13 +2369,15 @@ static int cmd_bredr_sdp_find_record(int argc, char *argv[])
if (!strcmp(action, "HFPAG")) {
discov = discov_hfpag;
} else if (!strcmp(action, "A2SRC")) {
discov = discov_a2src;
} else {
err = -EINVAL;
}
if (err) {
printk("SDP UUID to resolve invalid (err %d)\n", err);
printk("Supported UUID is \'HFPAG\' only\n");
printk("SDP UUID to resolve not valid (err %d)\n", err);
printk("Supported UUID are \'HFPAG\' \'A2SRC\' only\n");
return err;
}