From 01bdbf7cfe6bb834f1b5a452025c35176c9451d5 Mon Sep 17 00:00:00 2001 From: jhchun Date: Thu, 16 Apr 2026 14:06:29 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=ED=8D=BC=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ble_app_bladder_patch/command/dr_util.c | 4 +-- .../ble_app_bladder_patch/main.c | 25 ++++++++++--------- .../measurement/adc121s051/dr_adc121s051.c | 6 ++--- .../measurement/imu/app_raw/app_raw.c | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/project/ble_peripheral/ble_app_bladder_patch/command/dr_util.c b/project/ble_peripheral/ble_app_bladder_patch/command/dr_util.c index 10fac91..41d45bc 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/command/dr_util.c +++ b/project/ble_peripheral/ble_app_bladder_patch/command/dr_util.c @@ -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) { /* 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[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) { /* 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[1] = tag[1]; diff --git a/project/ble_peripheral/ble_app_bladder_patch/main.c b/project/ble_peripheral/ble_app_bladder_patch/main.c index afe1659..1180112 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/main.c +++ b/project/ble_peripheral/ble_app_bladder_patch/main.c @@ -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 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 volatile bool m_tx_in_progress = false; /* TX in progress 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"}; /*============================================================================== * 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_text2[AES_BLOCK_SIZE]; /* AES encryption result buffer 2 */ -uint8_t m_decrypted_text[AES_BLOCK_SIZE]; /* AES decryption result buffer */ +uint8_t m_encrypted_text[AES_BLOCK_SIZE] = {0}; /* AES encryption result buffer */ +uint8_t m_encrypted_text2[AES_BLOCK_SIZE] = {0}; /* AES encryption result buffer 2 */ +uint8_t m_decrypted_text[AES_BLOCK_SIZE] = {0}; /* AES decryption result buffer */ volatile uint8_t Sj_type; /* Command type identifier */ 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 */ 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 */ -uint8_t ble_bin_buffer[BLE_NUS_MAX_DATA_LEN]; /* BLE binary response buffer (2026-03-17: moved from cmd_parse.c) */ -uint16_t ble_bin_buff[BLE_NUS_MAX_DATA_LEN/2]; /* BLE binary transmission buffer (word units) */ +char ble_tx_buffer[BLE_NUS_MAX_DATA_LEN] = {0}; /* BLE text transmission buffer */ +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] = {0}; /* BLE binary transmission buffer (word units) */ which_cmd_t cmd_type_t; /* Current command source (CMD_BLE or CMD_UART) */ 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 -- */ 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 */ 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 HW_NO[HW_NO_LENGTH]; /* Hardware number (FDS stored/read) */ +char SERIAL_NO[SERIAL_NO_LENGTH] = {0}; /* Serial number (used as BLE device name) */ +char HW_NO[HW_NO_LENGTH] = {0}; /* Hardware number (FDS stored/read) */ bool bond_data_delete; /* Bond data delete request flag */ uint32_t m_life_cycle; /* Device life cycle counter */ 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); /* 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; /** diff --git a/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c b/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c index 0a73abb..5a3b36a 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c +++ b/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c @@ -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) */ static nrfx_spim_t m_spim = NRFX_SPIM_INSTANCE(3); -/* Echo capture buffer (module-level for external access) */ -static uint16_t m_echo_buffer[DR_ADC_ECHO_SAMPLES_MAX]; +/* IEC 62304 §5.5.3: zero-initialized for deterministic startup */ +static uint16_t m_echo_buffer[DR_ADC_ECHO_SAMPLES_MAX] = {0}; /*============================================================================== * 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 */ - 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; dr_adc_err_t err = dr_adc_delta_compress(ch_data->samples, ch_data->num_samples, diff --git a/project/ble_peripheral/ble_app_bladder_patch/measurement/imu/app_raw/app_raw.c b/project/ble_peripheral/ble_app_bladder_patch/measurement/imu/app_raw/app_raw.c index 6b3cbde..fab8a18 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/measurement/imu/app_raw/app_raw.c +++ b/project/ble_peripheral/ble_app_bladder_patch/measurement/imu/app_raw/app_raw.c @@ -63,7 +63,7 @@ static struct inv_imu_device icm_driver; /* 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)