Reworked part of the bluetooth nano shell commands
This commit is contained in:
parent
5387213c06
commit
d97db47fad
@ -523,9 +523,46 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
||||
|
||||
int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
||||
{
|
||||
if(argc >= 3)
|
||||
if(argc > 1)
|
||||
{
|
||||
if(strcmp(argv[1], "send_ble_notif") == 0)
|
||||
if(strcmp(argv[1], "enable") == 0)
|
||||
{
|
||||
if(argc == 3)
|
||||
{
|
||||
bool result = ble_modem_on(true);
|
||||
shell_printf("Enabling bluetooth modem with ble service : %d"NEW_LINE, result);
|
||||
|
||||
if(result)
|
||||
ble_service_nus_register_data_rx_cb(&(nus_data_rx_cb));
|
||||
}
|
||||
else
|
||||
{
|
||||
shell_printf("Enabling bluetooth modem only : %d"NEW_LINE, ble_modem_on(false));
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[1], "disable") == 0)
|
||||
{
|
||||
shell_printf("Disabling bluetooth : %d"NEW_LINE, ble_modem_off());
|
||||
}
|
||||
else if(strcmp(argv[1], "start_demo") == 0)
|
||||
{
|
||||
bool result = ble_service_start();
|
||||
shell_printf("Starting demo : %d"NEW_LINE"Use a BLE app to find the device"NEW_LINE, result /*demo_ble_server_on()*/);
|
||||
if(result)
|
||||
{
|
||||
ble_service_nus_register_data_rx_cb(&(nus_data_rx_cb));
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[1], "stop_demo") == 0)
|
||||
{
|
||||
shell_printf("Stopping demo : %d"NEW_LINE, ble_service_stop() /*demo_ble_server_off()*/);
|
||||
ble_service_nus_register_data_rx_cb(NULL);
|
||||
}
|
||||
else if(strcmp(argv[1], "mtu_exch") == 0)
|
||||
{
|
||||
shell_printf("MTU exchange request : %d"NEW_LINE, ble_service_request_mtu_exchange());
|
||||
}
|
||||
else if(strcmp(argv[1], "send_ble_notif") == 0 && argc > 2)
|
||||
{
|
||||
char cmd[200] = "";
|
||||
bool found = false;
|
||||
@ -583,51 +620,7 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
shell_printf("Unknown %s action"NEW_LINE, argv[0]);
|
||||
}
|
||||
}
|
||||
else if(argc > 1)
|
||||
{
|
||||
if(strcmp(argv[1], "enable") == 0)
|
||||
{
|
||||
if(argc == 3)
|
||||
{
|
||||
bool result = ble_modem_on(true);
|
||||
shell_printf("Enabling bluetooth modem with ble service : %d"NEW_LINE, result);
|
||||
|
||||
if(result)
|
||||
ble_service_nus_register_data_rx_cb(&(nus_data_rx_cb));
|
||||
}
|
||||
else
|
||||
{
|
||||
shell_printf("Enabling bluetooth modem only : %d"NEW_LINE, ble_modem_on(false));
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[1], "disable") == 0)
|
||||
{
|
||||
shell_printf("Disabling bluetooth : %d"NEW_LINE, ble_modem_off());
|
||||
}
|
||||
else if(strcmp(argv[1], "start_demo") == 0)
|
||||
{
|
||||
bool result = ble_service_start();
|
||||
shell_printf("Starting demo : %d"NEW_LINE"Use a BLE app to find the device"NEW_LINE, result /*demo_ble_server_on()*/);
|
||||
if(result)
|
||||
{
|
||||
ble_service_nus_register_data_rx_cb(&(nus_data_rx_cb));
|
||||
}
|
||||
}
|
||||
else if(strcmp(argv[1], "stop_demo") == 0)
|
||||
{
|
||||
shell_printf("Stopping demo : %d"NEW_LINE, ble_service_stop() /*demo_ble_server_off()*/);
|
||||
ble_service_nus_register_data_rx_cb(NULL);
|
||||
}
|
||||
else if(strcmp(argv[1], "mtu_exch") == 0)
|
||||
{
|
||||
shell_printf("MTU exchange request : %d"NEW_LINE, ble_service_request_mtu_exchange());
|
||||
}
|
||||
else
|
||||
{
|
||||
shell_printf("Unknown %s action"NEW_LINE, argv[0]);
|
||||
shell_printf("Unknown %s action"NEW_LINE, argv[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user