I am working on an app where I will have anywhere from 2 to 32 ble devices that I will need to send strings to. I am able to scan, connect, and send strings to a single device without issue.
What I can't seem to workout is how to take a list of the devices, connect/send strings/disconnect and then repeat on the next device in the list. I end up locking the companion app, or crashing it. Or it runs through the processes I'm trying to use, never connecting and sending the string.
Searching here for multiple ble shows a few examples of using multiple bluetoothLE components to connect to devices simultaneously however I don't believe that is what I need to do.
I've included my latest failed attempt at working this out. I'm nearly certain I'm just "doing it wrong" but I don't know where or why it is wrong. The idea here is I press the send button, it pulls entries in the tinydb that match and pulls the MAC address from that entry and connects to it. Then it waits till connected, calls to send the strings, sends the strings and comes back to disconnect and then move on to the next entry.
This example hangs the companion app.
Any suggestions would be greatly appreciated. I'm running out of hair to pull out over this.