Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes onServiceDiscoverd is not called when connecting. #536

Open
cos-overclock opened this issue Nov 14, 2023 · 1 comment
Open

Sometimes onServiceDiscoverd is not called when connecting. #536

cos-overclock opened this issue Nov 14, 2023 · 1 comment
Labels

Comments

@cos-overclock
Copy link

The BleManager was used to connect with the peripheral device.
It is recognised that if the device is not a bonding device when connected, the discoverService is executed after a delay of 300 ms, but in reality the BluetoothGatt executes the discoverService immediately.
I don't know if this is the direct cause, but sometimes BleManager's onServicesDiscovered is not called.
Am I missing some setting that is required for the connection?

2023-11-13 16:48:17.882 31278-31432 BluetoothGatt                 D  connect() - device: 00:3C:84:13:9B:D5, auto: false
2023-11-13 16:48:17.882 31278-31432 BluetoothGatt                 D  registerApp()
2023-11-13 16:48:17.882 31278-31432 BluetoothGatt                 D  registerApp() - UUID=3c4f615a-b9f9-4bbc-bf0e-f566a7b50f0d
2023-11-13 16:48:17.886 31278-31348 BluetoothGatt                 D  onClientRegistered() - status=0 clientIf=6
2023-11-13 16:48:18.187 31278-31291 BluetoothGatt                 D  onClientConnectionState() - status=0 clientIf=6 device=00:3C:84:13:9B:D5
2023-11-13 16:48:18.187 31278-31278 MyBleManager                  I  Connected to 00:3C:84:13:9B:D5
2023-11-13 16:48:18.189 31278-31278 BleConnect...onObserver       D  ConnectionObserver.onDeviceConnected
2023-11-13 16:48:18.491 31278-31278 BluetoothGatt                 D  discoverServices() - device: 00:3C:84:13:9B:D5
@cos-overclock cos-overclock changed the title BluetoothGatt automatically calls ServiceDiscover when connecting Sometimes onServiceDiscoverd is not called when connecting. Nov 14, 2023
@cos-overclock
Copy link
Author

Sorry, I misunderstood, as I had restricted the log level output to logcat.
After a 300 msec WAIT for the connection, the discoverService was called.
There seems to be another reason why the onServiceDiscoverd callback is not being called.

2023-11-14 10:37:09.401  6449-6583  BluetoothGatt                D  connect() - device: 00:3C:84:13:9B:D5, auto: false
2023-11-14 10:37:09.401  6449-6583  BluetoothGatt                D  registerApp()
2023-11-14 10:37:09.402  6449-6583  BluetoothGatt                D  registerApp() - UUID=1e571094-4100-4f3a-ac42-10e3470bc72a
2023-11-14 10:37:09.407  6449-6557  BluetoothGatt                D  onClientRegistered() - status=0 clientIf=6
2023-11-14 10:37:09.741  6449-6557  BluetoothGatt                D  onClientConnectionState() - status=0 clientIf=6 device=00:3C:84:13:9B:D5
2023-11-14 10:37:09.742  6449-6449  MyBleManager                 D  [Callback] Connection state changed with status: 0 and new state: 2 (CONNECTED)
2023-11-14 10:37:09.742  6449-6449  MyBleManager                 I  Connected to 00:3C:84:13:9B:D5
2023-11-14 10:37:09.743  6449-6449  MyBleManager                 D  wait(300)
2023-11-14 10:37:09.743  6449-6449  BleConnect...onObserver      D  ConnectionObserver.onDeviceConnected
2023-11-14 10:37:10.044  6449-6449  MyBleManager                 V  Discovering services...
2023-11-14 10:37:10.044  6449-6449  MyBleManager                 D  gatt.discoverServices()
2023-11-14 10:37:10.045  6449-6449  BluetoothGatt                D  discoverServices() - device: 00:3C:84:13:9B:D5
2023-11-14 10:37:19.398  6449-6583  BleConnector                 W  kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 10000 ms

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

No branches or pull requests

2 participants