NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

Good strategy for multiple BLE devices connected, without disconnect in between?

Open distancerunner opened this issue 1 year ago • 1 comments

Thanks for this great Lib. It works wonderful for my MQTT Bridge.

I'm creating a BLE reader for Renogy LiFePo Batteries (https://github.com/distancerunner/Renogy-Battery-ESP32-Bluetooth-MQTT-Bridge). Actual I have 2 of them in my VAN. I will poll every one of them in cycle, one after each other.

My actual code makes it like that:

  1. Scan
  2. Device found
  3. Connect to device with adress xx:xx:xx:xx
  4. write data
  5. get notification (voltage, current etc)
  6. close connection with client->disconnect()
  7. start again from 1.

I was wondering, if there is a better way to stay connected to multiple devices (how should I handle the amount dynamical, the amount should be flexible). I will call data without reconnect every time. Is there a strategy I can make?

distancerunner avatar Apr 12 '23 14:04 distancerunner

You can simply create multiple client instances and maintain the connection with up to 9 devices.

h2zero avatar May 14 '23 19:05 h2zero