Updated the nano shell commands to use the new bluetooth modem start API which as the option to set the modem in bluetooth only mode

This commit is contained in:
anschrammh 2023-04-05 07:58:09 +02:00
parent 1faa5b3c84
commit 3fc2297f17

View File

@ -99,7 +99,7 @@ static void tls_rtc_irq_cb(void *arg)
static void nus_data_rx_cb(const uint8_t *data, uint16_t length)
{
shell_printf("%s, received data : "NEW_LINE"#", __FUNCTION__);
//shell_printf("%s, received data : "NEW_LINE"#", __FUNCTION__);
for (uint16_t i = 0; i < length; i++)
{
@ -108,7 +108,7 @@ static void nus_data_rx_cb(const uint8_t *data, uint16_t length)
else
shell_putc(data[i]);
}
shell_puts("#"NEW_LINE);
//shell_puts("#"NEW_LINE);
}
int _system(const shell_cmd_t *pcmd, int argc, char *const argv[])
@ -581,21 +581,17 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
{
if(argc > 1)
{
if(strcmp(argv[1], "enable") == 0)
if(strcmp(argv[1], "enable") == 0 && argc == 4)
{
if(argc == 3)
{
bool result = ble_modem_on(true);
shell_printf("Enabling bluetooth modem with ble service : %d"NEW_LINE, result);
bool btOnly = atoi(argv[2]) == 1;
bool service = atoi(argv[3]) == 1;
bool result = ble_modem_on(btOnly, service);
shell_printf("Enabling bluetooth : %d with bt only : %d and service : %d"NEW_LINE, result, btOnly, service);
if(result)
ble_service_register_nus_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());
@ -632,9 +628,9 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
sprintf(cmd, "{\"t\":\"status\",\"bat\":%s,\"chg\":%s,\"volt\":%s} \n", argv[3], argv[4], argv[5]);
found = true;
}
else if(strcmp(argv[2], "findPhone") == 0)
else if(strcmp(argv[2], "find_phone") == 0)
{
strcpy(cmd, "{\"t\":\"findPhone\",\"n\":true} \n");
sprintf(cmd, "{\"t\":\"findPhone\",\"n\":%s} \n", argv[3]);
found = true;
}
else if(strcmp(argv[2], "music") == 0)
@ -647,6 +643,11 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
sprintf(cmd, "{\"t\":\"notify\",\"n\":\"%s\",\"id\":%s,\"tel\":\"%s\",\"msg\":\"%s\"} \n", argv[3], argv[4], argv[5], argv[6]);
found = true;
}
else if(strcmp(argv[2], "act") == 0)
{
sprintf(cmd, "{\"t\":\"act\",\"hrm\":%s,\"stp\":%s} \n", argv[3], argv[4]);
found = true;
}
if(found)
{
@ -654,7 +655,8 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
}
else
{
shell_printf("Unknown %s action, list of send_ble_notif actions :"NEW_LINE"toast \"msg\""NEW_LINE"bat \"XX%%\" 1|0 X.X"NEW_LINE"findPhone"NEW_LINE"music play|pause|previous|next"NEW_LINE"notify reply|dismiss_all id \"tel\" \"msg\""NEW_LINE, argv[2]);
shell_printf("Unknown %s action, list of send_ble_notif actions :"NEW_LINE"toast \"msg\""NEW_LINE"bat \"XX%%\" 1|0 X.X"NEW_LINE"find_phone true|false"NEW_LINE"music play|pause|previous|next"NEW_LINE"notify reply|dismiss_all id \"tel\" \"msg\""NEW_LINE
"act hrm steps"NEW_LINE, argv[2]);
}
}
else if(strcmp(argv[1], "up_conn_param") == 0)