I’m also seeing a third issue to do with disconnects.
If my phone goes to sleep it disconnects from the bluetooth, if I wake it up ~30 seconds later my phone will reconnect to the board.
However if I wake it up immediately my phone fails to reconnect.
(A 3rd failure mode is when I start the app from cold. It sometimes fails to connect to the board)
Here’s a good reconnect:
05:09:02 DEBUG CommunicationService - removeOnServerResponseListener: clazz=ProjectActivity
05:09:02 DEBUG CommunicationService - onUnbind
05:09:02 DEBUG CommunicationService - onDestroy
05:09:02 DEBUG c.b.a.communication.transport.a.a.a - onDisconnect: forced=true
[...]
05:09:15 DEBUG CommunicationService - onBind
05:09:15 DEBUG SocketTransport - connect: relogin
05:09:15 DEBUG SocketReader - connect to 139.59.206.133
05:09:15 DEBUG CommunicationService - onReceive activeNetwork =
[REDACTED]
05:09:21 DEBUG c.b.a.communication.transport.a.a.a - onDisconnect: forced=true
[...]
05:09:23 DEBUG c.b.a.communication.transport.a.a.b - to write: BluetoothLoginAction{actiondId=2, body=570529042ad34219a964929e2a483f40}
05:09:23 DEBUG c.b.a.communication.transport.a.a.b - write: [2, 0, 1, 0, 32, 53, 55, 48, 53, 50, 57, 48, 52, 50, 97, 100, 51, 52, 50, 49]
05:09:23 DEBUG c.b.a.communication.transport.a.a.b - write: [57, 97, 57, 54, 52, 57, 50, 57, 101, 50, 97, 52, 56, 51, 102, 52, 48]
05:09:23 DEBUG c.b.a.communication.transport.a.a.a - onDataChanged: onDataChanged=[0, 0, 1, 0, -56]
05:09:23 DEBUG c.b.a.communication.transport.a.a.a - parseAndSend: actionId=0 messageId=1 codeOrLength=200
05:09:23 DEBUG CommunicationService - onEventMainThread serverResponse=ServerResponse{code=200, messageId=-200, projectId=-1, body='null'} paused=false
05:09:23 DEBUG c.b.a.communication.transport.a.a.a - parseAndSend: wrap
[...]
05:09:24 DEBUG CommunicationService - onPacketReceived messageId = 1111, actionId = 25, value = 1972193027-0
05:09:24 DEBUG CommunicationService - onPacketReceived actionId=25 serverAction=null
05:09:24 DEBUG CommunicationService - onPacketReceived messageId = 1111, actionId = 25, value = 1972193027-0
05:09:24 DEBUG CommunicationService - onPacketReceived actionId=25 serverAction=null
[...5 more...]
05:09:25 DEBUG c.b.a.communication.transport.a.a.a - onDataChanged: onDataChanged=[20, 0, 109, 0, 7, 118, 119, 0, 48, 0, 50, 57]
05:09:25 DEBUG c.b.a.communication.transport.a.a.a - parseAndSend: actionId=20 messageId=109 codeOrLength=7 message=
05:09:25 DEBUG c.b.a.communication.transport.a.a.a - parseAndSend: wrap
05:09:25 DEBUG CommunicationService - onPacketReceived messageId = 109, actionId = 20, value = 1972193027-0
Notice the ~12 second gap from when my phone went to standby at 05:09:03 and when it woke up at 05:09:15. It then takes another 8 seconds before it reconnects the bluetooth (but hey I can live with that). I see a bunch of synthetic onPackedReceived
messages after it reconnects that contain the values from before the disconnect - is this by design?
Now here is a bad reconnect:
05:09:45 DEBUG CommunicationService - removeOnServerResponseListener: clazz=ProjectActivity
05:09:45 DEBUG CommunicationService - onUnbind
05:09:45 DEBUG CommunicationService - onDestroy
05:09:45 DEBUG c.b.a.communication.transport.a.a.a - onDisconnect: forced=true
[...]
05:09:47 DEBUG CommunicationService - onBind
05:09:47 DEBUG SocketTransport - connect: relogin
05:09:47 DEBUG SocketReader - connect to 139.59.206.133
05:09:47 DEBUG CommunicationService - onReceive activeNetwork =
[...]
05:09:52 DEBUG c.b.a.communication.transport.a.a.a - onDisconnect: forced=true
05:09:53 DEBUG c.b.a.communication.transport.a.a.a - onDisconnect: forced=true
05:09:53 DEBUG CommunicationService - onPacketResponse messageId=4 responseCode=OK
05:09:53 DEBUG CommunicationService - onPacketResponse serverAction=SyncAction{actiondId=25, body=1972193027}
05:09:53 DEBUG CommunicationService - onPacketResponse postResponse=ServerResponse{code=200, messageId=4, projectId=1972193027, body='null'}
[A whole bunch of synthetic onPacketRecieved messages]
Here there are only 2 seconds from the disconnect (05:09:45) to the reconnect (05:09:47).
In the bad case the app fails to reconnect the BLE connection. I know this because the BLE-connected light on my board is off.
My theory here is that in the good case, both the BLE connection is broken and the Blynk heartbeat timeout has passed. In the bad case the Blynk heartbeat timeout has not passed. For some reason in this situation the app does not fix the bluetooth connection.