Commit graph

35 commits

Author SHA1 Message Date
geeksville
f9c1ac8cd2 Fix back to back writes to not overwrite BLE characterstic. Fixes
the "sending while device was asleep bug"
2020-06-13 16:21:26 -07:00
geeksville
eb5a492ade OMG - we were accidentally leaving two GATTs alive - which is super bad 2020-06-11 17:34:22 -07:00
geeksville
e20f7c5943 use only async io when talking to the radio 2020-06-11 16:22:20 -07:00
geeksville
96a28afb8f fix autobug: old notifies might come in from devices we are reconnecting to 2020-06-10 12:03:31 -07:00
geeksville
1be402d771 fix autobug - discovery can now occur after mtu 2020-06-10 11:42:11 -07:00
geeksville
590e76731f One more fix for Soyes XS phones (but see disclaimer below)
The bluetooth implementation of this phone calls the gatt callbacks
*before* the connect call returns to the client.  This is incorrect because
the client won't have a reference to the gatt at that time.

Fortunately, we only need to check gatt on disconnect, so I moved that later.

But one problem I've noticed in my testing.  Sometimes this phone stops
being able to scan for BLE devices.  The only fix I've found is to click to
turn bluetooth off briefly and then back on.

A major problem with this phone is that if you reboot the phone it seems
the time the phone has forgotten its paring data and devices must
be re-paired.  This is a huge bummer and I don't think my app can fix this.
2020-06-09 12:25:05 -07:00
geeksville
2568f00762 ignore failures delivering close exceptions (autobug) 2020-06-09 10:22:19 -07:00
geeksville
7a3cda314e Fix recent bug where sometimes phone would not auto-reconnect to devices 2020-06-07 18:05:18 -07:00
geeksville
db43f47f91 handle 133 statuses when direct connect fails 2020-06-04 09:58:06 -07:00
geeksville
d526d11d20 Fix #32
+            // Note: To workaround https://issuetracker.google.com/issues/36995652
+            // Always call BluetoothDevice#connectGatt() with autoConnect=false
+            // (the race condition does not affect that case). If that connection times out
+            // you will get a callback with status=133. Then call BluetoothGatt#connect()
+            // to initiate a background connection.
2020-06-04 09:35:25 -07:00
geeksville
4d6ca25caf autobug, prevent redundant notifcations from onConnectChanged 2020-05-24 11:38:33 -07:00
geeksville
38f45a9413 fix autobug that showed on a MIX2 (whatever that is), ignore BLE state changes
when we don't have a gatt
2020-05-24 11:07:15 -07:00
geeksville
e6abd9d1a5 autobugs - some phones send bougs onMtuChanged when we are not setting mtu 2020-05-24 11:01:13 -07:00
geeksville
8b3817964e make sync BLE operations timeout a bit shorter 2020-05-24 10:47:02 -07:00
geeksville
a191dac0f4 stay with old api for now, because too much change hurts reliaiblity ;-) 2020-05-24 10:12:12 -07:00
geeksville
28023b8f42 Fix 27: add timeouts for BLE operations, to protect against buggy drivers 2020-05-24 09:45:39 -07:00
geeksville
c06f5f1c39 set aside ble sw update for now 2020-05-15 10:18:15 -07:00
geeksville
0b7f853abc fix an autobug - race condition on some phones BLE reconnect 2020-05-10 21:39:49 -07:00
geeksville
5822dddc6c Fix #23: autobug, if we get mystery BLE error 133 while reading messages
drop the BLE link and reconnect and try again.
2020-04-26 13:03:35 -07:00
geeksville
e302848607 0.5.5 only try to set max MTU once, if it fails consider phone buggy 2020-04-24 15:49:34 -07:00
geeksville
3e89510f52 Some phones have buggy race conditions wrt finding services or characteristics
This workaround is: If we fail in that way during initial device connection
we disconnect() and try again 500 ms later.
2020-04-24 15:22:54 -07:00
geeksville
8bf60c7603 make BLE exceptions strongly typed, so I can trigger closing down connections if needed 2020-04-20 11:10:53 -07:00
geeksville
0919bc75ef only ignore connect failures if autoconnect is on 2020-04-20 11:01:27 -07:00
geeksville
2a52b707ee fix autobug: some phones call gatt connected but with an error status code 2020-04-20 10:37:46 -07:00
geeksville
9b57d60432 add note about an unsolved autobug 2020-04-20 10:15:22 -07:00
geeksville
34aa4cde05 if bluetooth was disabled when we started, reattempt device connect later 2020-04-20 09:56:38 -07:00
geeksville
54d632eb84 some android stacks are buggy and need 500ms before returning BLE descriptors 2020-04-13 16:28:32 -07:00
geeksville
6ff84a1808 fix rare mystery bluetooth status 133 error
Thanks to comment by @pederovarela86

https://github.com/android/connectivity-samples/issues/18#issuecomment-374600798
2020-04-10 18:04:39 -07:00
Kevin Hester
90cee2f202 add support for reconnecting if bluetooth gets disabled 2020-03-02 08:05:43 -08:00
Kevin Hester
6a90881dd6 fix crashlytics auto report. oops error() is now a kotlin stdlib call
and therefore I was accidentally calling it instead of my Logging.error()
method.  And that made some error logs incorrectly fatal.
2020-02-29 13:21:05 -08:00
geeksville
2c8c7ac8d6 if phone ble stack is hosed restart it 2020-02-25 09:28:47 -08:00
geeksville
601aeb83d7 BLE sw update kinda works again 2020-02-24 15:47:53 -08:00
geeksville
7ed5a3efac make SafeBluetooth Closable 2020-02-24 15:34:17 -08:00
geeksville
bdd6e5de6c gracefully handle when an esp32 bluetooth link slowly browns out 2020-02-17 18:46:20 -08:00
geeksville
10ad07e136 we now fetch any new rxmessages when they arrive at the radio 2020-02-10 15:31:56 -08:00
Renamed from app/src/main/java/com/geeksville/mesh/SafeBluetooth.kt (Browse further)