Bluetooth: Shell: Add gatt-show-db command

gatt-show-db shows the current set of attributes available in the GATT
database:

bt> gatt-show-db
attr 0x0011ce80 handle 0x0001 uuid 2800 perm 0x01
attr 0x0011ce94 handle 0x0002 uuid 2803 perm 0x01
attr 0x0011cea8 handle 0x0003 uuid 2a00 perm 0x01
attr 0x0011cebc handle 0x0004 uuid 2803 perm 0x01
attr 0x0011ced0 handle 0x0005 uuid 2a01 perm 0x01
attr 0x0011cde0 handle 0x0006 uuid 2800 perm 0x01
attr 0x0011cdf4 handle 0x0007 uuid 2803 perm 0x01
attr 0x0011ce08 handle 0x0008 uuid 2a05 perm 0x00
attr 0x0011ce1c handle 0x0009 uuid 2902 perm 0x03
attr 0x0011c9a0 handle 0x000a uuid 2800 perm 0x01
attr 0x0011c9b4 handle 0x000b uuid 2803 perm 0x01

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2017-06-15 12:58:12 +03:00 committed by Johan Hedberg
commit 272b3a5c99
3 changed files with 17 additions and 0 deletions

View file

@ -2014,6 +2014,7 @@ static const struct shell_cmd bt_commands[] = {
"<CCC handle> <value handle> [ind]" },
{ "gatt-unsubscribe", cmd_gatt_unsubscribe, HELP_NONE },
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
{ "gatt-show-db", cmd_gatt_show_db, HELP_NONE },
{ "gatt-register-service", cmd_gatt_register_test_svc,
"register pre-predefined test service" },
{ "gatt-unregister-service", cmd_gatt_unregister_test_svc,

View file

@ -483,6 +483,21 @@ int cmd_gatt_unsubscribe(int argc, char *argv[])
}
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
static u8_t print_attr(const struct bt_gatt_attr *attr, void *user_data)
{
printk("attr %p handle 0x%04x uuid %s perm 0x%02x\n",
attr, attr->handle, bt_uuid_str(attr->uuid), attr->perm);
return BT_GATT_ITER_CONTINUE;
}
int cmd_gatt_show_db(int argc, char *argv[])
{
bt_gatt_foreach_attr(0x0001, 0xffff, print_attr, NULL);
return 0;
}
/* Custom Service Variables */
static struct bt_uuid_128 vnd_uuid = BT_UUID_INIT_128(
0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12,

View file

@ -13,6 +13,7 @@
#ifndef __GATT_H
#define __GATT_H
int cmd_gatt_show_db(int argc, char *argv[]);
int cmd_gatt_exchange_mtu(int argc, char *argv[]);
int cmd_gatt_discover(int argc, char *argv[]);
int cmd_gatt_read(int argc, char *argv[]);