Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

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

Open
sbm24 opened this issue Jan 21, 2021 · 8 comments
Open

Comments

@sbm24
Copy link

sbm24 commented Jan 21, 2021

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
Copy link
Owner

fbiego commented Jan 24, 2021

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

@sbm24
Copy link
Author

sbm24 commented Jan 24, 2021

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
Copy link
Owner

fbiego commented Jan 24, 2021

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
Copy link
Author

sbm24 commented Jan 24, 2021

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
Copy link
Owner

fbiego commented Jan 25, 2021

Did you make changes on the Esp32 code?

@sbm24
Copy link
Author

sbm24 commented Jan 25, 2021

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
Copy link
Owner

fbiego commented Jan 25, 2021

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

@sbm24
Copy link
Author

sbm24 commented Jan 26, 2021

Restarted Several times

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants