버퍼 초기화 추가
This commit is contained in:
@@ -55,7 +55,7 @@ void dr_ble_return_3(const char *tag, uint16_t v1, uint16_t v2, uint16_t v3)
|
|||||||
void dr_ble_debug(uint16_t point_id, uint16_t value)
|
void dr_ble_debug(uint16_t point_id, uint16_t value)
|
||||||
{
|
{
|
||||||
/* Use dedicated buffer to avoid conflicts with ble_bin_buffer */
|
/* Use dedicated buffer to avoid conflicts with ble_bin_buffer */
|
||||||
static uint8_t dbg_buffer[8];
|
static uint8_t dbg_buffer[8] = {0};
|
||||||
|
|
||||||
dbg_buffer[0] = 'd';
|
dbg_buffer[0] = 'd';
|
||||||
dbg_buffer[1] = 'b';
|
dbg_buffer[1] = 'b';
|
||||||
@@ -73,7 +73,7 @@ void dr_ble_debug(uint16_t point_id, uint16_t value)
|
|||||||
void dr_ble_return_piezo_1(const char *tag, uint16_t value)
|
void dr_ble_return_piezo_1(const char *tag, uint16_t value)
|
||||||
{
|
{
|
||||||
/* Use dedicated buffer for piezo responses to avoid conflicts with ble_bin_buffer */
|
/* Use dedicated buffer for piezo responses to avoid conflicts with ble_bin_buffer */
|
||||||
static uint8_t piezo_buffer[8];
|
static uint8_t piezo_buffer[8] = {0};
|
||||||
|
|
||||||
piezo_buffer[0] = tag[0];
|
piezo_buffer[0] = tag[0];
|
||||||
piezo_buffer[1] = tag[1];
|
piezo_buffer[1] = tag[1];
|
||||||
|
|||||||
@@ -212,20 +212,21 @@ static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /* C
|
|||||||
static uint16_t m_ble_nus_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - 3; /* NUS max data length (MTU - overhead) */
|
static uint16_t m_ble_nus_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - 3; /* NUS max data length (MTU - overhead) */
|
||||||
static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}}; /* UUIDs included in advertising */
|
static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}}; /* UUIDs included in advertising */
|
||||||
|
|
||||||
static uint8_t m_tx_buffer[BLE_NUS_MAX_DATA_LEN]; /* ASCII text transmission buffer */
|
static uint8_t m_tx_buffer[BLE_NUS_MAX_DATA_LEN] = {0}; /* ASCII text transmission buffer */
|
||||||
static uint16_t m_tx_len = 0; /* Data length to transmit */
|
static uint16_t m_tx_len = 0; /* Data length to transmit */
|
||||||
static volatile bool m_tx_in_progress = false; /* TX in progress flag */
|
static volatile bool m_tx_in_progress = false; /* TX in progress flag */
|
||||||
static volatile bool m_tx_complete_pending = false; /* TX completion pending flag */
|
static volatile bool m_tx_complete_pending = false; /* TX completion pending flag */
|
||||||
static uint8_t c_addr[6]; /* Connected peer BLE address */
|
static uint8_t c_addr[6] = {0}; /* Connected peer BLE address */
|
||||||
|
|
||||||
static char * roles_str[] = {"INVALID_ROLE", "CENTRAL", "PERIPHERAL"};
|
static char * roles_str[] = {"INVALID_ROLE", "CENTRAL", "PERIPHERAL"};
|
||||||
|
|
||||||
/*==============================================================================
|
/*==============================================================================
|
||||||
* Global Variables
|
* Global Variables
|
||||||
|
* IEC 62304 §5.5.3: all global buffers zero-initialized for deterministic startup
|
||||||
*============================================================================*/
|
*============================================================================*/
|
||||||
uint8_t m_encrypted_text[AES_BLOCK_SIZE]; /* AES encryption result buffer */
|
uint8_t m_encrypted_text[AES_BLOCK_SIZE] = {0}; /* AES encryption result buffer */
|
||||||
uint8_t m_encrypted_text2[AES_BLOCK_SIZE]; /* AES encryption result buffer 2 */
|
uint8_t m_encrypted_text2[AES_BLOCK_SIZE] = {0}; /* AES encryption result buffer 2 */
|
||||||
uint8_t m_decrypted_text[AES_BLOCK_SIZE]; /* AES decryption result buffer */
|
uint8_t m_decrypted_text[AES_BLOCK_SIZE] = {0}; /* AES decryption result buffer */
|
||||||
|
|
||||||
volatile uint8_t Sj_type; /* Command type identifier */
|
volatile uint8_t Sj_type; /* Command type identifier */
|
||||||
volatile bool processing; /* Sensor data processing flag (prevents duplicate commands) */
|
volatile bool processing; /* Sensor data processing flag (prevents duplicate commands) */
|
||||||
@@ -244,9 +245,9 @@ extern uint8_t add_cycle; /* Additional measurement cycle counter *
|
|||||||
extern bool motion_raw_data_enabled; /* Motion raw data streaming enabled */
|
extern bool motion_raw_data_enabled; /* Motion raw data streaming enabled */
|
||||||
|
|
||||||
uint16_t cnt_s; /* Power button polling counter (5ms units, 150=0.75s) */
|
uint16_t cnt_s; /* Power button polling counter (5ms units, 150=0.75s) */
|
||||||
char ble_tx_buffer[BLE_NUS_MAX_DATA_LEN]; /* BLE text transmission buffer */
|
char ble_tx_buffer[BLE_NUS_MAX_DATA_LEN] = {0}; /* BLE text transmission buffer */
|
||||||
uint8_t ble_bin_buffer[BLE_NUS_MAX_DATA_LEN]; /* BLE binary response buffer (2026-03-17: moved from cmd_parse.c) */
|
uint8_t ble_bin_buffer[BLE_NUS_MAX_DATA_LEN] = {0}; /* BLE binary response buffer */
|
||||||
uint16_t ble_bin_buff[BLE_NUS_MAX_DATA_LEN/2]; /* BLE binary transmission buffer (word units) */
|
uint16_t ble_bin_buff[BLE_NUS_MAX_DATA_LEN/2] = {0}; /* BLE binary transmission buffer (word units) */
|
||||||
which_cmd_t cmd_type_t; /* Current command source (CMD_BLE or CMD_UART) */
|
which_cmd_t cmd_type_t; /* Current command source (CMD_BLE or CMD_UART) */
|
||||||
|
|
||||||
bool device_status = false; /* Device active state (true=running) */
|
bool device_status = false; /* Device active state (true=running) */
|
||||||
@@ -261,13 +262,13 @@ volatile bool data_tx_in_progress = false; /* Binary TX in progress flag
|
|||||||
|
|
||||||
/* -- BLE TX async retry state -- */
|
/* -- BLE TX async retry state -- */
|
||||||
static volatile bool s_tx_pending = false; /* TX retry pending */
|
static volatile bool s_tx_pending = false; /* TX retry pending */
|
||||||
static uint8_t s_tx_pending_buf[BLE_NUS_MAX_DATA_LEN]; /* Pending packet (with CRC) */
|
static uint8_t s_tx_pending_buf[BLE_NUS_MAX_DATA_LEN] = {0}; /* Pending packet (with CRC) */
|
||||||
static uint16_t s_tx_pending_len = 0; /* Pending packet length */
|
static uint16_t s_tx_pending_len = 0; /* Pending packet length */
|
||||||
|
|
||||||
|
|
||||||
char m_static_passkey[PASSKEY_LENGTH] = DEFAULT_PASSKEY; /* Static passkey (6 digits, loaded from FDS) */
|
char m_static_passkey[PASSKEY_LENGTH] = DEFAULT_PASSKEY; /* Static passkey (6 digits, loaded from FDS) */
|
||||||
char SERIAL_NO[SERIAL_NO_LENGTH]; /* Serial number (used as BLE device name) */
|
char SERIAL_NO[SERIAL_NO_LENGTH] = {0}; /* Serial number (used as BLE device name) */
|
||||||
char HW_NO[HW_NO_LENGTH]; /* Hardware number (FDS stored/read) */
|
char HW_NO[HW_NO_LENGTH] = {0}; /* Hardware number (FDS stored/read) */
|
||||||
bool bond_data_delete; /* Bond data delete request flag */
|
bool bond_data_delete; /* Bond data delete request flag */
|
||||||
uint32_t m_life_cycle; /* Device life cycle counter */
|
uint32_t m_life_cycle; /* Device life cycle counter */
|
||||||
uint8_t resetCount = 0; /* Communication timeout counter (reset detection) */
|
uint8_t resetCount = 0; /* Communication timeout counter (reset detection) */
|
||||||
@@ -592,7 +593,7 @@ extern bool maa_async_is_busy(void);
|
|||||||
extern void maa_async_abort(void);
|
extern void maa_async_abort(void);
|
||||||
|
|
||||||
/* 2026-03-17: Prevent blocking in BLE callback -- buffer command for main loop processing */
|
/* 2026-03-17: Prevent blocking in BLE callback -- buffer command for main loop processing */
|
||||||
static volatile uint8_t pending_cmd_buf[BLE_NUS_MAX_DATA_LEN];
|
static volatile uint8_t pending_cmd_buf[BLE_NUS_MAX_DATA_LEN] = {0};
|
||||||
static volatile uint8_t pending_cmd_len = 0;
|
static volatile uint8_t pending_cmd_len = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ static uint32_t m_vref_mv = DR_ADC_VREF_MV;
|
|||||||
/* Hardware SPI instance (SPIM3 - supports up to 32MHz, 16MHz for ADC121S051) */
|
/* Hardware SPI instance (SPIM3 - supports up to 32MHz, 16MHz for ADC121S051) */
|
||||||
static nrfx_spim_t m_spim = NRFX_SPIM_INSTANCE(3);
|
static nrfx_spim_t m_spim = NRFX_SPIM_INSTANCE(3);
|
||||||
|
|
||||||
/* Echo capture buffer (module-level for external access) */
|
/* IEC 62304 §5.5.3: zero-initialized for deterministic startup */
|
||||||
static uint16_t m_echo_buffer[DR_ADC_ECHO_SAMPLES_MAX];
|
static uint16_t m_echo_buffer[DR_ADC_ECHO_SAMPLES_MAX] = {0};
|
||||||
|
|
||||||
/*==============================================================================
|
/*==============================================================================
|
||||||
* PRIVATE FUNCTIONS
|
* PRIVATE FUNCTIONS
|
||||||
@@ -1104,7 +1104,7 @@ dr_adc_err_t dr_adc_transmit_channel_delta(const dr_maa_channel_t *ch_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Compress data first */
|
/* Compress data first */
|
||||||
static uint8_t delta_buffer[400]; /* Worst case: 140*3 = 420 bytes */
|
static uint8_t delta_buffer[400] = {0}; /* Worst case: 140*3 = 420 bytes */
|
||||||
uint16_t compressed_size = 0;
|
uint16_t compressed_size = 0;
|
||||||
|
|
||||||
dr_adc_err_t err = dr_adc_delta_compress(ch_data->samples, ch_data->num_samples,
|
dr_adc_err_t err = dr_adc_delta_compress(ch_data->samples, ch_data->num_samples,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
static struct inv_imu_device icm_driver;
|
static struct inv_imu_device icm_driver;
|
||||||
|
|
||||||
/* Binary buffer for BLE transmission */
|
/* Binary buffer for BLE transmission */
|
||||||
uint8_t imu_bin_buffer[BLE_NUS_MAX_DATA_LEN];
|
uint8_t imu_bin_buffer[BLE_NUS_MAX_DATA_LEN] = {0};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ICM42670P mounting matrix (Q30 fixed-point)
|
* ICM42670P mounting matrix (Q30 fixed-point)
|
||||||
|
|||||||
Reference in New Issue
Block a user