Bluetooth: Shell: Add gatt-unregister-service command

gatt-unregister-service can be used to remove the test service at
runtime causing service changed to be indicated:

00:1b:dc:07:31:88 (public)> gatt-unregister-service
[bt] [DBG] gatt_indicate: (0x0011e100) conn 0x0011d880 handle 0x0008
[bt] [DBG] bt_att_req_send: (0x0011e100) conn 0x0011d880 req 0x0011db00
[bt] [DBG] att_send_req: (0x0011e100) req 0x0011db00
Unregistering test vendor service

< ACL Data TX: Handle 3585 flags 0x00 dlen 11
      ATT: Handle Value Indication (0x1d) len 6
        Handle: 0x0008
          Data: 0a001000
> ACL Data RX: Handle 3585 flags 0x02 dlen 5
      ATT: Handle Value Confirmation (0x1e) len 0

Jira: ZEP-2225
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2017-06-12 14:49:26 +03:00 committed by Johan Hedberg
commit 01eeb5ea0b
3 changed files with 12 additions and 0 deletions

View file

@ -2016,6 +2016,8 @@ static const struct shell_cmd bt_commands[] = {
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
{ "gatt-register-service", cmd_gatt_register_test_svc,
"register pre-predefined test service" },
{ "gatt-unregister-service", cmd_gatt_unregister_test_svc,
"unregister pre-predefined test service" },
{ "gatt-metrics", cmd_gatt_write_cmd_metrics,
"register vendr char and measure rx [value on, off]" },
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)

View file

@ -596,6 +596,15 @@ int cmd_gatt_register_test_svc(int argc, char *argv[])
return 0;
}
int cmd_gatt_unregister_test_svc(int argc, char *argv[])
{
bt_gatt_unregister_service(&vnd_svc);
printk("Unregistering test vendor service\n");
return 0;
}
static struct bt_uuid_128 met_svc_uuid = BT_UUID_INIT_128(
0x01, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12,
0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12);

View file

@ -22,6 +22,7 @@ int cmd_gatt_write_without_rsp(int argc, char *argv[]);
int cmd_gatt_subscribe(int argc, char *argv[]);
int cmd_gatt_unsubscribe(int argc, char *argv[]);
int cmd_gatt_register_test_svc(int argc, char *argv[]);
int cmd_gatt_unregister_test_svc(int argc, char *argv[]);
int cmd_gatt_write_cmd_metrics(int argc, char *argv[]);
#endif /* __GATT_H */