diff --git a/src/command/cmd_common.c b/src/command/cmd_common.c index 2c29bd9..d51e36b 100644 --- a/src/command/cmd_common.c +++ b/src/command/cmd_common.c @@ -30,6 +30,7 @@ static uint8_t g_echo_session; #define ECHO_SAMPLE_SIZE 2U #define RIM_OVERHEAD_SIZE 8U #define RIC_OVERHEAD_SIZE 12U +#define RIM_ERROR_SAMPLE_COUNT 0xFFFFU uint8_t cmd_next_echo_session(void) { @@ -463,6 +464,22 @@ void cmd_send_response_rim(const uint8_t *sample_bytes, uint16_t sample_count) cmd_send_response_rim_ric(sample_bytes, sample_count, samples_per_pkt); } +void cmd_send_response_rim_error(void) +{ + uint8_t *buf = tx_rim_buf; + + buf[0] = 'r'; buf[1] = 'i'; buf[2] = 'm'; buf[3] = ':'; + buf[4] = (uint8_t)(RIM_ERROR_SAMPLE_COUNT >> 8); + buf[5] = (uint8_t)(RIM_ERROR_SAMPLE_COUNT & 0xFF); + + uint16_t crc = cmd_crc16_compute(buf, 6U); + buf[6] = (uint8_t)(crc & 0xFF); + buf[7] = (uint8_t)(crc >> 8); + + DBG_PRINTF("[CMD] tx rim error=0x%04X len=8\r\n", RIM_ERROR_SAMPLE_COUNT); + ble_data_send(buf, 8U); +} + void cmd_send_response_piezo_config(const char *tag, uint16_t freq, uint16_t cycles, uint16_t avg, uint16_t delay_us, uint16_t samples) { uint8_t *buf = tx_cfg_buf; @@ -487,4 +504,4 @@ void cmd_send_response_piezo_config(const char *tag, uint16_t freq, uint16_t cyc buf[15] = (uint8_t)(crc >> 8); ble_data_send(buf, sizeof(tx_cfg_buf)); -} \ No newline at end of file +} diff --git a/src/command/cmd_common.h b/src/command/cmd_common.h index 8077868..2630364 100644 --- a/src/command/cmd_common.h +++ b/src/command/cmd_common.h @@ -27,6 +27,7 @@ int cmd_send_response_imu(const int16_t accel[3], const int16_t gyro[3]); void cmd_send_response_echo(uint8_t session, uint8_t channel, const uint16_t *samples, uint16_t num_samples); void cmd_send_response_bundle(uint16_t batt_mv, const int16_t accel[3], const int16_t gyro[3], int16_t temp_cdeg); void cmd_send_response_rim(const uint8_t *sample_bytes, uint16_t sample_count); +void cmd_send_response_rim_error(void); void cmd_send_response_piezo_config(const char *tag, uint16_t freq, uint16_t cycles, uint16_t avg, uint16_t delay_us, uint16_t samples); #endif /* CMD_COMMON_H__ */