From 3fc2297f17085d8ea28911345071be30cba3811c Mon Sep 17 00:00:00 2001 From: anschrammh Date: Wed, 5 Apr 2023 07:58:09 +0200 Subject: [PATCH] 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 --- app/nano_shell_command.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/nano_shell_command.c b/app/nano_shell_command.c index a77c902..b471b72 100644 --- a/app/nano_shell_command.c +++ b/app/nano_shell_command.c @@ -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,20 +581,16 @@ 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) { @@ -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)