fbiego / DT78-App-Android

Alternative app for the DT78 Smartwatch. Also works with DT92 & DT66. May work with watches that use the WearFit 2.0 app.
MIT License
50 stars 23 forks source link

App disconnects immediately and tries reconnecting on Bluetooth 4.1 & 4.2 #7

Open sbm24 opened 3 years ago

sbm24 commented 3 years ago

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.

fbiego commented 3 years ago

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

sbm24 commented 3 years ago

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.

fbiego commented 3 years ago

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

sbm24 commented 3 years ago

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.

fbiego commented 3 years ago

Did you make changes on the Esp32 code?

sbm24 commented 3 years ago

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.

fbiego commented 3 years ago

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

sbm24 commented 3 years ago

Restarted Several times