Skip to content

Commit

Permalink
Merge pull request #11 from Avnet/AAGBT-50
Browse files Browse the repository at this point in the history
Add ini file configuration to control BLE transmit feature
  • Loading branch information
bawilless authored Aug 9, 2023
2 parents 02e384e + 21e65d1 commit c88409e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
7 changes: 6 additions & 1 deletion ndp120/synpkg_files/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Power_Mode=0

[BLE Mode]
# 0-> Disables BLE mode where inference results are broadcast over BLE
# 1-> Enables BLE mode
BLE_Enabled=0
6 changes: 6 additions & 0 deletions src/ble_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/ble_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdio.h>
#include "r_sci_uart.h"
#include "hal_data.h"
#include "fat_load.h"

extern volatile bool g_uart3_txComplete; /* Tx complete flags */

Expand Down
8 changes: 8 additions & 0 deletions src/fat_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -643,3 +646,8 @@ int is_file_exist_in_sdcard( char *filename )

return status;
}

int get_ble_mode( void )
{
return ble_mode;
}
6 changes: 6 additions & 0 deletions src/fat_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions src/ndp_thread_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 */
Expand All @@ -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
{
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit c88409e

Please sign in to comment.