Open cos-overclock opened 9 months ago
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
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 thediscoverService
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?