From 01eeb5ea0bd5c0012232555bddc7b56e08b73754 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 12 Jun 2017 14:49:26 +0300 Subject: [PATCH] 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 --- subsys/bluetooth/shell/bt.c | 2 ++ subsys/bluetooth/shell/gatt.c | 9 +++++++++ subsys/bluetooth/shell/gatt.h | 1 + 3 files changed, 12 insertions(+) diff --git a/subsys/bluetooth/shell/bt.c b/subsys/bluetooth/shell/bt.c index f55226238f9..0fea5d5d028 100644 --- a/subsys/bluetooth/shell/bt.c +++ b/subsys/bluetooth/shell/bt.c @@ -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) diff --git a/subsys/bluetooth/shell/gatt.c b/subsys/bluetooth/shell/gatt.c index 9356ab9c9ec..936a71b141b 100644 --- a/subsys/bluetooth/shell/gatt.c +++ b/subsys/bluetooth/shell/gatt.c @@ -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); diff --git a/subsys/bluetooth/shell/gatt.h b/subsys/bluetooth/shell/gatt.h index a12b84ef30a..bbd32a91087 100644 --- a/subsys/bluetooth/shell/gatt.h +++ b/subsys/bluetooth/shell/gatt.h @@ -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 */