mid? 커맨드 추가

- 디바이스 정보 전체 조회
This commit is contained in:
2026-06-12 17:34:12 +09:00
parent e04a7af6c9
commit 6707a8d3df
+40
View File
@@ -57,6 +57,7 @@ static uint8_t tx_echo_buf[4 + 2 + 2 + (ECHO_ADC_MAX_SAMPLES * 2) + 2];
static uint8_t tx_bundle_buf[22];
static uint8_t tx_cfg_buf[16];
static uint8_t tx_ascii_buf[4 + HW_NO_LENGTH + 2];
static uint8_t tx_id_buf[4 + HW_NO_LENGTH + SERIAL_NO_LENGTH + SERIAL_NO_LENGTH + 2];
static uint8_t tx_rim_samples[IMU_FIFO_RIM_TARGET_SAMPLES * IMU_FIFO_SAMPLE_BYTES];
static uint8_t tx_rim_buf[4 + 2 + (IMU_FIFO_RIM_TARGET_SAMPLES * IMU_FIFO_SAMPLE_BYTES) + 2];
static uint8_t g_echo_session;
@@ -224,6 +225,28 @@ static int send_response_ascii(const char *tag, const char *value, uint8_t value
return ble_data_send(buf, (uint16_t)(6U + value_len));
}
static int send_response_identity(void)
{
uint8_t *buf = tx_id_buf;
char fw_version[SERIAL_NO_LENGTH];
copy_fixed_ascii(fw_version, sizeof(fw_version), FIRMWARE_VERSION, strlen(FIRMWARE_VERSION));
buf[0] = 'r';
buf[1] = 'i';
buf[2] = 'd';
buf[3] = ':';
memcpy(&buf[4], HW_NO, HW_NO_LENGTH);
memcpy(&buf[4 + HW_NO_LENGTH], SERIAL_NO, SERIAL_NO_LENGTH);
memcpy(&buf[4 + HW_NO_LENGTH + SERIAL_NO_LENGTH], fw_version, sizeof(fw_version));
uint16_t crc = dr_crc16_compute(buf, (uint32_t)(sizeof(tx_id_buf) - 2U));
buf[sizeof(tx_id_buf) - 2U] = (uint8_t)(crc & 0xFF);
buf[sizeof(tx_id_buf) - 1U] = (uint8_t)(crc >> 8);
return ble_data_send(buf, sizeof(tx_id_buf));
}
static int send_response_tag_echo(const char *tag, const char *echo_tag)
{
uint8_t *buf = tx_ascii_buf;
@@ -1225,6 +1248,22 @@ static int cmd_mfv(const uint8_t *data, uint8_t data_len)
return 1;
}
static int cmd_mid(const uint8_t *data, uint8_t data_len)
{
int err;
ARG_UNUSED(data);
ARG_UNUSED(data_len);
err = send_response_identity();
if (err)
{
DBG_ERR("[CMD] mid tx failed err=%d\r\n", err);
}
DBG_PRINTF("[CMD] mid read\r\n");
return 1;
}
static int cmd_mwh(const uint8_t *data, uint8_t data_len)
{
if (data_len < HW_NO_LENGTH)
@@ -1394,6 +1433,7 @@ static const cmd_entry_t cmd_table[] =
{ "mtb?", cmd_mtb },
{ "mcf?", cmd_mcf },
{ "mcs?", cmd_mcs },
{ "mid?", cmd_mid },
{ "mfv?", cmd_mfv },
{ "mwh?", cmd_mwh },
{ "mrh?", cmd_mrh },