diff --git a/subsys/bluetooth/shell/bt.c b/subsys/bluetooth/shell/bt.c index 0fea5d5d028..5bf9e0de4a9 100644 --- a/subsys/bluetooth/shell/bt.c +++ b/subsys/bluetooth/shell/bt.c @@ -2014,6 +2014,7 @@ static const struct shell_cmd bt_commands[] = { " [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, diff --git a/subsys/bluetooth/shell/gatt.c b/subsys/bluetooth/shell/gatt.c index 936a71b141b..82f77ee8496 100644 --- a/subsys/bluetooth/shell/gatt.c +++ b/subsys/bluetooth/shell/gatt.c @@ -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, diff --git a/subsys/bluetooth/shell/gatt.h b/subsys/bluetooth/shell/gatt.h index bbd32a91087..541ba7e13e3 100644 --- a/subsys/bluetooth/shell/gatt.h +++ b/subsys/bluetooth/shell/gatt.h @@ -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[]);