diff --git a/project/ble_peripheral/ble_app_bladder_patch/command/cmd_table.c b/project/ble_peripheral/ble_app_bladder_patch/command/cmd_table.c index 9ddf330..62e687e 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/command/cmd_table.c +++ b/project/ble_peripheral/ble_app_bladder_patch/command/cmd_table.c @@ -41,7 +41,6 @@ static const CmdEntry m_cmd_table[] = { { "msn?", true, Cmd_msn }, { "mst?", true, Cmd_mst }, { "msp?", true, Cmd_msp }, - { "msi?", true, Cmd_msi }, /* D. Piezo ultrasound */ { "mpa?", true, Cmd_mpa }, diff --git a/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.c b/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.c index 0d2521e..b961e01 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.c +++ b/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.c @@ -4,7 +4,6 @@ * msn? -> rsn: battery ADC measurement * mso? -> rso: TMP235 temperature reading * msp? -> rsp: IMU 6-axis single read - * msi? -> rsi: IMU motion streaming start * all_sensors() bulk-measurement helper used by the mbb? handler *============================================================================*/ @@ -74,34 +73,6 @@ int Cmd_msp(const ParsedCmd *cmd) return 1; } -/*============================================================================== - * msi? -> rsi: IMU motion sensor streaming start - * - * Request: [TAG 4B "msi?"] [mode 1B] [CRC 2B] - * mode = 'c': continuous (repeats on timer) - * else : single shot (one read then auto stop) - * Response: rsi: + IMU data (sent from main timer callback) - *============================================================================*/ -int Cmd_msi(const ParsedCmd *cmd) -{ - hw_i2c_init_once(); - - motion_raw_data_enabled = true; - ble_got_new_data = false; - - if (cmd->data_len > 0 && (char)cmd->data[0] == 'c') - { - motion_data_once = false; - } - else - { - motion_data_once = true; - } - - main_timer_start(); - return 1; -} - /*============================================================================== * all_sensors() - Bulk-measurement helper for the mbb? handler * @@ -146,8 +117,10 @@ void all_sensors(void) info4 = false; - /* Assemble and transmit the rbb: packet */ - buf = ble_bin_buffer; + /* Assemble and transmit the rbb: packet (dedicated buffer to avoid + collision with ble_bin_buffer used by the async ADC state machine) */ + static uint8_t rbb_buf[20]; + buf = rbb_buf; buf[0] = 'r'; buf[1] = 'b'; buf[2] = 'b'; buf[3] = ':'; buf[4] = (uint8_t)(info_batt >> 8); buf[5] = (uint8_t)(info_batt & 0xFF); diff --git a/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.h b/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.h index 5a23976..254b9af 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.h +++ b/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.h @@ -9,8 +9,6 @@ int Cmd_msn(const ParsedCmd *cmd); /* msn? -> rsn: battery ADC measurement */ int Cmd_mst(const ParsedCmd *cmd); /* mst? -> rso: TMP235 with piezo power cycle */ int Cmd_msp(const ParsedCmd *cmd); /* msp? -> rsp: IMU 6-axis single read */ -int Cmd_msi(const ParsedCmd *cmd); /* msi? -> rsi: IMU streaming start */ - /* Helper for the mbb? handler: sequentially measures battery / IMU / temperature, then emits a single rbb: response. * Called from Cmd_mbb() in cmd_piezo.c. */ void all_sensors(void); diff --git a/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c b/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c index 5a3b36a..83898f9 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c +++ b/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c @@ -1377,7 +1377,11 @@ dr_adc_err_t maa_async_start(uint8_t freq_option, uint16_t delay_us, uint16_t nu { g_plat.log("[maa] maa_async_start: CH%u capture failed (%d)", ch, err); } - maa_async_send_completion(0xFFF0 | ch); + /* Clean up state only — do NOT send raa: here. + The caller (Cmd_maa / Cmd_mbb) sends the raa: error packet + to avoid duplicate raa: on the BLE link. */ + dr_piezo_power_off(); + g_maa_ctx.state = MAA_ASYNC_IDLE; return err; } }