Skip to content
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

Unable to connect multiple hubs since release 1.0.4 #46

Open
Mattze0815 opened this issue Dec 22, 2020 · 8 comments
Open

Unable to connect multiple hubs since release 1.0.4 #46

Mattze0815 opened this issue Dec 22, 2020 · 8 comments

Comments

@Mattze0815
Copy link

Hi @corneliusmunz,
we appreciate the non-blocking connection procedure introduced with release 1.0.4. This is a great improvement, thank you very much for that.

We have experienced the following problem:

  • We want to connect to multiple hubs.
  • You call init() for multiple hubs BEFORE the hubs actually connect to the PC.
  • Only the last hub that was initialised will be connected, not the other ones.

We had to create a relatively complitcated work around to overcome this problem.

Maybe you could have a look into this?

Thanks!

@Mattze0815
Copy link
Author

Mattze0815 commented Dec 22, 2020

FYI: problem also exists in 1.1.0.

@corneliusmunz
Copy link
Owner

Hi @Mattze0815 ! Yes.. unfortunately that behaviour is strictly related to the "non blocking" behaviour. I think that is good but also "evil" I have discussed this with @fvanroie: #41 (comment) I think i will revert the non blocking behaviour because it needs a very complicated logic to detect if scans are already ongoing and unfortunately if a scan is ongoing, a hub could not be connected at the same time. This is related to a constraint in the NimBLE stack : h2zero/NimBLE-Arduino#58 (comment)

@corneliusmunz
Copy link
Owner

@Mattze0815 Maybe i will add a optional parameter to enforce non-blocking scans but not as a default behaviour. I am currently working on a HubManager which will have the logic and boilerplate inside if you want to have a system with different hubs: #41 (comment)

@fvanroie
Copy link

I can make a post of my multi-hub project. The code is not pretty but it works with both scan methods.
Or if you add me to the mattzo-controller repo, I'll have a look!

@corneliusmunz
Copy link
Owner

@fvanroie would be great if you could send me your working example or post it here.

@Mattze0815
Copy link
Author

Mattze0815 commented Dec 23, 2020

Hi guys, your answers are much appreciated, thank you.

I would very strongly wish to keep the non-blocking connectivity feature, even with the present limitation. I have build a work around, and it appears to work quite stable. It's just not very elegant.

@fvanroie, I will add you to MattzoBricks shortly and give you some instructions of were to look. Thanks in advance!

@fvanroie
Copy link

I have uploaded my PUp TrainController project as a github repo. The main interest is in ble_setup() and ble_hub_task() functions.

@Mattze0815
Copy link
Author

@fvanroie, access granted.

Look for the MattzoController/MTC4PU folder. You need to copy the MattzoController/libraries/MattzoBricks folder to your Arduino library folder.

Connecting multiple hubs is possible (successfully tested with 8 concurrently connected hubs), but they need to be connected exactly in the order as specified in MTC4PU_Configuration.h.

Enjoy the fun: https://github.com/Mattze0815/roc2bricks

More general info here: www.mattzobricks.com

@Mattze0815 Mattze0815 changed the title Unable to connect multiple hub since release 1.0.4 Unable to connect multiple hubs since release 1.0.4 Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants