feat: BLE stability fixes, NIRS streaming improvements, catheter count feature
- Fix BLE API deprecation warnings with API 33+ version checks - Move isServiceReady to onDescriptorWrite for reliable CCCD setup - Fix battery polling: immediate query on connect, pause during NIRS streaming - Add mcj retry mechanism for NIRS streaming reliability - Add debug logging to BLE, NIRS parsing, and processing pipeline - Add catheter count feature to Piezo monitoring (persistent count, add dialog, auto-decrement on catheterize) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package com.example.medilightv2android
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.example.medilightv2android.ble.BleManager
|
||||
@@ -22,6 +23,7 @@ class AppState(private val context: Context) {
|
||||
var bladderLevel by mutableStateOf(BladderLevel())
|
||||
var isDeviceConnected by mutableStateOf(false)
|
||||
var piezoSettings by mutableStateOf(PiezoSettings())
|
||||
var catheterCount = mutableIntStateOf(0)
|
||||
|
||||
private val storage = UserStorage.getInstance(context)
|
||||
private val historyStore = MeasurementHistoryStore.getInstance(context)
|
||||
@@ -40,6 +42,7 @@ class AppState(private val context: Context) {
|
||||
catheterizationThreshold = storage.catheterizationLevel
|
||||
)
|
||||
piezoSettings = storage.piezoSettings
|
||||
catheterCount.intValue = storage.catheterCount
|
||||
|
||||
currentScreen = when {
|
||||
!storage.hasCompletedOnboarding -> AppScreen.ONBOARDING
|
||||
@@ -147,6 +150,11 @@ class AppState(private val context: Context) {
|
||||
bladderLevel = newLevel
|
||||
storage.bladderLevel = 0
|
||||
notificationService.cancelAll()
|
||||
|
||||
if (catheterCount.intValue > 0) {
|
||||
catheterCount.intValue--
|
||||
storage.catheterCount = catheterCount.intValue
|
||||
}
|
||||
}
|
||||
|
||||
fun showHistory() {
|
||||
@@ -157,6 +165,11 @@ class AppState(private val context: Context) {
|
||||
currentScreen = if (sensorMode == SensorMode.NIRS) AppScreen.VIVAMYO_MONITORING else AppScreen.PIEZO_MONITORING
|
||||
}
|
||||
|
||||
fun addCatheterCount(amount: Int = 1) {
|
||||
catheterCount.intValue += amount
|
||||
storage.catheterCount = catheterCount.intValue
|
||||
}
|
||||
|
||||
fun updateCatheterizationThreshold(threshold: Int) {
|
||||
bladderLevel = bladderLevel.copy(catheterizationThreshold = threshold)
|
||||
storage.catheterizationLevel = threshold
|
||||
|
||||
Reference in New Issue
Block a user