본딩 정보 삭제 및 재부팅 LED 변경

- 전원이 꺼진 상태에서 전원 버튼을 10초 이상 누르는 경우 본딩 삭제 모드 진입 : 주황색 LED 0.5초 간격 점멸
- 전원이 꺼진 상태에서 전원 버튼을 15초 이상 누르는 경우 본딩 삭제 : 주황색 LED 2초 점등 후 소등
- 본딩 삭제 완료 후 재부팅 시 : 초록색 LED 2초 점등 후 BLE 광고 초록색 LED 0.5초 간격 점멸
This commit is contained in:
2026-08-03 14:20:05 +09:00
parent 3d305b6270
commit b54c9d48ce
5 changed files with 33 additions and 12 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ uint8_t cmd_next_echo_session(void)
void cmd_reboot_after_response(void) void cmd_reboot_after_response(void)
{ {
k_msleep(100); k_msleep(2000);
sys_reboot(SYS_REBOOT_COLD); sys_reboot(SYS_REBOOT_COLD);
} }
-1
View File
@@ -107,7 +107,6 @@ int cmd_msr(const uint8_t *data, uint8_t data_len)
if (status == 0x0000) if (status == 0x0000)
{ {
DBG_PRINTF("[CMD] msr complete -> production done, reboot\r\n"); DBG_PRINTF("[CMD] msr complete -> production done, reboot\r\n");
k_msleep(1500);
} }
cmd_reboot_after_response(); cmd_reboot_after_response();
+2 -1
View File
@@ -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_SEARCHING] = { 1000, 1000, COLOR_ORANGE, true },
[LED_STATE_ALIGN_COMPLETE] = { 0, 0, COLOR_GREEN, false }, [LED_STATE_ALIGN_COMPLETE] = { 0, 0, COLOR_GREEN, false },
[LED_STATE_ERROR] = { 0, 0, COLOR_ORANGE, true }, [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 */ /* Module variables */
+1
View File
@@ -24,6 +24,7 @@ typedef enum
LED_STATE_ALIGN_COMPLETE, // 6: Green ON LED_STATE_ALIGN_COMPLETE, // 6: Green ON
LED_STATE_ERROR, // 7: Orange 3Hz x3 / 1s off LED_STATE_ERROR, // 7: Orange 3Hz x3 / 1s off
LED_STATE_BOND_DELETE, // Bond Delete: Orange on 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_COUNT
} led_state_t; } led_state_t;
+29 -9
View File
@@ -22,7 +22,7 @@
#define POWER_LOOP_INTERVAL 20 // 전원 시퀀스 타이머 간격(ms) #define POWER_LOOP_INTERVAL 20 // 전원 시퀀스 타이머 간격(ms)
#define POWER_ON_THRESHOLD 220 // power button hold threshold(off -> on) #define POWER_ON_THRESHOLD 220 // power button hold threshold(off -> on)
#define POWER_OFF_THRESHOLD 333 // power button hold threshold(on -> off) #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 #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); // 전원 유지 출력 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 bool power_btn_suspended; // 측정 중 버튼 상태머신 일시 정지
static const char *power_off_pending_reason = "none"; // 예약된 전원 OFF 사유 static const char *power_off_pending_reason = "none"; // 예약된 전원 OFF 사유
static bool bond_reset_pending; // 본드 삭제 work 중복 예약 방지 static bool bond_reset_pending; // 본드 삭제 work 중복 예약 방지
static bool bond_reset_notice; // bond reset notice LED active
static uint8_t p_order; // 전원 시퀀스 단계 static uint8_t p_order; // 전원 시퀀스 단계
static bool lock_check = false; // power sequence lock flag 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"); DBG_PRINTF("[BTN] BLE bond delete skipped (BT_SMP disabled)\r\n");
#endif #endif
k_work_cancel_delayable(&power_on_complete_work);
led_set_state(LED_STATE_BOND_DELETE); led_set_state(LED_STATE_BOND_DELETE);
k_msleep(1500); k_msleep(2000);
sys_reboot(SYS_REBOOT_COLD); sys_reboot(SYS_REBOOT_COLD);
} }
@@ -113,6 +115,8 @@ void power_control_reset_state(void)
boot_btn_released = false; boot_btn_released = false;
power_btn_suspended = false; power_btn_suspended = false;
bond_reset_pending = false; bond_reset_pending = false;
bond_reset_notice = false;
k_work_cancel_delayable(&power_on_complete_work);
power_off_pending_reason = "none"; power_off_pending_reason = "none";
} }
@@ -186,6 +190,8 @@ void device_power_keep_on(void)
device_on = true; device_on = true;
boot_btn_released = (gpio_pin_get_dt(&power_btn) != 1); boot_btn_released = (gpio_pin_get_dt(&power_btn) != 1);
cnt_s = 0; cnt_s = 0;
bond_reset_notice = false;
k_work_cancel_delayable(&power_on_complete_work);
power_control_handler(ON, "keep-on"); power_control_handler(ON, "keep-on");
} }
@@ -194,6 +200,8 @@ void power_button_suspend(bool suspend)
{ {
power_btn_suspended = suspend; power_btn_suspended = suspend;
cnt_s = 0; 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"); power_control_handler(OFF, "boot-button-released-before-latch");
cnt_s = 0; cnt_s = 0;
bond_reset_notice = false;
} }
else else
{ {
@@ -227,10 +236,9 @@ static void main_s(struct k_timer *timer)
{ {
device_on = true; device_on = true;
power_control_handler(ON, "button-2s-latch"); power_control_handler(ON, "button-2s-latch");
led_set_state(LED_STATE_ADVERTISING); bond_reset_notice = false;
k_work_submit(&adv_start_work); led_set_state(LED_STATE_POWER_ON);
battery_timer_start(); k_work_schedule(&power_on_complete_work, K_MSEC(2000));
m_reset_status = 1;
} }
} }
} }
@@ -243,11 +251,22 @@ static void main_s(struct k_timer *timer)
{ {
boot_btn_released = true; boot_btn_released = true;
cnt_s = 0; cnt_s = 0;
if (bond_reset_notice)
{
bond_reset_notice = false;
led_set_state(LED_STATE_ADVERTISING);
}
} }
else else
{ {
cnt_s++; 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초 유지 시 본드 삭제 if ((cnt_s >= BOND_RESET_THRESHOLD) && !bond_reset_pending) // 부팅 버튼 15초 유지 시 본드 삭제
{ {
bond_reset_pending = true; bond_reset_pending = true;
@@ -263,10 +282,12 @@ static void main_s(struct k_timer *timer)
if (cnt_s >= POWER_OFF_THRESHOLD) if (cnt_s >= POWER_OFF_THRESHOLD)
{ {
battery_timer_stop(); battery_timer_stop();
k_work_cancel_delayable(&power_on_complete_work);
k_work_submit(&adv_stop_work); k_work_submit(&adv_stop_work);
device_on = false; device_on = false;
boot_btn_released = false; boot_btn_released = false;
cnt_s = 0; cnt_s = 0;
bond_reset_notice = false;
sleep_mode_enter_reason("button-long-press"); sleep_mode_enter_reason("button-long-press");
return; return;
} }
@@ -386,9 +407,8 @@ void power_control_resume_after_reset(uint32_t reset_reason)
m_reset_status = 1; m_reset_status = 1;
power_control_handler(ON, "resume-after-reset"); power_control_handler(ON, "resume-after-reset");
led_set_state(LED_STATE_ADVERTISING); led_set_state(LED_STATE_POWER_ON);
battery_timer_start(); k_work_schedule(&power_on_complete_work, K_MSEC(2000));
k_work_submit(&adv_start_work);
DBG_CORE("[BOOT] Resume after resetreas=0x%08x\r\n", reset_reason); DBG_CORE("[BOOT] Resume after resetreas=0x%08x\r\n", reset_reason);
} }