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

[Question] Limiting connections to running hubs #86

Closed
Nelvarion opened this issue Jul 3, 2020 · 14 comments
Closed

[Question] Limiting connections to running hubs #86

Nelvarion opened this issue Jul 3, 2020 · 14 comments
Labels
bug Something isn't working platform: Powered Up Issues related to LEGO Powered Up software: pybricks-code Issues with https://code.pybricks.com application software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: bluetooth Issues involving bluetooth

Comments

@Nelvarion
Copy link

Question
Are there any plans on protecting running hubs from outside connections?
Perhaps limiting pairing only to the computer used to flash the hub?

Context
After uploading a script to a hub and letting it run, you can open the editor and hijack the hub, stopping the running program and allowing you to run any other code.

@Nelvarion Nelvarion added support Request for technical support for a problem that is not a bug or feature request triage Issues that have not been triaged yet labels Jul 3, 2020
@dlech dlech added platform: Powered Up Issues related to LEGO Powered Up software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) and removed triage Issues that have not been triaged yet labels Jul 3, 2020
@dlech
Copy link
Member

dlech commented Jul 3, 2020

Yes, we plan on making the hub no longer connectable once a program has started.

@Nelvarion
Copy link
Author

Good to hear, could be interesting in shows otherwise 😄

@GianCann
Copy link

GianCann commented Jul 3, 2020

we plan on making the hub no longer connectable once a program has started

I hope this feature is programmable, because there are cases where is useful to interact with the hub when the program run.

@Nelvarion
Copy link
Author

@GianCann right now when you connect to hub while it's running it terminates the running processes.
You mean some interactive interrupt?

@GianCann
Copy link

GianCann commented Jul 3, 2020

it terminates the running processes.

No, it's not true (at least with Powered Up Hub).

@GianCann
Copy link

GianCann commented Jul 3, 2020

Watch this video:
https://youtu.be/s1B9pz1sM9U

Se CPlusHun send data to stdout (with Print command) ad you can connect device to read the data. If you disconnect the tablet and connect another tablet to the same BLE service, you continue to see the data output from the Hub.

Only if you send CTRL+C you can stop the program (but you can catch the KeyboardInterrupt exception and manage as you want)

@Nelvarion
Copy link
Author

That was my experience earlier, after pairing with the hub using the web editor the console logged the same message as hitting the stop button

@Nelvarion
Copy link
Author

Seems like you're connecting through some other interface and not the pybrick web editor

@GianCann
Copy link

GianCann commented Jul 3, 2020

Yes @Nelvarion ,
you can connect to nRF UART service exposed by the hub with any BLE client and interact with him.

@dlech dlech added bug Something isn't working and removed support Request for technical support for a problem that is not a bug or feature request labels Aug 5, 2020
@dlech
Copy link
Member

dlech commented Dec 11, 2020

This seems to be a limitation of the Web Bluetooth specification/implementation. Showing connected devices in the device chooser is by design: WebBluetoothCG/web-bluetooth#266. I haven't found a way to work around it (e.g. the gatt.connected property returns false even if the device is already connected in another browser window).

Also see WebBluetoothCG/web-bluetooth#295

@dlech dlech added software: pybricks-code Issues with https://code.pybricks.com application software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) and removed software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) labels Dec 11, 2020
@Nelvarion
Copy link
Author

Can you even reject a connection attempt?

What about the ability to manually add an item or array with a pre-defined name in our scripts, populate it with the desired devices MAC(s) and have it cross-checked when a device attempts to connect?

@dlech
Copy link
Member

dlech commented Dec 11, 2020

Chromium doesn't actually create a 2nd connection to the hub. It shares the underlying OS connection between browser windows. So the hub has no way of knowing which browser window requests are coming from. So I don't think we can do anything in the firmware.

Chromium has some new advertisement watcher APIs that could allow us scan devices differently, but I haven't really looked into it yet since they are still experimental and not available on all OSes. But that is probably the way forward eventually.

Hubs stop advertising when a program is running, so other computers cannot find the hub at that point. The only problem, as I understand it, is multiple connections from the same computer.

@Nelvarion
Copy link
Author

From my perspective as long as the hub is no longer discoverable after starting the program then there's no issue.
At least for this scenario multiple connections from the same computer are not relevant as the assumption is that it's running autonomously.
If/when messaging will be added to PU then it will become important again.

@dlech dlech added the topic: bluetooth Issues involving bluetooth label Jan 19, 2021
@dlech
Copy link
Member

dlech commented Feb 26, 2021

Closing since this is working as much as it technically possible right now. Also see #262.

@dlech dlech closed this as completed Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform: Powered Up Issues related to LEGO Powered Up software: pybricks-code Issues with https://code.pybricks.com application software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: bluetooth Issues involving bluetooth
Projects
None yet
Development

No branches or pull requests

3 participants