-
Notifications
You must be signed in to change notification settings - Fork 26
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
LEGO boost #34
Comments
@ratschan Thanks for this report. Today, I tried to dig into this, but still not sure what is happening. Your report with -d command just says the device was disconnected, but it has no clue of the disconnection cause. I tried to recreate this issue with my environment and my micro:bit. I once succeeded to recreate very similar issue. The connection to my micro:bit failed with the message below:
When I repeat it, the failure was recreated a few times (sometimes succeeded, and sometimes failed). As a next step, I tried to run scratch_link.py in place of the scratch_link command.
This command did not recreate the failure. I'm not sure why, because the scratch_link command is just running the scrach_link.py. After that, I tried to recreate the failure with the scratch_link command, I can no longer recreate the failure... This is sad, since if the failure would be recreated on my system, it was easier for me to chase it down. And I'm not sure why the failure disappeared. Today, I stop here. If you have time, please try to run the scratch_link.py instead of scratch_link command and see if the failure is recreated or not. |
Thanks a lot for taking the time to look into this and for your suggestion. Unfortunately, the way of starting scratch_link does not make a difference. I will try to read and understand your code in detail, maybe this will allow me to find the problem. Anyway, would you maybe have an output of scratch_link -d available that shows how it would look like if everything works correctly? This would help me to understand what goes wrong ... |
FYI, here's the scratch_link -d outputs with my system and my micro:bit. If you see the word "match..." the scratch_link finds out the devices to list in Scratch dialog.
My current guess is that the failure happened in _scan_devices(), at the line to call scanner.scan(). This scan() is bluepy API. So I guess we need to dig into bluepy layer, and which is a rather hard work for me. |
Thanks a lot! I works now by simply executing "hciconfig hci0 down" before starting scratch_link. Btw., on another machine with a fresh Ubuntu 22.04 installation I had to do a change to gencert.py to make it work. The reason is that firefix directory is not ~/.mozilla any more, but ~/snap/firefox/common/.mozilla. Anyway, thanks a lot for your work! It is really great to have this available! |
As for the NSS DB path difference of the Snap package, I created a fix commit at "snap" branch. Will do some more evaluation before merging to the master branch. |
An update on my follow-up work: I've merged the fix for Snap packages. Today, I spent some more time using my old laptop with Ubuntu 22.04 LTS. It recreates the BTLEDisconnectError in stable manner. I still do not understand the cause, but I confirmed that the error happens at scanner.scan(). I also found that if the scanner.scan() calls is repeated, the error can be worked around. As a temporary work around solution, I implemented "-r" option of scratch_link. With "-r 2" option, I see the error can be avoided. Using -s command together, "scratch_link -r 2 -s 3" command works stable in my environments. With these changes, I released pyscrlink version 0.2.7, even though I'm not sure the -r option help you or not. |
I can confirm that
makes the difference in connecting successfully to the LEGO BOOST hub. Thank you for your work! |
I am trying to connect to LEGO boost from Ubuntu/Firefox/Scratch via a BLE dongle using pyscrlink. Installation (following the instructions at https://github.com/kawasaki/pyscrlink) works fine. But trying to connect from Scratch, as described in the instructions, fails, the LEGO boost extension saying "no devices found". Doing so, scratch_link -d outputs the following:
Print debug messages
2023-02-25 15:52:14,387 set scan_seconds: 10.0
2023-02-25 15:52:14,412 Certificate is ready in FireFox NSS DB: /home/ratschan/.mozilla/firefox/wx5xyc5d.default-release
2023-02-25 15:52:15,271 Certificate is ready in FireFox NSS DB: /home/ratschan/.mozilla/firefox/dj0c5tt0.default
2023-02-25 15:52:15,301 Certificate is ready for Chrome
2023-02-25 15:52:15,356 Started scratch-link
2023-02-25 15:54:57,652 Start session for web socket path: /scratch/ble
2023-02-25 15:54:57,652 start session handler
2023-02-25 15:54:57,652 start recv_request
2023-02-25 15:54:57,754 start recv_request
2023-02-25 15:54:57,754 request: {"jsonrpc":"2.0","method":"discover","params":{"filters":[{"services":["00001623-1212-efde-1623-785feabcd123"],"manufacturerData":{"919":{"dataPrefix":[0,64],"mask":[0,255]}}}],"optionalServices":[]},"id":0}
2023-02-25 15:54:57,754 handle request to BLE device
2023-02-25 15:54:57,754 discover
2023-02-25 15:54:57,754 {'filters': [{'services': ['00001623-1212-efde-1623-785feabcd123'], 'manufacturerData': {'919': {'dataPrefix': [0, 64], 'mask': [0, 255]}}}], 'optionalServices': []}
2023-02-25 15:54:57,763 start BLE scan: 10.0 seconds
2023-02-25 15:55:07,788 Failure in session for web socket path: /scratch/ble
2023-02-25 15:55:07,788 BTLEDisconnectError: Device disconnected
I also tried to follow the steps "at In Case You Fail to Connect" but could not really make sense of the instructions. Opening "https://device-manager.scratch.mit.edu:20110/" in the browser, I get "Failed to open a WebSocket connection: invalid Connection header: keep-alive. You cannot access a WebSocket server directly with a browser. You need a WebSocket client.". But the instructions say "This is expected". Now I do not understand what to conclude from this ...
The text was updated successfully, but these errors were encountered: