Bluetooth: Add gatt-discover-characteristic command to btshell
This adds gatt-discover-characteristic which works as follow: btshell>gatt-discover-characteristic <bdaddr> <bdaddr_type> [UUID] [start_handle] [end_handle] bt: bt_gatt_discover_characteristic (0x0010d098): start_handle 0x000b end_handle 0x0011 Discover pending btshell>bt: bt_att_recv (0x0010f294): Received ATT code 0x09 len 23 bt: att_handle_read_type_rsp (0x0010f294): bt: att_read_type_rsp (0x0010f294): err 0x00 bt: att_read_type_rsp (0x0010f294): handle 0x000b properties 0x02 value_handle 0x000c Discover found handle 11 bt: att_read_type_rsp (0x0010f294): handle 0x000d properties 0x10 value_handle 0x000e Discover found handle 13 bt: att_read_type_rsp (0x0010f294): handle 0x0010 properties 0x08 value_handle 0x0011 Discover found handle 16 Discover destroy Change-Id: I04aad56cc4f978e3a884adffc487ae4dcc1c4ee9 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
d87232b2a1
commit
710aa2ecc7
@ -427,18 +427,26 @@ static void cmd_gatt_discover(int argc, char *argv[])
|
||||
return;
|
||||
}
|
||||
|
||||
if (argc < 4) {
|
||||
printk("UUID type required\n");
|
||||
return;
|
||||
}
|
||||
|
||||
uuid.u16 = xtoi(argv[3]);
|
||||
discover_params.uuid = &uuid;
|
||||
discover_params.func = discover_func;
|
||||
discover_params.destroy = discover_destroy;
|
||||
discover_params.start_handle = 0x0001;
|
||||
discover_params.end_handle = 0xffff;
|
||||
|
||||
if (argc < 4) {
|
||||
if (!strcmp(argv[0], "gatt-discover")) {
|
||||
printk("UUID type required\n");
|
||||
return;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Only set the UUID if the value is valid (non zero) */
|
||||
uuid.u16 = xtoi(argv[3]);
|
||||
if (uuid.u16) {
|
||||
uuid.type = BT_UUID_16;
|
||||
discover_params.uuid = &uuid;
|
||||
}
|
||||
|
||||
if (argc > 4) {
|
||||
discover_params.start_handle = xtoi(argv[4]);
|
||||
if (argc > 5) {
|
||||
@ -446,7 +454,13 @@ static void cmd_gatt_discover(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
err = bt_gatt_discover(conn, &discover_params);
|
||||
done:
|
||||
if (!strcmp(argv[0], "gatt-discover-characteristic")) {
|
||||
err = bt_gatt_discover_characteristic(conn, &discover_params);
|
||||
} else {
|
||||
err = bt_gatt_discover(conn, &discover_params);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
printk("Discover failed (err %d)\n", err);
|
||||
} else {
|
||||
@ -473,4 +487,5 @@ void main(void)
|
||||
shell_cmd_register("security", cmd_security);
|
||||
shell_cmd_register("gatt-exchange-mtu", cmd_gatt_exchange_mtu);
|
||||
shell_cmd_register("gatt-discover", cmd_gatt_discover);
|
||||
shell_cmd_register("gatt-discover-characteristic", cmd_gatt_discover);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user