BLESerialClient class modifaction
Opened this issue · 3 comments
hello,
your modification of the BLESerial to BLESerielClient is exact what is searched for.
but i need to switch to NIMBLEDevice for save resources.
so i try to modify it but struggle with serveral compiler issues, like virtual class errors.
can you point me the right direction to do that?
another little issue in this class is that the read function never return a -1 like the arduino class, do you have a short idea to fix that?
in another issue i read it is easy to modificate it that it connect to a specific device that given, can you tell me about how?
and it is possibile in any way to hold a connection to more than one server?
thank you for your time
I'm sorry but I haven't looked at this code in a long time. I did struggle with it because the BLE protocol isn't intended for serial communications like the BMS uses. It really should be regular BT but that isn't what the JBD BMS uses. I never was able to get Arduino to communicate over BLE with the BMS. The Arduino BLE library works in a very different way.
I don't know what NIMBLEDevice is.
I do not believe it is possible to connect to more than one server.
To connect to a specific device look in
BleSerialClient::onResult(BLEAdvertisedDevice advertisedDevice)
and add code to check that the advertised device is the one you wish to connect to.
Thanks for your quick answer.
NIMble is a fork of the arduino ble library but with signifikant smaler memory Impact, and i need so i got out of memory.
So when No multiple Connection is possibile i think a Connect-read-disconnect and select the next device will work too.
So im relative new to the Bluetooth world, its Not my recommend Thing to use, but the Project need it.
With Cour serialclient Class i got a succsessfull Connection to my device and get communication, so its nearly perfect. But struggle to rewrite it to NIMble.
You can Take a Look at my try
https://github.com/softwarecrash/nimble-serial
Something is wrong with the class constructor when it use NIMble insgesamt of ble
I Hope you have a little Bit time to Help me out of this.
Thank you
I don't think you are going to get the SerialBLE library to work with the Arduino library, or at least I couldn't. It is a very different implementation. The ESP32 library uses callbacks for when data arrives, while the Arduino loops checking for data. No matter what I did, the Arduino library was losing data after 20 bytes or so. BLE is meant for just updating data points, like a weather station would just update windspeed and direction. The Arduino library is fine for that because it is only a few bytes. And the BMS uses BLE, so that is what I had to use. But the Arduino library just didn't work with the BMS.
If you have a choice, I would select BT, not BLE. BT would allow connection to multiple devices, I think. And BT is much simpler than BLE and supports serial natively. The disconnect/reconnect idea might take about 5 seconds. Another option would be to have a second Bluetooth chip, or even a whole another esp32.
If you are running out of memory, can you use a different model esp32 with more?