From 39cf6068f7683f71a92726bc8fb1622bc865853e Mon Sep 17 00:00:00 2001 From: jhchun Date: Fri, 26 Jun 2026 17:21:41 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ble_app_bladder_patch/main.c | 35 ++++++++++--------- .../ble_app_bladder_patch/main.h | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/project/ble_peripheral/ble_app_bladder_patch/main.c b/project/ble_peripheral/ble_app_bladder_patch/main.c index 0a9756f..74a5530 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/main.c +++ b/project/ble_peripheral/ble_app_bladder_patch/main.c @@ -231,7 +231,7 @@ static char * roles_str[] = {"INVALID_ROLE", "CENTRAL", "PERIPHERAL"}; /*============================================================================== * Global Variables - * IEC 62304 ยง5.5.3: all global buffers zero-initialized for deterministic startup + * IEC 62304 5.5.3: all global buffers zero-initialized for deterministic startup *============================================================================*/ volatile uint8_t Sj_type; /* Command type identifier */ bool power_off_duble_prohibit = false; /* Power-off double prevention flag */ @@ -1546,7 +1546,7 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) DBG_PRINTF("[BLE] Connected\r\n"); #if BLE_DEV_MODE - /* Dev: no passkey/SEC โ€” allow NUS TX/RX as soon as GAP is up (prod uses PM_EVT_CONN_SEC_SUCCEEDED). */ + /* Dev: no passkey/SEC - allow NUS TX/RX as soon as GAP is up (prod uses PM_EVT_CONN_SEC_SUCCEEDED). */ ble_connection_st = BLE_CONNECTED_ST; battery_timer_start(); #endif @@ -2077,6 +2077,7 @@ static void main_s(void * p_context) bool button_released = nrf_gpio_pin_read(POWER_BUTTON); + /* ---- Running phase: post-boot button polling ---- */ if (booted) { @@ -2121,7 +2122,7 @@ static void main_s(void * p_context) go_device_power_off = true; main_timer_start(); } - else if (cnt_s > 250 || (m_reset_status == 2)) /* 250 x 5ms = 1.25s + ฮฑ */ + else if (cnt_s > 250 || (m_reset_status == 2)) /* 250 x 5ms = 1.25s + ฅแ */ { DBG_PRINTF("[BTN] Boot (cnt=%d)\r\n", cnt_s); device_reset = false; @@ -2150,7 +2151,7 @@ static void main_s(void * p_context) cnt_s++; device_reset = false; - if (cnt_s == 250) /* 250 x 5ms = 1.25s + ฮฑ */ + if (cnt_s == 250) /* 250 x 5ms = 1.25s + ฅแ */ { led_set_state(LED_STATE_POWER_ON); DBG_PRINTF("[BTN] 2.0s\r\n"); @@ -2171,7 +2172,7 @@ int main(void) { bool erase_bonds_local = false; - /*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + /*-------------------------------------------------------------------------- * Phase 1: Basic hardware init (BLE-independent) * * - Power self-latch (P0.8 HIGH) @@ -2180,7 +2181,7 @@ int main(void) * - App timers (power polling, battery, main loop) * - Default config (serial number, passkey) * - Buttons/LEDs - *โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ + *--------------------------------------------------------------------------*/ power_hold_init(); if ((NRF_POWER->GPREGRET2 & POST_DFU_APP_BOOT_GPREGRET2_MASK) != 0) @@ -2203,7 +2204,7 @@ int main(void) log_init(); DBG_PRINTF("\r\n========================================\r\n"); - DBG_PRINTF(" Medithings v1.17\r\n"); + DBG_PRINTF(" Medithings VesiScan-Basic\r\n"); DBG_PRINTF("========================================\r\n"); DBG_PRINTF("[1] HW Init\r\n"); @@ -2217,33 +2218,33 @@ int main(void) #endif DBG_PRINTF(" gpio/timer/config/btn OK\r\n"); - /*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + /*-------------------------------------------------------------------------- * Phase 2: BLE stack init * * - Power management module (WFE/sleep when idle) * - SoftDevice S140 (BLE 5.0 protocol stack) * - DC-DC converter enable (required after SoftDevice) - *โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ + *--------------------------------------------------------------------------*/ DBG_PRINTF("[2] BLE Stack\r\n"); power_management_init(); ble_stack_init(); APP_ERROR_CHECK(sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE)); DBG_PRINTF(" pwr/stack/dcdc OK\r\n"); - /*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + /*-------------------------------------------------------------------------- * Phase 3: Internal flash config (must init after BLE stack) * * - FDS (Flash Data Storage) init * - Read stored config from flash (serial, passkey, piezo, etc.) * - Overwrite defaults with flash values - *โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ + *--------------------------------------------------------------------------*/ DBG_PRINTF("[3] FDS\r\n"); fs_storage_init(); config_load(); load_flash_config(); DBG_PRINTF(" fds OK\r\n"); - /*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + /*-------------------------------------------------------------------------- * Phase 4: BLE protocol setup * * - GAP: device name (serial number), connection params, passkey @@ -2252,7 +2253,7 @@ int main(void) * - Advertising: advertising data (name, UUID) * - Connection parameter negotiation module * - Security: Peer Manager (bonding/passkey) - *โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ + *--------------------------------------------------------------------------*/ DBG_PRINTF("[4] BLE Protocol\r\n"); gap_params_init(); gatt_init(); @@ -2287,14 +2288,14 @@ int main(void) DBG_PRINTF(" fds defaults saved\r\n"); } - /*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + /*-------------------------------------------------------------------------- * Phase 5: Application init * * - Command parser: process BLE received commands (log, BLE TX, CRC) * - Piezo driver: GPIO/Timer/PPI setup for ultrasound measurement * - IMU (ICM42670P) is NOT initialized here * -> imu_read_direct() self-configures/reads/sleeps on each msp? command - *โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ + *--------------------------------------------------------------------------*/ DBG_PRINTF("[5] App\r\n"); g_plat.log = log_printf; g_plat.tx_bin = dr_binary_tx_safe; @@ -2304,9 +2305,9 @@ int main(void) dr_piezo_init(); DBG_PRINTF(" parser/piezo OK\r\n"); - /*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + /*-------------------------------------------------------------------------- * Boot complete -> start power button state machine - *โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*/ + *--------------------------------------------------------------------------*/ DBG_PRINTF("\r\n========================================\r\n"); DBG_PRINTF(" READY [%s]\r\n", SERIAL_NO); DBG_PRINTF("========================================\r\n\r\n"); diff --git a/project/ble_peripheral/ble_app_bladder_patch/main.h b/project/ble_peripheral/ble_app_bladder_patch/main.h index 992d2c1..7be5a8f 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/main.h +++ b/project/ble_peripheral/ble_app_bladder_patch/main.h @@ -53,7 +53,7 @@ * : Unify both IMU direct-read and FIFO outputs as raw data in datasheet axis convention. * - VBTFW0120 260615 jhChun : Add EMC mitigation logic for BLE link stability: extended supervision timeout and dynamic TX power control based on RSSI, RSSI silence, HVN latency, and TX queue congestion. ------------------------------------------------------------------------- */ -#define FIRMWARE_VERSION "VBTFW0129" +#define FIRMWARE_VERSION "VBTFW0120" /*============================================================================== * Data Length Constants