-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Connect to more of 3 peripheral device #99
Comments
Edit: deleted, wrong fix - see below. |
@h2zero thanks for that hint. Up to now (without rebuilding the libbtdm_app.a ) the connection to more than 3 peripheral devices was not possible. Do you have a hint how i could rebuild the libbtdm_app.a library? |
Edit: deleted, wrong fix - see below. |
Could you post a log of the error you get when trying to connect to more than 3 devices? |
@corneliusmunz @GianCann I was wrong, no files need to be replaced, sorry for the bad info. I was playing with controller versions to test some things and I thought that was what made it work for me, it was not. The solution is actually a lot simpler. Just change the defines in the sdkconfig.h file at Arduino/hardware/espressif/esp32/tools/sdk/include/config to:
That will allow the controller the max connections it can handle and you can set the NimBLE max connections to what you need. |
@h2zero First of all many thanks for your support! I have tested it with the changed settings in sdkconfig.h. and in the nimconfig.h file. Unfortunately it does not connect to the 4th device. The devices are Lego Hubs which are connected via the legoino arduino library: https://github.com/corneliusmunz/legoino The following error message occurs which tells me, that the max connections in sdkconfig.h. and nimconfig.h are not really taken into account: The follwing settings were used: For the connection procedure i used this sketch from my Lego Bluetooth library: |
That’s odd, I connected to 5 devices today just with the config changes. I will try again with my other pc as I’m not quite sure about the status of the binary I used. |
Thank you @h2zero : I look forward to a definitive clarification on the use of the ESP32 module with more than 3 BLE devices |
I was just able to do some more testing, with the above changes to the config files I am able to connect to 4 devices with no issue currently. This is using arduino-esp32 1.0.4 and arduino IDE. I am wondering if you are using platformio, this may be why the config changes do not have effect? |
@h2zero 👍 👏 💪 🤘 ❤️ I switch to another PC (former try was on a MAC) and have done all your proposed changes (so only 3 changed settings in 2 header files) and fortunately it works like a charm!! I think on my OSX environment the formerly build object-files are used without applying the changes in the max connection values. I will try to evaluate a littlebit deeper why it have not worked out on my OSX system. So again: Thank you very much for you help and your superb work on that library. I will have a look on your proceeding and will definitely think about porting my Lego library (https://github.com/corneliusmunz/legoino) from the standard ble library to yours. Do you plan to "officially" release the libray for the library manager? @GianCann Can you try it with your 8 Train Hub setup? So for me it worked out and i can connect to 4 hubs at the same time |
@GianCann I could connect at the same time to 2 train hubs, 2 train remote controls, 1 boost hub and 1 control+ hub 😀 |
@corneliusmunz 💯 I'm glad you found the issue and all is working as expected, I have not connected to more than 6 devices before so if you have any issues connecting to this many them please make an issue about it. NimBLE actually supports up to 32 connections, sadly the esp32 controller is not equipped for this, but I'd be curious to see what happens if attempted.
This is in the works, a few minor things to deal with like mirroring the code between Arduino and IDF repos and some documentation/minor cleanup, other than that the current code is v1.0.0 I believe and ready to release. I just haven't had time to finish up these things. |
@corneliusmunz I have seen your test. Today I try to replicate on Windows PC. |
@h2zero, @GianCann I have tested it today on my MAC with the following procedure and it worked like a charm! I think i have changed maybe the wrong header files or the Arduino IDE does not recompile the hardware libs after the header was changed.
|
@corneliusmunz Thank you for providing the details of your solution. I will include this in the library documentation. How many simultaneous connections have you been able to maintain? |
@corneliusmunz I following your instruction but I get this error: C:\Users\remoteadmin\Documents\Arduino\libraries\legoino-feature-check_NimBle_Library\src\Lpf2Hub.cpp: In member function 'bool Lpf2Hub::connectHub()': C:\Users\remoteadmin\Documents\Arduino\libraries\legoino-feature-check_NimBle_Library\src\Lpf2Hub.cpp:885:66: error: no matching function for call to 'NimBLEClient::connect(NimBLEAddress&, int, bool)'
In file included from C:\Users\remoteadmin\Documents\Arduino\libraries\NimBLE-Arduino-master\src/NimBLEDevice.h:31:0,
C:\Users\remoteadmin\Documents\Arduino\libraries\NimBLE-Arduino-master\src/NimBLEClient.h:41:49: note: candidate: bool NimBLEClient::connect(NimBLEAdvertisedDevice*, bool)
C:\Users\remoteadmin\Documents\Arduino\libraries\NimBLE-Arduino-master\src/NimBLEClient.h:41:49: note: candidate expects 2 arguments, 3 provided C:\Users\remoteadmin\Documents\Arduino\libraries\NimBLE-Arduino-master\src/NimBLEClient.h:42:49: note: candidate: bool NimBLEClient::connect(const NimBLEAddress&, bool)
C:\Users\remoteadmin\Documents\Arduino\libraries\NimBLE-Arduino-master\src/NimBLEClient.h:42:49: note: candidate expects 2 arguments, 3 provided C:\Users\remoteadmin\Documents\Arduino\libraries\NimBLE-Arduino-master\src/NimBLEClient.h:43:49: note: candidate: bool NimBLEClient::connect(bool)
C:\Users\remoteadmin\Documents\Arduino\libraries\NimBLE-Arduino-master\src/NimBLEClient.h:43:49: note: candidate expects 1 argument, 3 provided exit status 1 |
Ok, I have changed this part of code in C:\Users\remoteadmin\Documents\Arduino\libraries\legoino-feature-check_NimBle_Library\src\Lpf2Hub.cpp
|
Yeah! 09:51:41.275 -> Number of Clients: 0 Now... go with others hub! |
Cool! I am really looking forward to your test with more that 4 hubs :-) I only have 6 hubs so that was my maximum |
@GianCann I see now why this was failing on your side. The NimBLE lib has changed the interface yesterday and i was downloading it before the change. I will update the code on my feature branch according to your changes. Thanks for evaluating this and fixing the error |
I successful get 8 device connected to my ESP32 |
Very cool! Thanks for your patience and your super hint to use the nimBLE Lib! I have pushed the code changes with your fix on the feature branch. Can you check it with 10 Devices? maybe it works :-) As far as i remember you have had 10 TrainHubs in your test setup picture |
I have 12 Train Hub, 6 Control+ Hub, 2 Move Hub and 4 Remote control 😄 |
A simple example: |
@h2zero I suggest you add a note on the description page of the library, useful for those who need to connect to more than 3 devices |
I will do that. Thanks for confirming the required changes. I'm curious also to know what happens if you connect to more than 9. If you try it please post your results. |
Yes! I will try later |
I can confirm: max 9 device!
If I try to modify these line with 10 value: So, maximum 9 BLE device. (I want to make a MQTT/BLE Gateway) |
Thanks for testing that, interesting that it crashes on boot with those values set to 10. WiFi + 9 BLE connections might need some connection interval management to maintain. |
Can you explain better? |
I’m not sure if you will need to do anything until you try it but I will explain. The BLE connection interval sets how often the devices should send a packet to each other. There is also connection supervision timeout that will disconnect if a packet is not received in that time. Depending on the device you’re connected to and the parameters set you may get disconnected from one or more devices frequently. Also if the connection interval is short and you’re also using WiFi you may get disconnected from WiFi often as the BLE connections may not give it enough time to use the antenna. I would say don’t worry about it until you try it. If you have issues we can make the adjustments then. |
Ok, it's all clear. |
As an update to this I have created a patch that should allow maximum connection change without the need to modify @GianCann if you're interested, perhaps you could test this patch with your setup, just apply the patch and revert the changes you made in sdkconfig. |
@h2zero I have applied your patch and used the original settings in the |
@corneliusmunz Thank you for testing and I'm glad it works as intended. Will will commit this to master shortly. |
Closing this as resolved. |
Good morning,
I need to connect (from a ESP32 BLE with a client role) to 6-8 peripheral device subscribing notification from these device.
It's possible to do with this library?
The text was updated successfully, but these errors were encountered: