Bluetooth: shell: Add name command

name command can be used to read or write the GAP Device Name which is
used by the advertise command.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2018-07-17 13:55:47 +03:00 committed by Johan Hedberg
commit e9e5115116
2 changed files with 19 additions and 0 deletions

View file

@ -526,6 +526,23 @@ static int cmd_init(int argc, char *argv[])
return 0;
}
static int cmd_name(int argc, char *argv[])
{
int err;
if (argc < 2) {
printk("Bluetooth Local Name: %s\n", bt_get_name());
return 0;
}
err = bt_set_name(argv[1]);
if (err) {
printk("Unable to set name %s (err %d)", argv[1], err);
}
return 0;
}
static void cmd_active_scan_on(int dups)
{
int err;
@ -1909,6 +1926,7 @@ static int cmd_bredr_sdp_find_record(int argc, char *argv[])
static const struct shell_cmd bt_commands[] = {
{ "init", cmd_init, HELP_ADDR_LE },
{ "name", cmd_name, "[name]" },
{ "scan", cmd_scan,
"<value: on, passive, off> <dup filter: dups, nodups>" },
{ "advertise", cmd_advertise,

View file

@ -17,6 +17,7 @@ CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_CONSOLE_SHELL=y
CONFIG_BT_SHELL=y
CONFIG_BT_DEVICE_NAME="test shell"
CONFIG_BT_DEVICE_NAME_MAX=28
CONFIG_BT_L2CAP_TX_BUF_COUNT=6
CONFIG_BT_SETTINGS=y