From 6707a8d3df4b7eb9b9d3cc637d3aee4a7992752b Mon Sep 17 00:00:00 2001 From: jhchun Date: Fri, 12 Jun 2026 17:34:12 +0900 Subject: [PATCH] =?UTF-8?q?mid=3F=20=EC=BB=A4=EB=A7=A8=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 디바이스 정보 전체 조회 --- src/parser.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/parser.c b/src/parser.c index 0e1bff0..5dd1bb0 100644 --- a/src/parser.c +++ b/src/parser.c @@ -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 },