생산 전용 완료 커맨드 추가(mpd?)
- 본딩 정보 삭제 및 재부팅 + 생산 완료 플래그 설정
This commit is contained in:
@@ -13,6 +13,7 @@ const cmd_entry_t cmd_table[] =
|
||||
{ "msq?", cmd_msq },
|
||||
{ "mss?", cmd_mss },
|
||||
{ "msr?", cmd_msr },
|
||||
{ "mpd?", cmd_mpd },
|
||||
{ "mdf?", cmd_mdf },
|
||||
{ "msn?", cmd_msn },
|
||||
{ "mls?", cmd_mls },
|
||||
|
||||
@@ -18,6 +18,32 @@
|
||||
#include "cmd_device.h"
|
||||
#include "led_control.h"
|
||||
|
||||
static void cmd_clear_bonds_and_reboot(const char *cmd_name)
|
||||
{
|
||||
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] %s bt_unpair failed err=%d\r\n", cmd_name, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_PRINTF("[CMD] %s bond data deleted\r\n", cmd_name);
|
||||
}
|
||||
#else
|
||||
DBG_PRINTF("[CMD] %s bond delete skipped (BT_SMP disabled)\r\n", cmd_name);
|
||||
#endif
|
||||
|
||||
DBG_PRINTF("[CMD] %s complete -> bond reset, reboot\r\n", cmd_name);
|
||||
sys_reboot(SYS_REBOOT_COLD);
|
||||
}
|
||||
/*
|
||||
* msq: power off
|
||||
*/
|
||||
@@ -66,17 +92,6 @@ int cmd_msr(const uint8_t *data, uint8_t data_len)
|
||||
ARG_UNUSED(data);
|
||||
ARG_UNUSED(data_len);
|
||||
|
||||
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);
|
||||
if (tx_err)
|
||||
{
|
||||
@@ -86,34 +101,49 @@ int cmd_msr(const uint8_t *data, uint8_t data_len)
|
||||
|
||||
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");
|
||||
sys_reboot(SYS_REBOOT_COLD);
|
||||
cmd_clear_bonds_and_reboot("msr");
|
||||
}
|
||||
|
||||
cmd_reboot_after_response();
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
* mpd: set production done flag
|
||||
*/
|
||||
int cmd_mpd(const uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
uint16_t status = 0x0000;
|
||||
|
||||
ARG_UNUSED(data);
|
||||
ARG_UNUSED(data_len);
|
||||
|
||||
int nvs_err = app_nvs_save_production_done(1U);
|
||||
if (nvs_err)
|
||||
{
|
||||
status = (uint16_t)(-nvs_err);
|
||||
DBG_ERR("[CMD] mpd production_done save failed err=%d\r\n", nvs_err);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_production_done = 1U;
|
||||
DBG_PRINTF("[CMD] mpd -> production done\r\n");
|
||||
}
|
||||
|
||||
int tx_err = cmd_send_response_u16("rpd:", status);
|
||||
if (tx_err)
|
||||
{
|
||||
DBG_ERR("[CMD] mpd tx failed err=%d\r\n", tx_err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (status == 0x0000)
|
||||
{
|
||||
cmd_clear_bonds_and_reboot("mpd");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* mdf: DFU mode enter
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
int cmd_msq(const uint8_t *data, uint8_t data_len);
|
||||
int cmd_mss(const uint8_t *data, uint8_t data_len);
|
||||
int cmd_msr(const uint8_t *data, uint8_t data_len);
|
||||
int cmd_mpd(const uint8_t *data, uint8_t data_len);
|
||||
int cmd_mdf(const uint8_t *data, uint8_t data_len);
|
||||
|
||||
#endif /* CMD_DEVICE_H__ */
|
||||
|
||||
Reference in New Issue
Block a user