diff --git a/src/command/cmd_common.c b/src/command/cmd_common.c index 447284a..2c29bd9 100644 --- a/src/command/cmd_common.c +++ b/src/command/cmd_common.c @@ -38,7 +38,7 @@ uint8_t cmd_next_echo_session(void) void cmd_reboot_after_response(void) { - k_msleep(100); + k_msleep(2000); sys_reboot(SYS_REBOOT_COLD); } diff --git a/src/command/handlers/cmd_device.c b/src/command/handlers/cmd_device.c index 8193e57..270cd5f 100644 --- a/src/command/handlers/cmd_device.c +++ b/src/command/handlers/cmd_device.c @@ -107,7 +107,6 @@ int cmd_msr(const uint8_t *data, uint8_t data_len) if (status == 0x0000) { DBG_PRINTF("[CMD] msr complete -> production done, reboot\r\n"); - k_msleep(1500); } cmd_reboot_after_response(); diff --git a/src/drivers/led/led_control.c b/src/drivers/led/led_control.c index 29bec82..1ce96a5 100644 --- a/src/drivers/led/led_control.c +++ b/src/drivers/led/led_control.c @@ -46,7 +46,8 @@ static const led_pattern_t m_patterns[LED_STATE_COUNT] = { [LED_STATE_ALIGN_SEARCHING] = { 1000, 1000, COLOR_ORANGE, true }, [LED_STATE_ALIGN_COMPLETE] = { 0, 0, COLOR_GREEN, false }, [LED_STATE_ERROR] = { 0, 0, COLOR_ORANGE, true }, - [LED_STATE_BOND_DELETE] = { 0, 0, COLOR_ORANGE, false }, + [LED_STATE_BOND_DELETE] = { 1000, 0, COLOR_ORANGE, false }, + [LED_STATE_BOND_DELETE_PENDING] = { 500, 500, COLOR_ORANGE, true }, }; /* Module variables */ diff --git a/src/drivers/led/led_control.h b/src/drivers/led/led_control.h index 915910e..7dbe118 100644 --- a/src/drivers/led/led_control.h +++ b/src/drivers/led/led_control.h @@ -24,6 +24,7 @@ typedef enum LED_STATE_ALIGN_COMPLETE, // 6: Green ON LED_STATE_ERROR, // 7: Orange 3Hz x3 / 1s off LED_STATE_BOND_DELETE, // Bond Delete: Orange on + LED_STATE_BOND_DELETE_PENDING, // Bond Delete Pending: Orange blink 500ms/500ms LED_STATE_COUNT } led_state_t; diff --git a/src/power/power_control.c b/src/power/power_control.c index 7733587..858d2b0 100644 --- a/src/power/power_control.c +++ b/src/power/power_control.c @@ -22,7 +22,7 @@ #define POWER_LOOP_INTERVAL 20 // 전원 시퀀스 타이머 간격(ms) #define POWER_ON_THRESHOLD 220 // power button hold threshold(off -> on) #define POWER_OFF_THRESHOLD 333 // power button hold threshold(on -> off) -#define BOND_RESET_NOTICE_THRESHOLD (5000 / POWER_ON_DELAY) // 5s long press bond reset notice +#define BOND_RESET_NOTICE_THRESHOLD (10000 / POWER_ON_DELAY) // 10s long press bond reset notice #define BOND_RESET_THRESHOLD (15000 / POWER_ON_DELAY) // 15s long press bond reset static const struct gpio_dt_spec power_hold = GPIO_DT_SPEC_GET(POWER_HOLD_NODE, gpios); // 전원 유지 출력 @@ -43,6 +43,7 @@ static bool boot_btn_released; // 부팅 후 버튼을 static bool power_btn_suspended; // 측정 중 버튼 상태머신 일시 정지 static const char *power_off_pending_reason = "none"; // 예약된 전원 OFF 사유 static bool bond_reset_pending; // 본드 삭제 work 중복 예약 방지 +static bool bond_reset_notice; // bond reset notice LED active static uint8_t p_order; // 전원 시퀀스 단계 static bool lock_check = false; // power sequence lock flag @@ -94,8 +95,9 @@ static void bond_reset_work_handler(struct k_work *work) DBG_PRINTF("[BTN] BLE bond delete skipped (BT_SMP disabled)\r\n"); #endif + k_work_cancel_delayable(&power_on_complete_work); led_set_state(LED_STATE_BOND_DELETE); - k_msleep(1500); + k_msleep(2000); sys_reboot(SYS_REBOOT_COLD); } @@ -113,6 +115,8 @@ void power_control_reset_state(void) boot_btn_released = false; power_btn_suspended = false; bond_reset_pending = false; + bond_reset_notice = false; + k_work_cancel_delayable(&power_on_complete_work); power_off_pending_reason = "none"; } @@ -186,6 +190,8 @@ void device_power_keep_on(void) device_on = true; boot_btn_released = (gpio_pin_get_dt(&power_btn) != 1); cnt_s = 0; + bond_reset_notice = false; + k_work_cancel_delayable(&power_on_complete_work); power_control_handler(ON, "keep-on"); } @@ -194,6 +200,8 @@ void power_button_suspend(bool suspend) { power_btn_suspended = suspend; cnt_s = 0; + bond_reset_notice = false; + k_work_cancel_delayable(&power_on_complete_work); } /* 전원 버튼 상태머신 */ @@ -218,6 +226,7 @@ static void main_s(struct k_timer *timer) { power_control_handler(OFF, "boot-button-released-before-latch"); cnt_s = 0; + bond_reset_notice = false; } else { @@ -227,10 +236,9 @@ static void main_s(struct k_timer *timer) { device_on = true; power_control_handler(ON, "button-2s-latch"); - led_set_state(LED_STATE_ADVERTISING); - k_work_submit(&adv_start_work); - battery_timer_start(); - m_reset_status = 1; + bond_reset_notice = false; + led_set_state(LED_STATE_POWER_ON); + k_work_schedule(&power_on_complete_work, K_MSEC(2000)); } } } @@ -243,11 +251,22 @@ static void main_s(struct k_timer *timer) { boot_btn_released = true; cnt_s = 0; + if (bond_reset_notice) + { + bond_reset_notice = false; + led_set_state(LED_STATE_ADVERTISING); + } } else { cnt_s++; + if ((cnt_s >= BOND_RESET_NOTICE_THRESHOLD) && !bond_reset_notice) + { + bond_reset_notice = true; + led_set_state(LED_STATE_BOND_DELETE_PENDING); + } + if ((cnt_s >= BOND_RESET_THRESHOLD) && !bond_reset_pending) // 부팅 버튼 15초 유지 시 본드 삭제 { bond_reset_pending = true; @@ -263,10 +282,12 @@ static void main_s(struct k_timer *timer) if (cnt_s >= POWER_OFF_THRESHOLD) { battery_timer_stop(); + k_work_cancel_delayable(&power_on_complete_work); k_work_submit(&adv_stop_work); device_on = false; boot_btn_released = false; cnt_s = 0; + bond_reset_notice = false; sleep_mode_enter_reason("button-long-press"); return; } @@ -386,9 +407,8 @@ void power_control_resume_after_reset(uint32_t reset_reason) m_reset_status = 1; power_control_handler(ON, "resume-after-reset"); - led_set_state(LED_STATE_ADVERTISING); - battery_timer_start(); - k_work_submit(&adv_start_work); + led_set_state(LED_STATE_POWER_ON); + k_work_schedule(&power_on_complete_work, K_MSEC(2000)); DBG_CORE("[BOOT] Resume after resetreas=0x%08x\r\n", reset_reason); } \ No newline at end of file