주기 측정 배터리/IMU/온도 측정 실패 시 BLE 응답 0xFFFF

- 실패하더라도 Piezo sweep은 계속됨
This commit is contained in:
2026-09-02 13:57:59 +09:00
parent a564c1400a
commit 2f9efac10d
+25 -6
View File
@@ -38,8 +38,8 @@ int cmd_mbb(const uint8_t *data, uint8_t data_len)
uint8_t session = cmd_next_echo_session();
int16_t accel[3];
int16_t gyro[3];
int16_t accel[3] = { (int16_t)0xFFFF, (int16_t)0xFFFF, (int16_t)0xFFFF };
int16_t gyro[3] = { (int16_t)0xFFFF, (int16_t)0xFFFF, (int16_t)0xFFFF };
processing = true;
DBG_PRINTF("[MBB] cmd start\r\n");
@@ -50,13 +50,29 @@ int cmd_mbb(const uint8_t *data, uint8_t data_len)
/* Read battery first (idle measurement) so mbb? result matches msn? */
DBG_PRINTF("[MBB] battery read (idle)\r\n");
batt_mv = battery_read_mv();
if (batt_mv < 0)
{
DBG_PRINTF("[MBB] battery read fail\r\n");
batt_mv = 0xFFFF;
}
int status = piezo_measure_start_session();
if (status == ECHO_STATUS_OK) // Piezo GPIO, power, ADC initialization/wake succeeded
{
DBG_PRINTF("[MBB] imu/temp read\r\n");
imu_read_with_temperature(accel, gyro, &temp_cdeg);
int imu_ret = imu_read_with_temperature(accel, gyro, &temp_cdeg);
if (imu_ret != 0)
{
DBG_PRINTF("[MBB] imu/temp read fail ret=%d\r\n", imu_ret);
accel[0] = (int16_t)0xFFFF;
accel[1] = (int16_t)0xFFFF;
accel[2] = (int16_t)0xFFFF;
gyro[0] = (int16_t)0xFFFF;
gyro[1] = (int16_t)0xFFFF;
gyro[2] = (int16_t)0xFFFF;
temp_cdeg = (int16_t)0xFFFF;
}
battery_protection_record_continuous(batt_mv, temp_cdeg); // update protection counters for continuous monitoring
@@ -240,8 +256,8 @@ int cmd_mim(const uint8_t *data, uint8_t data_len)
int imu_ret = imu_fifo_start();
if (imu_ret != 0)
{
DBG_PRINTF("[MTB] fifo start fail ret=%d\r\n", imu_ret);
cmd_send_response_rim(tx_rim_samples, 0U);
DBG_PRINTF("[MIM] fifo start fail ret=%d\r\n", imu_ret);
cmd_send_response_rim_error();
processing = false;
return 1;
}
@@ -252,7 +268,10 @@ int cmd_mim(const uint8_t *data, uint8_t data_len)
if (imu_ret != 0)
{
DBG_PRINTF("[MIM] fifo read fail ret=%d\r\n", imu_ret);
rim_count = 0U;
cmd_send_response_rim_error();
imu_fifo_stop();
processing = false;
return 1;
}
cmd_send_response_rim(tx_rim_samples, rim_count); // IMU FIFO 15 samples rim: 전송