diff --git a/ndp120/synpkg_files/config.ini b/ndp120/synpkg_files/config.ini index 462fb6f..f421279 100644 --- a/ndp120/synpkg_files/config.ini +++ b/ndp120/synpkg_files/config.ini @@ -42,4 +42,9 @@ Print_to_terminal=0 # output data to the serial debug terminal [Low Power Mode] # 0->Enter Low Power Mode with "down . . down" command; 1->Enter Low Power mode automatically after each feature detection -Power_Mode=0 \ No newline at end of file +Power_Mode=0 + +[BLE Mode] +# 0-> Disables BLE mode where inference results are broadcast over BLE +# 1-> Enables BLE mode +BLE_Enabled=0 \ No newline at end of file diff --git a/src/ble_uart.c b/src/ble_uart.c index 39b3705..f564696 100644 --- a/src/ble_uart.c +++ b/src/ble_uart.c @@ -44,8 +44,14 @@ void ble_uart_callback(uart_callback_args_t *p_args) int ble_send(char *pBuffer, int size) { + fsp_err_t err = FSP_SUCCESS; + // If we disabled BLE mode, then just return + if(get_ble_mode() == BLE_DISABLE){ + return 0; + } + g_uart3_txComplete = false; err = R_SCI_UART_Write(&g_uart3_ctrl, (uint8_t *)pBuffer, (uint32_t)size); if(FSP_SUCCESS != err) diff --git a/src/ble_uart.h b/src/ble_uart.h index 9432d78..be6efd8 100644 --- a/src/ble_uart.h +++ b/src/ble_uart.h @@ -11,6 +11,7 @@ #include #include "r_sci_uart.h" #include "hal_data.h" +#include "fat_load.h" extern volatile bool g_uart3_txComplete; /* Tx complete flags */ diff --git a/src/fat_load.c b/src/fat_load.c index 1135c6e..94e3867 100644 --- a/src/fat_load.c +++ b/src/fat_load.c @@ -38,6 +38,7 @@ int recording_period = 10; int low_power_mode = DOWN_DOWN_LP_MODE; int imu_write_to_file = IMU_FUNC_ENABLE; int imu_print_to_terminal = IMU_FUNC_DISABLE; +int ble_mode = BLE_DISABLE; void init_fatfs(void) { @@ -498,6 +499,8 @@ static uint32_t read_config_file( void ) IMU_FUNC_ENABLE, inifile); imu_print_to_terminal = ini_getl("IMU data stream", "Print_to_terminal", \ IMU_FUNC_DISABLE, inifile); + ble_mode = ini_getl("BLE Mode", "BLE_Enabled", BLE_DISABLE, inifile); + // Output application information to user printf("\nApplication Version: %s\n", VERSION_STRING); @@ -643,3 +646,8 @@ int is_file_exist_in_sdcard( char *filename ) return status; } + +int get_ble_mode( void ) +{ + return ble_mode; +} diff --git a/src/fat_load.h b/src/fat_load.h index d953986..4ac4aa5 100644 --- a/src/fat_load.h +++ b/src/fat_load.h @@ -42,6 +42,11 @@ enum IMU_FUNC_TYPE { IMU_FUNC_ENABLE = 1, }; +enum BLE_MODE_TYPE { + BLE_DISABLE = 0, + BLE_ENABLE = 1, +}; + #define LED_EVENT_NUM 10 extern int mode_circular_motion; @@ -69,6 +74,7 @@ int get_low_power_mode( void ); int is_imu_data_to_file( void ); int is_imu_data_to_terminal( void ); int is_file_exist_in_sdcard( char *filename ); +int get_ble_mode( void ); uint32_t cat_file(char * src_file, char * dst_file, int flag); uint32_t remove_file(char * file_name); diff --git a/src/ndp_thread_entry.c b/src/ndp_thread_entry.c index 0f899c5..c22171d 100644 --- a/src/ndp_thread_entry.c +++ b/src/ndp_thread_entry.c @@ -30,7 +30,7 @@ enum at_cmd_voice{ V_STOP = 6, }; -static char ble_at_sting[][36] = { +static char ble_at_string[][36] = { "AT+BLETX={\"Action\":\"WakeUp\"}\r\n", "AT+BLETX={\"Action\":\"Up\"}\r\n", "AT+BLETX={\"Action\":\"Down\"}\r\n", @@ -206,14 +206,14 @@ void ndp_thread_entry(void *pvParameters) current_stat.led = LED_EVENT_NONE; q_event = led_event_color[ndp_class_idx]; xQueueSend(g_led_queue, (void *)&q_event, 0U ); - ble_send(ble_at_sting[V_WAKEUP], strlen(ble_at_sting[V_WAKEUP])); + ble_send(ble_at_string[V_WAKEUP], strlen(ble_at_string[V_WAKEUP])); break; case 1: /* Voice: Up; light Cyan Led */ current_stat.led = LED_EVENT_NONE; q_event = led_event_color[ndp_class_idx]; xQueueSend(g_led_queue, (void *)&q_event, 0U ); - ble_send(ble_at_sting[V_UP], strlen(ble_at_sting[V_UP])); + ble_send(ble_at_string[V_UP], strlen(ble_at_string[V_UP])); break; case 2: /* Voice: Down; light Magenta Led */ @@ -225,7 +225,7 @@ void ndp_thread_entry(void *pvParameters) /* first receive 'Down' keyword */ q_event = led_event_color[ndp_class_idx]; xQueueSend(g_led_queue, (void *)&q_event, 0U ); - ble_send(ble_at_sting[V_DOWN], strlen(ble_at_sting[V_DOWN])); + ble_send(ble_at_string[V_DOWN], strlen(ble_at_string[V_DOWN])); } else { @@ -238,8 +238,8 @@ void ndp_thread_entry(void *pvParameters) q_event = LED_BLINK_DOUBLE_BLUE; xQueueSend(g_led_queue, (void *)&q_event, 0U ); /* Send 'idle' and 'advstop' to bluetooth */ - ble_send(ble_at_sting[V_IDLE], strlen(ble_at_sting[V_IDLE])); - ble_send(ble_at_sting[V_STOP], strlen(ble_at_sting[V_STOP])); + ble_send(ble_at_string[V_IDLE], strlen(ble_at_string[V_IDLE])); + ble_send(ble_at_string[V_STOP], strlen(ble_at_string[V_STOP])); /* clear led state */ current_stat.led = LED_EVENT_NONE; } @@ -248,7 +248,7 @@ void ndp_thread_entry(void *pvParameters) /* invalid time */ q_event = led_event_color[ndp_class_idx]; xQueueSend(g_led_queue, (void *)&q_event, 0U ); - ble_send(ble_at_sting[V_DOWN], strlen(ble_at_sting[V_DOWN])); + ble_send(ble_at_string[V_DOWN], strlen(ble_at_string[V_DOWN])); } } break; @@ -257,14 +257,14 @@ void ndp_thread_entry(void *pvParameters) current_stat.led = LED_EVENT_NONE; q_event = led_event_color[ndp_class_idx]; xQueueSend(g_led_queue, (void *)&q_event, 0U ); - ble_send(ble_at_sting[V_BACK], strlen(ble_at_sting[V_BACK])); + ble_send(ble_at_string[V_BACK], strlen(ble_at_string[V_BACK])); break; case 4: /* Voice: Next; light Green Led */ current_stat.led = LED_EVENT_NONE; q_event = led_event_color[ndp_class_idx]; xQueueSend(g_led_queue, (void *)&q_event, 0U ); - ble_send(ble_at_sting[V_NEXT], strlen(ble_at_sting[V_NEXT])); + ble_send(ble_at_string[V_NEXT], strlen(ble_at_string[V_NEXT])); break; default : break;