fix: NIRS connection failure
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(git push -u origin master)"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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!")
|
||||
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)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user