Tympan / Tympan_Library

Arduino/Teensy Library for Tympan Open Source Hearing Aid
MIT License
122 stars 32 forks source link

Add BT Classic support at startup (including Link ID tracking) #52

Closed chipaudette closed 3 years ago

chipaudette commented 3 years ago

Ever since our switch from BT Classic SPP messaging to Bluetooth Low Energy (BLE) messaging,, we only enabled BLE connections for V7 firmware on the BC127. The idea was: if we're using BLE, why confusing things by enabling BT Classic connections?

Well, after living with it for a while, here are some issues that appeared:

1) iOS devices could not see the Tympan (v7 firmware), which meant that it could not pair, which meant that the Tympan could not be used with iOS devices 2) We no longer could receive Bluetooth audio (v7 firmware), even on Android devices

Through random testing, we found that problem (1) was solved by enabling BT Classic to be discoverable. At that point, iOS could pair and connect. A side effect was that it also re-enabled BT Audio for all platforms.

Implementing BT Classic at start for Tympans with BC127 V7 Firmware is the primary goal of this merge.

It turns out, however, that there were all sorts of secondary effects to enabling BT Classic that were not good. Specifically, the BLE link ID could now take a variety of values (14, 24, 34) whereas before it was only ever a single value (14). Therefore, we needed to expand the library to track which link ID is the active BLE connection and add methods to detect when the Link ID was opened and closed. And, we needed to expand our flexibility when updating our advertising state, particularly where we interpret the replies from the BC127 in isConnected() and isAdvertising().

It was a lot of changes. Hopefully we got it right.

One area where we are still unsure is on RevD with iOS: (1) connect in the App, (2) purposely disconnect in the App, and then (3) reconnect again. Did the advertising get reactivated so that you could successfully reconnect?

chipaudette commented 3 years ago

@hgeithner-creare , @ijenkins-creare , @eyuan-creare

I created this pull request as documentation. I'm going to go ahead and accept the merge from feature into Develop. I don't think that we've fully retested everything, but Haley suggested that I go ahead and do it in order to better support Joshua Alexander and his problems connecting.