fix: NIRS connection failure

This commit is contained in:
2026-03-09 17:36:47 +09:00
parent a8532917b4
commit 91c5e5e7e0
2 changed files with 36 additions and 4 deletions
@@ -413,13 +413,38 @@ class BleManager private constructor(private val context: Context) {
}
} else {
Log.w(TAG, "CCCD descriptor not found for RX characteristic")
// No CCCD but still mark ready if characteristics exist
handler.post {
if (txCharacteristic != null && rxCharacteristic != null) {
isServiceReady.value = true
Log.d(TAG, "Service ready (no CCCD)")
}
}
}
} ?: run {
// No RX characteristic, mark ready if TX exists
handler.post {
if (txCharacteristic != null) {
isServiceReady.value = true
Log.d(TAG, "Service ready (no RX)")
}
}
}
}
handler.post {
if (txCharacteristic != null && rxCharacteristic != null) {
isServiceReady.value = true
Log.d(TAG, "Service ready!")
override fun onDescriptorWrite(gatt: BluetoothGatt, descriptor: BluetoothGattDescriptor, status: Int) {
Log.d(TAG, "onDescriptorWrite: status=$status uuid=${descriptor.uuid}")
if (descriptor.uuid == CCCD_UUID) {
handler.post {
if (status == BluetoothGatt.GATT_SUCCESS) {
if (txCharacteristic != null && rxCharacteristic != null) {
isServiceReady.value = true
Log.d(TAG, "Service ready! (CCCD written)")
}
} else {
Log.e(TAG, "CCCD write failed with status: $status")
connectionError.value = "Notification setup failed (status $status)"
}
}
}
}