DT78-App-Android icon indicating copy to clipboard operation
DT78-App-Android copied to clipboard

App disconnects immediately and tries reconnecting on Bluetooth 4.1 & 4.2

Open sbm24 opened this issue 4 years ago • 8 comments

When i used the app on a 2016 model phone having bluetooth v4.1, it connects to esp and immediatly disconnects, then again tries to reconnect in few seconds. This goes on. issue is also seen on some other old phones too.

sbm24 avatar Jan 21 '21 18:01 sbm24

I've also faced the same issue but it should reconnect automatically What android version is that? Have you disabled battery optimization?

fbiego avatar Jan 24 '21 06:01 fbiego

Hi, thanks for responding Android 6.0.1, BT 4.1, Xiaomi redmi 3S just tried battery saver to no. still issue persists.

Logs on android studio is as per following: . . . . I/OpenGLRenderer: Initialized EGL, version 1.4 W/MainActivity$onResume$t: Timer Task: Steps requested D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=FC:F5:C4:39:32:2E D/LeManagerCallbacks: onDeviceConnected {address=FC:F5:C4:39:32:2E,name=Esp32 Watch} D/ForegroundService$bleMa: onDeviceConnected Esp32 Watch D/BluetoothGatt: onClientConnectionState() - status=22 clientIf=9 device=FC:F5:C4:39:32:2E D/LeManagerCallbacks: onLinklossOccur {address=FC:F5:C4:39:32:2E,name=Esp32 Watch} D/ForegroundService$bleMa: Lost link to Esp32 Watch D/LeManagerCallbacks: onDeviceConnecting {address=FC:F5:C4:39:32:2E,name=Esp32 Watch} D/ForegroundService$bleMa: Connecting to Esp32 Watch D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=FC:F5:C4:39:32:2E D/LeManagerCallbacks: onDeviceConnected {address=FC:F5:C4:39:32:2E,name=Esp32 Watch} D/ForegroundService$bleMa: onDeviceConnected Esp32 Watch D/BluetoothGatt: onClientConnectionState() - status=22 clientIf=9 device=FC:F5:C4:39:32:2E . . .<<<<<after few minutes it appeared as . D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=FC:F5:C4:39:32:2E D/LeManagerCallbacks: onDeviceConnected {address=FC:F5:C4:39:32:2E,name=Esp32 Watch} D/BluetoothGatt: discoverServices() - device: FC:F5:C4:39:32:2E D/ForegroundService$bleMa: onDeviceConnected Esp32 Watch D/BluetoothGatt: onSearchComplete() = Device=FC:F5:C4:39:32:2E Status=0 W/LEManager$callback: Gatt service false, RX false, TX false D/LeManagerCallbacks: onDeviceNotSupported {address=FC:F5:C4:39:32:2E,name=Esp32 Watch} D/LeManagerCallbacks: onDeviceDisconnecting {address=FC:F5:C4:39:32:2E,name=Esp32 Watch} D/ForegroundService$bleMa: Disconnecting from Esp32 Watch D/BluetoothGatt: cancelOpen() - device: FC:F5:C4:39:32:2E D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=FC:F5:C4:39:32:2E D/BluetoothGatt: close() unregisterApp() - mClientIf=9 D/LeManagerCallbacks: onDeviceDisconnected {address=FC:F5:C4:39:32:2E,name=Esp32 Watch} D/ForegroundService$bleMa: Disconnected from Esp32 Watch W/MainActivity: onStart W/ForegroundService: onStartCommand {intent=true,flags=0,startId=2} onStartCommand - already running W/MainActivity$onResume$t: Timer Task: Steps requested ......

.<<<<<no further activity

Esp gets connected and disconnected imediately . even time also doesnt get updated on ESP. App works fine on latest phone model.

sbm24 avatar Jan 24 '21 14:01 sbm24

What UUIDs did you set for both the app and ESP32?

W/LEManager$callback: Gatt service false, RX false, TX false

This line indicates that the app did not find the required services

In ESP32 code

#define SERVICE_UUID              "6e400001-b5a3-f393-e0a9-e50e24dcca9e"
#define CHARACTERISTIC_UUID_RX    "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
#define CHARACTERISTIC_UUID_TX    "6e400003-b5a3-f393-e0a9-e50e24dcca9e"

App code (LEManager.kt)

val DT78_SERVICE_UUID:      UUID = UUID.fromString("6e400001-b5a3-f393-e0a9-e50e24dcca9e")
val DT78_TX_CHARACTERISTIC: UUID = UUID.fromString("6e400002-b5a3-f393-e0a9-e50e24dcca9e")
val DT78_RX_CHARACTERISTIC: UUID = UUID.fromString("6e400003-b5a3-f393-e0a9-e50e24dcca9e")

ESP - APP RX <- TX TX -> RX

fbiego avatar Jan 24 '21 16:01 fbiego

Yes, CHARACTERISTIC id are same as mentioned. I am using project as it is. Both side IDs match.

is there possibility that the phone needs more time to respond,i.e., it can't send packets too frequently. Its Bluetooth 4.1.

sbm24 avatar Jan 24 '21 23:01 sbm24

Did you make changes on the Esp32 code?

fbiego avatar Jan 25 '21 04:01 fbiego

No, i used it as it is. Same android and esp code works perfect on bluetooth v5 phone. If possible, try the android app on any older phone with Bluetooth v4.1 or 4.2. U may observe same thing.

sbm24 avatar Jan 25 '21 04:01 sbm24

It works fine on Android 6.0, BT v4.0. try restarting your phone

fbiego avatar Jan 25 '21 09:01 fbiego

Restarted Several times

sbm24 avatar Jan 26 '21 01:01 sbm24