detect UUID to warn firmware is too old

This commit is contained in:
andrekir 2022-10-12 23:40:54 -03:00
parent 3174b53c36
commit 22671a73db
3 changed files with 19 additions and 1 deletions

View file

@ -99,6 +99,10 @@ class BluetoothInterface(
/// this service UUID is publically visible for scanning
val BTM_SERVICE_UUID: UUID = UUID.fromString("6ba1b218-15a8-461f-9fa8-5dcae273eafd")
var invalidVersion = false
val EOL_FROMRADIO_CHARACTER: UUID =
UUID.fromString("8ba2bcc2-ee02-4a55-a531-c525c5e454d5")
val BTM_FROMRADIO_CHARACTER: UUID =
UUID.fromString("2c55e69e-4993-11ed-b878-0242ac120002")
val BTM_TORADIO_CHARACTER: UUID =
@ -149,6 +153,7 @@ class BluetoothInterface(
?: throw RadioNotConnectedException("BLE service not found")
private lateinit var fromNum: BluetoothGattCharacteristic
private lateinit var fromRadio: BluetoothGattCharacteristic
/**
* With the new rev2 api, our first send is to start the configure readbacks. In that case,
@ -228,7 +233,6 @@ class BluetoothInterface(
/// Attempt to read from the fromRadio mailbox, if data is found broadcast it to android apps
private fun doReadFromRadio(firstRead: Boolean) {
safe?.let { s ->
val fromRadio = getCharacteristic(BTM_FROMRADIO_CHARACTER)
s.asyncReadCharacteristic(fromRadio) {
try {
val b = it.getOrThrow()
@ -357,6 +361,13 @@ class BluetoothInterface(
fromNum = getCharacteristic(BTM_FROMNUM_CHARACTER)
// We changed UUIDs to be able to identify old firmware (<1.3.43)
fromRadio = if (bservice.characteristics.map { it.uuid }
.contains(EOL_FROMRADIO_CHARACTER)) {
invalidVersion = true
getCharacteristic(EOL_FROMRADIO_CHARACTER)
} else getCharacteristic(BTM_FROMRADIO_CHARACTER)
// We treat the first send by a client as special
isFirstSend = true