본딩 정보 삭제 후 재부팅 msr? 응답 로직 수정

- msr? 수신 시 rsr: 응답 후 disconnect
- 버튼 본딩 정보 삭제 후 재부팅 로직과 동일하게 주황 LED 2초 표시 후 재부팅
This commit is contained in:
2026-08-05 13:55:29 +09:00
parent 36fa5c6b35
commit 2e3fca2f80
+28 -28
View File
@@ -4,6 +4,7 @@
******************************************************************************/ ******************************************************************************/
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/sys/util.h> #include <zephyr/sys/util.h>
#include <zephyr/sys/reboot.h>
#if IS_ENABLED(CONFIG_BT_SMP) #if IS_ENABLED(CONFIG_BT_SMP)
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h> #include <zephyr/bluetooth/conn.h>
@@ -65,38 +66,15 @@ int cmd_msr(const uint8_t *data, uint8_t data_len)
ARG_UNUSED(data); ARG_UNUSED(data);
ARG_UNUSED(data_len); ARG_UNUSED(data_len);
#if IS_ENABLED(CONFIG_BT_SMP) int nvs_err = app_nvs_save_production_done(1U);
int err = bt_unpair(BT_ID_DEFAULT, NULL); if (nvs_err)
if (err)
{ {
status = (uint16_t)(-err); status = (uint16_t)(-nvs_err);
DBG_ERR("[CMD] msr bt_unpair failed err=%d\r\n", err); DBG_ERR("[CMD] msr production_done save failed err=%d\r\n", nvs_err);
} }
else else
{ {
led_set_state(LED_STATE_BOND_DELETE); m_production_done = 1U;
bond_data_delete = true;
ble_pairing_window_mark_reset_open();
DBG_PRINTF("[CMD] msr bond data deleted\r\n");
}
#else
bond_data_delete = true;
ble_pairing_window_mark_reset_open();
DBG_PRINTF("[CMD] msr bond delete skipped (BT_SMP disabled)\r\n");
#endif
if (status == 0x0000)
{
int nvs_err = app_nvs_save_production_done(1U);
if (nvs_err)
{
status = (uint16_t)(-nvs_err);
DBG_ERR("[CMD] msr production_done save failed err=%d\r\n", nvs_err);
}
else
{
m_production_done = 1U;
}
} }
int tx_err = cmd_send_response_u16("rsr:", status); int tx_err = cmd_send_response_u16("rsr:", status);
@@ -108,7 +86,29 @@ int cmd_msr(const uint8_t *data, uint8_t data_len)
if (status == 0x0000) if (status == 0x0000)
{ {
led_set_state(LED_STATE_BOND_DELETE);
k_msleep(2000);
bond_data_delete = true;
ble_pairing_window_mark_reset_open();
ble_advertising_restart_suspend(true);
#if IS_ENABLED(CONFIG_BT_SMP)
int err = bt_unpair(BT_ID_DEFAULT, NULL);
if (err)
{
DBG_ERR("[CMD] msr bt_unpair failed err=%d\r\n", err);
}
else
{
DBG_PRINTF("[CMD] msr bond data deleted\r\n");
}
#else
DBG_PRINTF("[CMD] msr bond delete skipped (BT_SMP disabled)\r\n");
#endif
DBG_PRINTF("[CMD] msr complete -> production done, reboot\r\n"); DBG_PRINTF("[CMD] msr complete -> production done, reboot\r\n");
sys_reboot(SYS_REBOOT_COLD);
} }
cmd_reboot_after_response(); cmd_reboot_after_response();