Closed phantase closed 4 years ago
I've experienced this myself with Raspbian on the Raspberry Pi, but not on macOS. There's an open issue for it against the Noble project: https://github.com/noble/noble/issues/223. The workaround is here: https://github.com/noble/noble/issues/223#issuecomment-241924168
With this library you can call poweredUP.scan()
again after connecting to the hub. I added this to the library at once point but it had adverse side effects, so I removed it. Hopefully it works for your scenario.
OK, just tested and restarted the scan after the connect.
I will try to find a RPi4 to see if the problem is the same with this model.
In any case it solve my case, thanks, I will continue working/playing/testing on that.
@phantase I had the same issue on RPi3 and fixed this in my fork: https://github.com/nutki/node-poweredup/commit/6cb5c0d621e488adc3e3dbda48abe5454c2f1424 I did not have any further problems with this.
@nutki That exact fix was implemented in this library, but I removed it as it caused a few issues in certain edge cases.
Namely:
I wanted to implement some kind of filtering so it wouldn't try connecting to the same device again if a connection is already in progress, which worked, but the trouble is that Noble gives each device a different peripheral id on every discover. So the original reference was no longer valid.
So, this solution can work well as long as you're willing sequentially connect hubs, waiting for the first to fully connect before turning on the second. But it won't handle disconnects/reconnects very well.
Thanks for this feedback @nutki and this explanation @nathankellenicki I will probably only reactivate scan after a connect.
Hi, I am making some test with this library, my goal is to connect on a Raspberry Pi multiple train and multiple remote.
When I try and adapt the examples, I have the following problem: the scan for new hubs/remotes stop once a device is discovered and the connection is initiated.
I have this following test :
Which will just color the LED of the remote depending of the name of the remote.
When I just turn on one remote, this one is connected and the LED changes color. If I turn on another remote, this remote is never discoverer.
If I turn all my remote at the same time when no other device is connected, all the remote are discovered and the connection to all the remote is made (and the LEDs' color will change).
Of course, same with standard trains hub. When one hub is connected, scan is interrupted and no more hub nor remote can be discovered.
When I disconnect the attached device, the scan restart and new devices can be discovered.
I had a look to the log (
DEBUG=* node scanners.js
) and it seems that the Noble library decide to stop scanning after the connection is enabled. After a look to the code, I don't see why it decide to stop scanning without the stop command.Here is the (long) log:
I am doing my test on a Raspberry Pi 3 and a Raspberry Pi 0 with the integrated Bluetooth. Latest Raspbian (Raspbian GNU/Linux 10 (buster)) Node: v12.13.1 for the RPi3, v11.15.0 for the RPi0 "node-poweredup": "^4.3.0" I can give the full node dependencies if required.
I hope you will be able to give me a hint.
Thanks