amowry / WARBL2

WARBL2 Code and design files
https://warbl.xyz/index.html
GNU General Public License v3.0
11 stars 3 forks source link

App version of Config Tool disconnects when another MIDI app is opened #19

Open amowry opened 2 months ago

amowry commented 2 months ago

I've been noticing that with BLE, the iOS app (or app version of the Config Tool in Web MIDI Browser) disconnects from the WARBL2 when another MIDI app is first opened. After reconnecting, it will stay connected. If you open another MIDI app before connecting with the WARBL app, it will also stay connected. After disconnecting, it will still receive messages from the WARBL, so it seems that the connection is briefly broken and then restored, but the connection logic isn't aware of it. It probably just needs to try to reconnect after there has been a state change (?).

I'm adding this here to remind myself to look at it :).

amowry commented 2 months ago

The issue is that I don't seem to be able to tell which port the WARBL is on with BLE on iOS so I can't figure out a way to reliably tell when the WARBL has been disconnected. The onstatechange event has always been used for this, but it fires for other reasons when BLE is used.

For now, I added a patch that reconnects the Config Tool if it thinks it has disconnected but it's still receiving CC messages from the WARBL. It's crude but seems to be an improvement from the previous behavior where the Config Tool disconnects for no apparent reason and never reconnects. I think that ideally the WARBL should just send a message every second or so telling the Config Tool to remain connected (the battery status updates could be made more frequent for this), and I might add that to the firmware, but the current behavior will still be needed for anyone on firmware 4.1 (or older).