From c0692b80ec0dde69b2d4e7ae804bea880f17c89b Mon Sep 17 00:00:00 2001 From: andrekir Date: Wed, 2 Oct 2024 20:00:02 -0300 Subject: [PATCH] refactor: remove legacy BLE characteristic --- .../java/com/geeksville/mesh/MainActivity.kt | 3 --- .../mesh/repository/radio/BluetoothInterface.kt | 16 +--------------- .../com/geeksville/mesh/service/MeshService.kt | 3 --- 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/MainActivity.kt b/app/src/main/java/com/geeksville/mesh/MainActivity.kt index cc9e22d9..c9779772 100644 --- a/app/src/main/java/com/geeksville/mesh/MainActivity.kt +++ b/app/src/main/java/com/geeksville/mesh/MainActivity.kt @@ -37,7 +37,6 @@ import com.geeksville.mesh.model.UIViewModel import com.geeksville.mesh.model.primaryChannel import com.geeksville.mesh.model.shouldAddChannels import com.geeksville.mesh.model.toChannelSet -import com.geeksville.mesh.repository.radio.BluetoothInterface import com.geeksville.mesh.service.* import com.geeksville.mesh.ui.* import com.geeksville.mesh.ui.map.MapFragment @@ -355,8 +354,6 @@ class MainActivity : AppCompatActivity(), Logging { } } } - } else if (BluetoothInterface.invalidVersion) { - showAlert(R.string.firmware_too_old, R.string.firmware_old) } } catch (ex: RemoteException) { warn("Abandoning connect $ex, because we probably just lost device connection") diff --git a/app/src/main/java/com/geeksville/mesh/repository/radio/BluetoothInterface.kt b/app/src/main/java/com/geeksville/mesh/repository/radio/BluetoothInterface.kt index a6c36b23..31a85d85 100644 --- a/app/src/main/java/com/geeksville/mesh/repository/radio/BluetoothInterface.kt +++ b/app/src/main/java/com/geeksville/mesh/repository/radio/BluetoothInterface.kt @@ -88,10 +88,6 @@ class BluetoothInterface @AssistedInject constructor( /// this service UUID is publicly 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 = @@ -119,7 +115,6 @@ class BluetoothInterface @AssistedInject constructor( ?: 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, @@ -199,6 +194,7 @@ class BluetoothInterface @AssistedInject constructor( /// 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() @@ -326,16 +322,6 @@ class BluetoothInterface @AssistedInject constructor( 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 { - invalidVersion = false - getCharacteristic(BTM_FROMRADIO_CHARACTER) - } - // We treat the first send by a client as special isFirstSend = true diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 78140c42..bbecf112 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -30,7 +30,6 @@ import com.geeksville.mesh.model.DeviceVersion import com.geeksville.mesh.repository.datastore.RadioConfigRepository import com.geeksville.mesh.repository.location.LocationRepository import com.geeksville.mesh.repository.network.MQTTRepository -import com.geeksville.mesh.repository.radio.BluetoothInterface import com.geeksville.mesh.repository.radio.RadioInterfaceService import com.geeksville.mesh.repository.radio.RadioServiceConnectionState import com.geeksville.mesh.util.* @@ -1624,8 +1623,6 @@ class MeshService : Service(), Logging { newNodes.clear() newMyNodeInfo = null - if (BluetoothInterface.invalidVersion) onHasSettings() // Device firmware is too old - debug("Starting config nonce=$configNonce") sendToRadio(ToRadio.newBuilder().apply {