fix: handle missing VERSION characteristic gracefully on old ESP firmware
This commit is contained in:
parent
7607361019
commit
1499d840ce
1 changed files with 9 additions and 1 deletions
|
|
@ -286,8 +286,13 @@ class BleRelayManager(
|
|||
val service = gatt.getService(SERVICE_UUID)
|
||||
val versionChar = service?.getCharacteristic(VERSION_UUID)
|
||||
if (versionChar != null) {
|
||||
gatt.readCharacteristic(versionChar)
|
||||
val ok = gatt.readCharacteristic(versionChar)
|
||||
if (!ok) {
|
||||
Log.w(TAG, "readCharacteristic(VERSION) returned false, skipping version check")
|
||||
handler.post { callbacks.onStatusChanged(BleStatus.Connected) }
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "VERSION characteristic not found, skipping version check")
|
||||
handler.post { callbacks.onStatusChanged(BleStatus.Connected) }
|
||||
}
|
||||
} else {
|
||||
|
|
@ -302,6 +307,9 @@ class BleRelayManager(
|
|||
Log.d(TAG, "ESP firmware version: $version, app bundled: $appVersion")
|
||||
handler.post { callbacks.onFirmwareVersion(version, appVersion) }
|
||||
handler.post { callbacks.onStatusChanged(BleStatus.Connected) }
|
||||
} else if (characteristic.uuid == VERSION_UUID) {
|
||||
Log.w(TAG, "Version read failed (status=$status), using Connected anyway")
|
||||
handler.post { callbacks.onStatusChanged(BleStatus.Connected) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue