wireless/bluetooth/btsak: fix help messages
Currently the help messages use "private" string while code expects "random". Remove not needed (CODE void *) cast. Use 'nitems' macro to calculate number of elements in array Align output in `btsak_cmd_scanget` command. Fix style issues Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
65ee6bea44
commit
f4d3e549b6
@ -54,7 +54,7 @@ Description: Enable security (encryption) for a connection:
|
|||||||
This command may return error if required level of security
|
This command may return error if required level of security
|
||||||
is not possible to achieve due to local or remote device
|
is not possible to achieve due to local or remote device
|
||||||
limitation (eg input output capabilities).
|
limitation (eg input output capabilities).
|
||||||
Usage: bt <ifname> security [-h] <addr> public|private <level>
|
Usage: bt <ifname> security [-h] <addr> public|random <level>
|
||||||
Where: <addr> - The 6-byte address of the connected peer
|
Where: <addr> - The 6-byte address of the connected peer
|
||||||
<level> - Security level, on of:
|
<level> - Security level, on of:
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ Where: See "GATT Commands" below
|
|||||||
```
|
```
|
||||||
Command: exchange-mtu
|
Command: exchange-mtu
|
||||||
Description: Set MTU to out maximum and negotiate MTU with peer
|
Description: Set MTU to out maximum and negotiate MTU with peer
|
||||||
Usage: bt <ifname> gatt exchange-mtu [-h] <addr> public|private
|
Usage: bt <ifname> gatt exchange-mtu [-h] <addr> public|random
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -88,19 +88,19 @@ Usage: bt <ifname> gatt mget [-h]
|
|||||||
```
|
```
|
||||||
Command: discover
|
Command: discover
|
||||||
Description: Initiate discovery
|
Description: Initiate discovery
|
||||||
Usage: bt <ifname> gatt discover [-h] <addr> public|private <uuid16> [<start> [<end>]]
|
Usage: bt <ifname> gatt discover [-h] <addr> public|random <uuid16> [<start> [<end>]]
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
Command: characteristic
|
Command: characteristic
|
||||||
Description: Initiate characteristics discovery
|
Description: Initiate characteristics discovery
|
||||||
Usage: bt <ifname> gatt characteristic [-h] <addr> public|private [<start> [<end>]]
|
Usage: bt <ifname> gatt characteristic [-h] <addr> public|random [<start> [<end>]]
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
Command: descriptor
|
Command: descriptor
|
||||||
Description: Initiate characteristics discovery
|
Description: Initiate characteristics discovery
|
||||||
Usage: bt <ifname> gatt descriptor [-h] <addr> public|private [<start> [<end>]]
|
Usage: bt <ifname> gatt descriptor [-h] <addr> public|random [<start> [<end>]]
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -112,13 +112,13 @@ Usage: bt <ifname> gatt dget [-h]
|
|||||||
```
|
```
|
||||||
Command: read
|
Command: read
|
||||||
Description: Initiate a GATT read operation.
|
Description: Initiate a GATT read operation.
|
||||||
Usage: bt <ifname> gatt read [-h] <addr> public|private <handle> [<offset>]
|
Usage: bt <ifname> gatt read [-h] <addr> public|random <handle> [<offset>]
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
Command: read-multiple
|
Command: read-multiple
|
||||||
Description: Initiate a GATT read-multiple operation.
|
Description: Initiate a GATT read-multiple operation.
|
||||||
Usage: bt <ifname> gatt read-multiple [-h] <addr> public|private <handle> [<handle> [<handle>]..]
|
Usage: bt <ifname> gatt read-multiple [-h] <addr> public|random <handle> [<handle> [<handle>]..]
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -130,7 +130,7 @@ Usage: bt <ifname> gatt rget [-h]
|
|||||||
```
|
```
|
||||||
Command: write
|
Command: write
|
||||||
Description: Initiate a GATT write operation.
|
Description: Initiate a GATT write operation.
|
||||||
Usage: bt <ifname> gatt write [-h] <addr> public|private <handle> <byte> [<byte> [<byte>]..]
|
Usage: bt <ifname> gatt write [-h] <addr> public|random <handle> <byte> [<byte> [<byte>]..]
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -178,7 +178,7 @@ int btsak_str2addr(FAR const char *str, FAR uint8_t *addr);
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Convert a string to an address type. String options are "public" or
|
* Convert a string to an address type. String options are "public" or
|
||||||
* "private".
|
* "random".
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
* Name: btsak_cmd_discover_common
|
* Name: btsak_cmd_discover_common
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] <discover-cmd> [-h] <addr> public|private [<uuid16>]
|
* gatt [-h] <discover-cmd> [-h] <addr> public|random [<uuid16>]
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ static void btsak_cmd_read_common(FAR struct btsak_s *btsak, int argc,
|
|||||||
* Name: btsak_cmd_gatt_exchange_mtu
|
* Name: btsak_cmd_gatt_exchange_mtu
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] exchange_mtu [-h] <addr> public|private command
|
* gatt [-h] exchange_mtu [-h] <addr> public|random command
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ void btsak_cmd_gatt_exchange_mtu(FAR struct btsak_s *btsak, int argc,
|
|||||||
* Name: btsak_cmd_discover
|
* Name: btsak_cmd_discover
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] discover [-h] <addr> public|private <uuid16> command
|
* gatt [-h] discover [-h] <addr> public|random <uuid16> command
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -412,7 +412,7 @@ void btsak_cmd_discover(FAR struct btsak_s *btsak, int argc,
|
|||||||
* Name: btsak_cmd_gatt_discover_characteristic
|
* Name: btsak_cmd_gatt_discover_characteristic
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] characteristic [-h] <addr> public|private command
|
* gatt [-h] characteristic [-h] <addr> public|random command
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ void btsak_cmd_gatt_discover_characteristic(FAR struct btsak_s *btsak,
|
|||||||
* Name: btsak_cmd_gatt_discover_descriptor
|
* Name: btsak_cmd_gatt_discover_descriptor
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] descriptor [-h] <addr> public|private command
|
* gatt [-h] descriptor [-h] <addr> public|random command
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ void btsak_cmd_gatt_discover_descriptor(FAR struct btsak_s *btsak,
|
|||||||
* Name: btsak_cmd_gatt_read
|
* Name: btsak_cmd_gatt_read
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] read [-h] <addr> public|private <handle> [<offset>] command
|
* gatt [-h] read [-h] <addr> public|random <handle> [<offset>] command
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ void btsak_cmd_gatt_read(FAR struct btsak_s *btsak, int argc,
|
|||||||
* Name: btsak_cmd_gatt_read_multiple
|
* Name: btsak_cmd_gatt_read_multiple
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] read-multiple [-h] <addr> public|private <handle>
|
* gatt [-h] read-multiple [-h] <addr> public|random <handle>
|
||||||
* [<handle> [<handle>]..]
|
* [<handle> [<handle>]..]
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -488,7 +488,7 @@ void btsak_cmd_gatt_read_multiple(FAR struct btsak_s *btsak, int argc,
|
|||||||
* Name: btsak_cmd_gatt_write
|
* Name: btsak_cmd_gatt_write
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] write [-h] [-h] <addr> public|private <handle> <byte>
|
* gatt [-h] write [-h] [-h] <addr> public|random <handle> <byte>
|
||||||
* [<byte> [<byte>]..]
|
* [<byte> [<byte>]..]
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -571,7 +571,7 @@ void btsak_cmd_gatt_write(FAR struct btsak_s *btsak, int argc,
|
|||||||
* Name: btsak_cmd_gatt_connect
|
* Name: btsak_cmd_gatt_connect
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] connect [-h] <addr> public|private
|
* gatt [-h] connect [-h] <addr> public|random
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -585,7 +585,7 @@ void btsak_cmd_connect(FAR struct btsak_s *btsak, int argc,
|
|||||||
* Name: btsak_cmd_gatt_connect
|
* Name: btsak_cmd_gatt_connect
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* gatt [-h] disconnect [-h] <addr> public|private
|
* gatt [-h] disconnect [-h] <addr> public|random
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/wireless/bluetooth/bt_core.h>
|
#include <nuttx/wireless/bluetooth/bt_core.h>
|
||||||
#include <nuttx/net/bluetooth.h>
|
#include <nuttx/net/bluetooth.h>
|
||||||
@ -68,89 +69,93 @@ static const struct btsak_command_s g_btsak_commands[] =
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
"help",
|
"help",
|
||||||
(CODE void *)btsak_cmd_help,
|
btsak_cmd_help,
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
{"info",
|
{
|
||||||
(CODE void *)btsak_cmd_info,
|
"info",
|
||||||
|
btsak_cmd_info,
|
||||||
"[-h]"
|
"[-h]"
|
||||||
},
|
},
|
||||||
{"features",
|
{
|
||||||
(CODE void *)btsak_cmd_features,
|
"features",
|
||||||
|
btsak_cmd_features,
|
||||||
"[-h] [le]"
|
"[-h] [le]"
|
||||||
},
|
},
|
||||||
{"scan",
|
{
|
||||||
(CODE void *)btsak_cmd_scan,
|
"scan",
|
||||||
|
btsak_cmd_scan,
|
||||||
"[-h] <start [-d]|get|stop>"
|
"[-h] <start [-d]|get|stop>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"advertise",
|
"advertise",
|
||||||
(CODE void *)btsak_cmd_advertise,
|
btsak_cmd_advertise,
|
||||||
"[-h] <start|stop>"
|
"[-h] <start|stop>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"security",
|
"security",
|
||||||
(CODE void *)btsak_cmd_security,
|
btsak_cmd_security,
|
||||||
"[-h] <addr> public|private <level>"
|
"[-h] <addr> public|random <level>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"gatt",
|
"gatt",
|
||||||
(CODE void *)btsak_cmd_gatt,
|
btsak_cmd_gatt,
|
||||||
"[-h] <cmd> [option [option [option...]]]"
|
"[-h] <cmd> [option [option [option...]]]"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NCOMMANDS (sizeof(g_btsak_commands) / sizeof(struct btsak_command_s))
|
#define NCOMMANDS nitems(g_btsak_commands)
|
||||||
|
|
||||||
static const struct btsak_command_s g_btsak_gatt_commands[] =
|
static const struct btsak_command_s g_btsak_gatt_commands[] =
|
||||||
{
|
{
|
||||||
{"exchange-mtu",
|
{
|
||||||
(CODE void *)btsak_cmd_gatt_exchange_mtu,
|
"exchange-mtu",
|
||||||
"[-h] <addr> public|private"
|
btsak_cmd_gatt_exchange_mtu,
|
||||||
|
"[-h] <addr> public|random"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"connect",
|
"connect",
|
||||||
(CODE void *)btsak_cmd_connect,
|
btsak_cmd_connect,
|
||||||
"[-h] <addr> public|private"
|
"[-h] <addr> public|random"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"disconnect",
|
"disconnect",
|
||||||
(CODE void *)btsak_cmd_disconnect,
|
btsak_cmd_disconnect,
|
||||||
"[-h] <addr> public|private"
|
"[-h] <addr> public|random"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"discover",
|
"discover",
|
||||||
(CODE void *)btsak_cmd_discover,
|
btsak_cmd_discover,
|
||||||
"[-h] <addr> public|private <uuid16> [<start> [<end>]]"
|
"[-h] <addr> public|random <uuid16> [<start> [<end>]]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"characteristic",
|
"characteristic",
|
||||||
(CODE void *)btsak_cmd_gatt_discover_characteristic,
|
btsak_cmd_gatt_discover_characteristic,
|
||||||
"[-h] <addr> public|private [<start> [<end>]]"
|
"[-h] <addr> public|random [<start> [<end>]]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"descriptor",
|
"descriptor",
|
||||||
(CODE void *)btsak_cmd_gatt_discover_descriptor,
|
btsak_cmd_gatt_discover_descriptor,
|
||||||
"[-h] <addr> public|private [<start> [<end>]]"
|
"[-h] <addr> public|random [<start> [<end>]]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"read",
|
"read",
|
||||||
(CODE void *)btsak_cmd_gatt_read,
|
btsak_cmd_gatt_read,
|
||||||
"[-h] <addr> public|private <handle> [<offset>]"
|
"[-h] <addr> public|random <handle> [<offset>]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"read-multiple",
|
"read-multiple",
|
||||||
(CODE void *)btsak_cmd_gatt_read_multiple,
|
btsak_cmd_gatt_read_multiple,
|
||||||
"[-h] <addr> public|private <handle> [<handle> [<handle>]..]"
|
"[-h] <addr> public|random <handle> [<handle> [<handle>]..]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"write",
|
"write",
|
||||||
(CODE void *)btsak_cmd_gatt_write,
|
btsak_cmd_gatt_write,
|
||||||
"[-h] <addr> public|private <handle> <byte> [<byte> [<byte>]..]"
|
"[-h] <addr> public|random <handle> <byte> [<byte> [<byte>]..]"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GATT_NCOMMANDS (sizeof(g_btsak_gatt_commands) / sizeof(struct btsak_command_s))
|
#define GATT_NCOMMANDS nitems(g_btsak_gatt_commands)
|
||||||
|
|
||||||
static const bt_addr_t g_default_epaddr =
|
static const bt_addr_t g_default_epaddr =
|
||||||
{
|
{
|
||||||
@ -539,7 +544,7 @@ int btsak_str2addr(FAR const char *str, FAR uint8_t *addr)
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Convert a string to an address type. String options are "public" or
|
* Convert a string to an address type. String options are "public" or
|
||||||
* "private".
|
* "random".
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ static void btsak_security_showusage(FAR const char *progname,
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\toutput capabilities).\n\n");
|
"\toutput capabilities).\n\n");
|
||||||
fprintf(stderr, "Usage:\n\n");
|
fprintf(stderr, "Usage:\n\n");
|
||||||
fprintf(stderr, "\t%s <ifname> %s [-h] <addr> public|private <level>\n",
|
fprintf(stderr, "\t%s <ifname> %s [-h] <addr> public|random <level>\n",
|
||||||
progname, cmd);
|
progname, cmd);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\nWhere:\n\n");
|
"\nWhere:\n\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user