fix(posture): rsp: 응답 (msp 명령 응답) 파싱 추가 — 자세 분류 작동

증상: PiezoMonitoring 진입 시 자세 아이콘이 항상 ?_ (UNKNOWN) 만 뜸.

원인: sendImuQuery() 가 보내는 msp 명령은 rsp: 응답을 받는데, 기존 코드는
      rim: (mtb alignment 응답) 만 imuCollector.parseRim() 으로 처리.
      rsp: 는 onImuReceived callback 으로만 가는데 어디서도 set 안 됨
      (dead callback) → 자세 분류기에 sample 절대 도달 못 함 → UNKNOWN.

수정:
  1) ImuPacketCollector.parseRsp() 신규
     rsp: format spec 미확정이라 defensive parsing 으로 두 변형 시도:
     - 변형 1 (multi-sample): rim: 와 동일 [tag 4B][num 2B][N×12B][crc 2B]
     - 변형 2 (single sample): [tag 4B][12B sample][crc 2B] = 18B
     실패 시 hex dump 로그 출력 (다음 디버깅용)
     성공 시 imuCollector.onComplete 정상 호출 → 분류기 작동.

  2) BleManager rsp: 핸들러
     - parseRsp() 라우팅
     - rx 로그에 hex 추가 (실제 format 확인용)

기존 rim: 처리는 그대로 (alignment 모드 영향 없음).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 14:06:40 +09:00
parent cf476971a5
commit 1774681a18
2 changed files with 77 additions and 3 deletions
@@ -1209,9 +1209,10 @@ class BleManager private constructor(private val context: Context) {
piezoCollector.addPacket(data)
}
"rsp:" -> {
if (data.size >= 16) {
debugLogger.rx("rsp", data.size, "IMU data")
}
// msp 명령 응답 — IMU 데이터. format 불명확이라 defensive parsing.
val hex = data.take(kotlin.math.min(data.size, 24)).joinToString(" ") { "%02X".format(it) }
debugLogger.rx("rsp", data.size, "IMU data hex=$hex")
imuCollector.parseRsp(data)
onImuReceived?.invoke(data)
}
"rim:" -> {