DFU 커맨드
This commit is contained in:
+47
-4
@@ -747,6 +747,19 @@ static int cmd_msr(const uint8_t *data, uint8_t data_len)
|
||||
ARG_UNUSED(data);
|
||||
ARG_UNUSED(data_len);
|
||||
|
||||
int tx_err = send_response_u16("rsr:", status);
|
||||
if (tx_err)
|
||||
{
|
||||
DBG_ERR("[CMD] msr tx failed err=%d\r\n", tx_err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* 현재 연결의 bond/security 정보를 먼저 지우면 같은 연결에서 rsr: 응답을
|
||||
* 보낼 수 없다. 응답 전송 완료 후 bond 삭제와 reboot를 진행한다.
|
||||
*/
|
||||
k_msleep(100);
|
||||
|
||||
#if IS_ENABLED(CONFIG_BT_SMP)
|
||||
int err = bt_unpair(BT_ID_DEFAULT, NULL);
|
||||
if (err)
|
||||
@@ -764,16 +777,45 @@ static int cmd_msr(const uint8_t *data, uint8_t data_len)
|
||||
DBG_PRINTF("[CMD] msr bond delete skipped (BT_SMP disabled)\r\n");
|
||||
#endif
|
||||
|
||||
int tx_err = send_response_u16("rsr:", status);
|
||||
if (status == 0x0000)
|
||||
{
|
||||
DBG_PRINTF("[CMD] msr complete\r\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* msp? → IMU 1회 측정 → rsp: + accel XYZ + gyro XYZ (각 int16 빅엔디안) */
|
||||
static int cmd_mdf(const uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
ARG_UNUSED(data);
|
||||
ARG_UNUSED(data_len);
|
||||
|
||||
uint16_t status = ble_dfu_advertising_is_enabled() ? 0xFFFF : 0x0000;
|
||||
|
||||
/* DFU advertising 전환 중 연결이 끊겨도 전원 래치가 유지되도록 먼저 ON 상태를 확정한다. */
|
||||
device_power_keep_on();
|
||||
|
||||
int tx_err = send_response_u16("rdf:", status);
|
||||
if (tx_err)
|
||||
{
|
||||
DBG_ERR("[CMD] msr tx failed err=%d\r\n", tx_err);
|
||||
DBG_ERR("[CMD] mdf tx failed err=%d\r\n", tx_err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (status == 0x0000)
|
||||
{
|
||||
DBG_PRINTF("[CMD] msr -> reboot\r\n");
|
||||
reboot_after_response();
|
||||
/* rdf: 응답이 나간 뒤 연결 해제와 SMP 광고 전환 실행 */
|
||||
k_msleep(100);
|
||||
int err = ble_dfu_advertising_enable();
|
||||
if (err)
|
||||
{
|
||||
DBG_ERR("[CMD] mdf enable failed err=%d\r\n", err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_PRINTF("[CMD] mdf rejected: already in DFU advertising\r\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -1504,6 +1546,7 @@ static const cmd_entry_t cmd_table[] =
|
||||
{ "msq?", cmd_msq },
|
||||
{ "mss?", cmd_mss },
|
||||
{ "msr?", cmd_msr },
|
||||
{ "mdf?", cmd_mdf },
|
||||
{ "msn?", cmd_msn },
|
||||
{ "mls?", cmd_mls },
|
||||
{ "msp?", cmd_msp },
|
||||
|
||||
Reference in New Issue
Block a user