Novakasa / brickrail

LEGO Train automation software for PoweredUp
MIT License
88 stars 7 forks source link

[Feature] Web interface #124

Open Xayer opened 1 year ago

Xayer commented 1 year ago

Describe the solution you'd like

First of all this project looks fantastic, and reminds me alot of Brick Automation Project.

The biggest thing most projects are missing is a web interface.

Similar to the pybricks interface running entirely in a webapp, I was wondering if it made sense to move the application to be based?

The first step would be to watch the websocket connection, or potentially be able to host the actual server on one device, and connect to it via the web interface. This would alleviate the need for seperate build steps.

Describe alternatives you've considered If possible, export the GUI to Wasm, and make it possible for other clients to only "view" the layout, with no edit permissions.

Novakasa commented 1 year ago

Thanks for checking out the project!

Overall, I do think that porting brickrail to the web would make the software much more accessible. If the whole software would be contained in the web, many more platforms could be used to run brickrail, and it is something I am thinking about, but the bluetooth situation makes it quite difficult for me.

However, it sounds like you are looking for something slightly different? If I understand correctly you would like to be able to control the trains from the web, from any device, that is not necessarily the device connected via bluetooth to the trains. To understand the request better, in what way would that help your layout concretely? Are you looking to control the trains via a tablet or phone?

Xayer commented 1 year ago

Thanks for checking out the project!

Overall, I do think that porting brickrail to the web would make the software much more accessible. If the whole software would be contained in the web, many more platforms could be used to run brickrail, and it is something I am thinking about, but the bluetooth situation makes it quite difficult for me.

The Bluetooth protocol should be available in a web browser. However the api can be a bit tedious to work with. I am just looking for ways where users do not need to have their computer turned on, or have a specific OS to run software like this.

However, it sounds like you are looking for something slightly different? If I understand correctly you would like to be able to control the trains from the web, from any device, that is not necessarily the device connected via bluetooth to the trains. To understand the request better, in what way would that help your layout concretely? Are you looking to control the trains via a tablet or phone?

I am looking to broadcast the layout and the train events to other devices that are not necessarily the host. I'm thinking for exhibitions where visitors could scan a QR code and follow the trains around on the track.

It's nothing but an idea at this point, but I think it could be fun. I could of course just sniff the websocket connection and make a web map for now as a proof of concept.

Novakasa commented 1 year ago

The Bluetooth protocol should be available in a web browser. However the api can be a bit tedious to work with. I am just looking for ways where users do not need to have their computer turned on, or have a specific OS to run software like this.

Yeah, looking at e.g. the pybricks code webapp, discovering and connecting to hubs there seems to require some actions by the user, whereas brickrail can already do a lot automatically as long as all the hubs are turned on. I do not know the web bluetooth API yet, but my guess is that the user confirmation for every connection is needed due to security reasons.

I am looking to broadcast the layout and the train events to other devices that are not necessarily the host. I'm thinking for exhibitions where visitors could scan a QR code and follow the trains around on the track.

That definitely would be cool. It is however not straightforward to implement, currently the websocket connection only communicates low-level commands between GUI and hubs. So, essentially it contains commands to the trains and sensor feedback from the trains, but nothing concrete about the virtual layout.

For what you describe, it probably would be better to add a new API open to the web that allows getting current info about the virtual layout.

Xayer commented 1 year ago

That definitely would be cool. It is however not straightforward to implement, currently the websocket connection only communicates low-level commands between GUI and hubs. So, essentially it contains commands to the trains and sensor feedback from the trains, but nothing concrete about the virtual layout

For now it'd be alright to het the layout statically, and require the users to reload the page to see new changes.

For what you describe, it probably would be better to add a new API open to the web that allows getting current info about the virtual layout.

Yeah that'd be awesome if possible.