fix: BLE 패킷 수신 메인스레드 의존 제거 + Auto 간격 1.5초

BLE:
- onCharacteristicChanged에서 handler.post 제거
- processReceivedData를 Binder 스레드에서 직접 실행
- 메인 스레드 큐 대기로 인한 reb 패킷 유실 방지

Auto:
- 최소 간격 1000ms → 1500ms (기기 연속 maa 채널 드롭 방지)
- 10개 × 1.5초 = ~15초마다 trimmed mean 업데이트

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-30 10:37:14 +09:00
parent 1a42fe6a07
commit 85162669e4
2 changed files with 4 additions and 4 deletions
@@ -807,7 +807,7 @@ class BleManager private constructor(private val context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (characteristic.uuid == RX_CHAR_UUID) { if (characteristic.uuid == RX_CHAR_UUID) {
if (value.size < 4) return if (value.size < 4) return
handler.post { processReceivedData(value) } processReceivedData(value)
} }
} }
} }
@@ -819,7 +819,7 @@ class BleManager private constructor(private val context: Context) {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
val data = characteristic.value ?: return val data = characteristic.value ?: return
if (data.size < 4) return if (data.size < 4) return
handler.post { processReceivedData(data) } processReceivedData(data)
} }
} }
} }
@@ -358,9 +358,9 @@ fun PiezoMonitoringView(appState: AppState) {
kotlinx.coroutines.delay(100) kotlinx.coroutines.delay(100)
} }
autoTickCount++ autoTickCount++
// 최소 1000ms 간격 보장 (기기 측정 한계 ~0.6초 + 여유) // 최소 1500ms 간격 보장 (기기 연속 maa 채널 드롭 방지)
val elapsed = System.currentTimeMillis() - measureStartMs val elapsed = System.currentTimeMillis() - measureStartMs
val remaining = 1000L - elapsed val remaining = 1500L - elapsed
if (remaining > 0) kotlinx.coroutines.delay(remaining) if (remaining > 0) kotlinx.coroutines.delay(remaining)
} }
kotlinx.coroutines.delay(50) kotlinx.coroutines.delay(50)