fix(posture): 연결 중 ?_ 지속되던 두 원인 fix

원인 A — Auto Scan 켜져 있는 동안 mtb polling 영원 skip:
  isAutoMeasuring 가 Auto Scan 종료까지 계속 true → mtb 안 보냄 → IMU rim 응답 없음
  → currentPosture 갱신 멈춤 → UNKNOWN 표시 지속.
변경: polling 조건에서 isAutoMeasuring 제거. !isMeasuring 만 검사 →
      Auto Scan 의 cycle 사이 idle 시간 (isMeasuring=false) 에는 mtb 가능.
      Spot 은 5회 연속이라 isSpotInProgress 유지 (충돌 회피).

원인 B — 다른 화면 다녀와도 imuCollector.onComplete cleanup 없어 stale callback 남음:
변경: DisposableEffect 로 onDispose 시 onComplete = null.
      다시 진입하면 LaunchedEffect 가 재등록.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-26 15:20:32 +09:00
parent de3a607f96
commit 618267d8c0
@@ -779,7 +779,11 @@ fun PiezoMonitoringView(appState: AppState) {
Log.d("ImuDbg", "imuCollector log: $msg") Log.d("ImuDbg", "imuCollector log: $msg")
} }
while (isActive) { while (isActive) {
if (isConnected && !isMeasuring && !isAutoMeasuring && !isSpotInProgress) { // Auto Scan 의 cycle 사이 idle 시간에도 polling 가능 — isAutoMeasuring 조건 제외.
// isMeasuring 은 현재 measure() 호출 중인 짧은 시간만 true → 사이 idle 에서 mtb 가능.
// isSpotInProgress 는 5회 연속 측정이라 분리 (충돌 회피).
// 이전: Auto Scan 켜두면 isAutoMeasuring=true 영원 유지 → mtb 영원 skip → posture UNKNOWN
if (isConnected && !isMeasuring && !isSpotInProgress) {
Log.d("ImuDbg", "→ sendMtb (posture poll)") Log.d("ImuDbg", "→ sendMtb (posture poll)")
bleManager.piezoCollector.skipNextComplete = true bleManager.piezoCollector.skipNextComplete = true
val sent = bleManager.sendMtb() val sent = bleManager.sendMtb()
@@ -788,12 +792,20 @@ fun PiezoMonitoringView(appState: AppState) {
Log.d("ImuDbg", "mtb throttled — skip this cycle") Log.d("ImuDbg", "mtb throttled — skip this cycle")
} }
} else { } else {
Log.d("ImuDbg", "skip (connected=$isConnected measuring=$isMeasuring auto=$isAutoMeasuring spot=$isSpotInProgress)") Log.d("ImuDbg", "skip (connected=$isConnected measuring=$isMeasuring spot=$isSpotInProgress)")
} }
kotlinx.coroutines.delay(GreenZoneConstants.posturePollIntervalMs) kotlinx.coroutines.delay(GreenZoneConstants.posturePollIntervalMs)
} }
} }
// PiezoMonitoring 이탈 시 imuCollector callback cleanup — 다른 화면 (PlacementGuide 등) 이
// 자기 콜백 등록하기 전에 우리 콜백 해제. 다시 진입하면 위 LaunchedEffect 가 재등록.
androidx.compose.runtime.DisposableEffect(Unit) {
onDispose {
bleManager.imuCollector.onComplete = null
}
}
// Add catheter dialog // Add catheter dialog
if (showAddCatheterDialog) { if (showAddCatheterDialog) {
var addAmount by remember { mutableStateOf("1") } var addAmount by remember { mutableStateOf("1") }