connectAsync will sometimes always fail if the phone was restarted.
I've only seen this happen on Google Pixel devices but if I restart the phone there is a chance that I will be able to connect to the MMR board after 2-3 retries, and connecting via nRFConnect works fine too. But other times when I restart the phone I'm completely unable to connect via my app, via nRFConnect, or even Metabase unless I restart the phone a few more times. This happens on 2 seperate Google Pixel devices.
In my app I get this:
java.util.concurrent.TimeoutException: Failed to connect and discover services within 10000ms
when it fails along with these bluetooth gatt logs:
D/BluetoothGatt: connect() - device: <MAC address>, auto: false D/BluetoothGatt: registerApp() D/BluetoothGatt: registerApp() - UUID=<UUID number> D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6 D/BluetoothGatt: refresh() - device: <MAC address> D/BluetoothGatt: close() unregisterApp() - mClientIf=6
This repeats because I call onServiceConnected every time the task faults
In the case where everything is working I get these logs:
D/BluetoothGatt: connect() - device: <MAC address>, auto: false registerApp() registerApp() - UUID=<UUID number> D/BluetoothGatt: onClientRegistered() - status=0 clientIf=7 D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=7 device=<MAC address> D/BluetoothGatt: onConnectionUpdated() - Device=<MAC address>interval=6 latency=0 timeout=500 status=0 D/BluetoothGatt: onConnectionUpdated() - Device=<MAC address> interval=36 latency=0 timeout=500 status=0 D/BluetoothGatt: discoverServices() - device: <MAC address> D/BluetoothGatt: onSearchComplete() = Device=<MAC address> Status=0 D/BluetoothGatt: setCharacteristicNotification() - uuid: <UUID number> enable: true
I need to make sure that I have some way of making the MMR work with most phones or at least know why it fails.
Why would it work sometimes but not others? And If it does work it seems to continue to work until the phone is turned off, at which point it's a coin flip if it works again or not. The behavior is basically the same with nRFConnect but seemingly only applies to the MMR board.