From 208701af526e216f1f0578a6f92bb49114d4524c Mon Sep 17 00:00:00 2001 From: dzid26 Date: Thu, 15 Oct 2026 21:59:26 +0100 Subject: [PATCH] fix: skip RSSI reads while a GATT write or setup step is in flight Co-Authored-By: Claude Sonnet 5.5 --- .../main/java/com/dzid26/teslable/ble/TeslaGattClient.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/dzid26/teslable/ble/TeslaGattClient.kt b/app/src/main/java/com/dzid26/teslable/ble/TeslaGattClient.kt index d20c7349b..bd67604d7 100644 --- a/app/src/main/java/com/dzid26/teslable/ble/TeslaGattClient.kt +++ b/app/src/main/java/com/dzid26/teslable/ble/TeslaGattClient.kt @@ -97,6 +97,9 @@ class TeslaGattClient( @SuppressLint("MissingPermission") override fun readRssi() { + // One GATT operation in flight: an RSSI read during setup or a chunk write would collide with it. The next + // poll picks the value up. + if (setupStep != SetupStep.DONE || writeInProgress) return gatt?.readRemoteRssi() } @@ -108,7 +111,8 @@ class TeslaGattClient( val chunk = writeQueue.removeFirstOrNull() ?: return writeInProgress = true - // The Go reference writes with response; write without response is validated on a real car. + // The Go reference writes with response. We write without response: chunks are paced on + // onCharacteristicWrite, which fires for this type too, and it saves a round trip per chunk. val started = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { gatt.writeCharacteristic(