Bluetooth: shell: Fix requiring UUID for gatt-discover

This enables using these commands to perform discover all procedure:

> gatt-discover-primary
 Discover pending
 Service 1800 found: start handle 1, end_handle 5
 Service 1801 found: start handle 6, end_handle 9

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2018-09-14 16:14:10 +03:00 committed by Johan Hedberg
commit f67d45609e
2 changed files with 7 additions and 14 deletions

View file

@ -2234,9 +2234,9 @@ static const struct shell_cmd bt_commands[] = {
#if defined(CONFIG_BT_GATT_CLIENT)
{ "gatt-exchange-mtu", cmd_gatt_exchange_mtu, HELP_NONE },
{ "gatt-discover-primary", cmd_gatt_discover,
"<UUID> [start handle] [end handle]" },
"[UUID] [start handle] [end handle]" },
{ "gatt-discover-secondary", cmd_gatt_discover,
"<UUID> [start handle] [end handle]" },
"[UUID] [start handle] [end handle]" },
{ "gatt-discover-include", cmd_gatt_discover,
"[UUID] [start handle] [end handle]" },
{ "gatt-discover-characteristic", cmd_gatt_discover,

View file

@ -158,18 +158,12 @@ int cmd_gatt_discover(int argc, char *argv[])
discover_params.start_handle = 0x0001;
discover_params.end_handle = 0xffff;
if (argc < 2) {
if (!strcmp(argv[0], "gatt-discover-primary") ||
!strcmp(argv[0], "gatt-discover-secondary")) {
return -EINVAL;
if (argc > 1) {
/* Only set the UUID if the value is valid (non zero) */
uuid.val = strtoul(argv[1], NULL, 16);
if (uuid.val) {
discover_params.uuid = &uuid.uuid;
}
goto done;
}
/* Only set the UUID if the value is valid (non zero) */
uuid.val = strtoul(argv[1], NULL, 16);
if (uuid.val) {
discover_params.uuid = &uuid.uuid;
}
if (argc > 2) {
@ -179,7 +173,6 @@ int cmd_gatt_discover(int argc, char *argv[])
}
}
done:
if (!strcmp(argv[0], "gatt-discover-secondary")) {
discover_params.type = BT_GATT_DISCOVER_SECONDARY;
} else if (!strcmp(argv[0], "gatt-discover-include")) {