Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling BLE advertising start/stop command in shell application #3714

Merged
merged 1 commit into from
Nov 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions examples/shell/shell_common/cmd_btp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,37 @@ int cmd_btp_adv(int argc, char ** argv)
{
CHIP_ERROR error = CHIP_NO_ERROR;
streamer_t * sout = streamer_get();
bool adv_enabled;

if (argc == 0)
{
ExitNow(error = CHIP_ERROR_INVALID_ARGUMENT);
}

adv_enabled = ConnectivityMgr().IsBLEAdvertisingEnabled();
if (strcmp(argv[0], "start") == 0)
{
streamer_printf(sout, "Starting BLE advertising");
// TODO: start advertising
if (adv_enabled)
{
streamer_printf(sout, "BLE advertising already enabled");
}
else
{
streamer_printf(sout, "Starting BLE advertising");
ConnectivityMgr().SetBLEAdvertisingEnabled(true);
}
}
else if (strcmp(argv[0], "stop") == 0)
{
streamer_printf(sout, "Stopping BLE advertising");
// TODO: stop advertising
if (adv_enabled)
{
streamer_printf(sout, "Stopping BLE advertising");
ConnectivityMgr().SetBLEAdvertisingEnabled(false);
}
else
{
streamer_printf(sout, "BLE advertising already stopped");
}
}
else
{
Expand Down Expand Up @@ -162,7 +178,7 @@ static const shell_command_t cmds_btp[] = {
{ &cmd_btp_help, "help", "Usage: btp <subcommand>" },
{ &cmd_btp_scan, "scan", "Enable or disable scan. Usage: btp scan <start timeout|stop>" },
{ &cmd_btp_connect, "connect", "Connect or disconnect to a device. Usage: btp connect <start address|stop>" },
{ &cmd_btp_adv, "adv", "Enable or disable advertisement. Usage: device dump" },
{ &cmd_btp_adv, "adv", "Enable or disable advertisement. Usage: btp adv <start|stop>" },
{ &cmd_btp_send, "send", "Send binary data. Usage: device dump" },
};

Expand Down