Skip to content

Comments

Add support for receiving data-lake variables through generic web-socket connections#2383

Merged
rafaellehmkuhl merged 3 commits intobluerobotics:masterfrom
rafaellehmkuhl:allow-generic-websocket-connections
Jan 31, 2026
Merged

Add support for receiving data-lake variables through generic web-socket connections#2383
rafaellehmkuhl merged 3 commits intobluerobotics:masterfrom
rafaellehmkuhl:allow-generic-websocket-connections

Conversation

@rafaellehmkuhl
Copy link
Member

@rafaellehmkuhl rafaellehmkuhl commented Jan 29, 2026

This PR is very simple although very powerful. It basically allows people to create WebSocket servers, connect Cockpit to them and send data to Cockpit through those servers.

This opens the possibility for users to create BlueOS extensions that send data without using MAVLink.

The data that is received is injected in the data-lake.

The data should come in the following format: variableName=variableValue. We support all types supported in the data-lake. The server should send a single variable per message. The server can be a Python script as simple as that:

import asyncio
import websockets

async def handler(websocket):
    while True:
        await websocket.send("coco=abcd")
        await asyncio.sleep(1)

async def main():
    async with websockets.serve(handler, "0.0.0.0", 8765):
        await asyncio.Future()  # run forever

asyncio.run(main())

The PR includes a testing server, and I'm creating an example BlueOS extension as well. The result from the included test server can be seen below:

Cap.2026-01-30.at.14.16.17.mp4

Copy link
Contributor

@ES-Alexander ES-Alexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature - I expect it will be helpful to advanced users, especially for topside software to integrate with Cockpit, and some BlueOS Extensions! :D

In that vein, do you think it's worth adding support for Extensions to list available websocket URLs via the cockpit_extras API, or would it be better to add some kind of event-based advertising support to #2300? At the moment as I understand it users will need to manually set up the websockets, which could be a challenge for some non-technical users, and a bit inconvenient for developers of external software.

I haven't had a chance to test the functionality, but here are some code comments. A couple of minor blockers (🛑), one response (or change) needed (👂), plus some other suggestions.

@rafaellehmkuhl rafaellehmkuhl force-pushed the allow-generic-websocket-connections branch from 9946102 to 2442817 Compare January 30, 2026 15:37
@rafaellehmkuhl
Copy link
Member Author

rafaellehmkuhl commented Jan 30, 2026

@ES-Alexander all suggestions implemented.

I actually expect this feature to evolve to be a primary connection point for those who want to use Cockpit with non-MAVLink vehicles. To evolve on that we basically need to add the support for data-lake variables in the dedicated widgets (e.g.: attitude, virtual-horizon, compass, etc).

Regarding the setup of the web-socket server, I don't think it's difficult at all. Eight lines of Python and one is good to go. I'm including the test server in the PR as an example, and will push an example BlueOS extension as well, so people know how to configure Docker (the only really stranger part).

@rafaellehmkuhl rafaellehmkuhl added the fast-track Solves an important user complaint - only block for major concerns label Jan 30, 2026
@rafaellehmkuhl rafaellehmkuhl force-pushed the allow-generic-websocket-connections branch from 2442817 to 82aced6 Compare January 30, 2026 17:36
Copy link
Contributor

@ES-Alexander ES-Alexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with a couple of Python servers, and it seems to work well - nice! :-)

Regarding the setup of the web-socket server, I don't think it's difficult at all.

I expect devs will be fine setting up the server, especially with the examples 👍

My concern was/is with users needing to know that they need to (and how to) set up a client connection. That's not hard, but it's extra steps and UX complexity for a software to somehow tell the user they need to set up a web-socket, and how/where to do so, and which address to connect it to.

Ideally an Extension (or other software) could just tell Cockpit (via a dedicated API, and/or cockpit_extras) "I have a websocket for you", and Cockpit would confirm with the user if they want to accept it, and if so create the connection for them automatically (with no manual setup/configuration required).

Not a requirement for this PR (we can raise it as an Issue), just noting that's a desirable feature for user-friendliness.

@rafaellehmkuhl
Copy link
Member Author

I tested with a couple of Python servers, and it seems to work well - nice! :-)

Regarding the setup of the web-socket server, I don't think it's difficult at all.

I expect devs will be fine setting up the server, especially with the examples 👍

My concern was/is with users needing to know that they need to (and how to) set up a client connection. That's not hard, but it's extra steps and UX complexity for a software to somehow tell the user they need to set up a web-socket, and how/where to do so, and which address to connect it to.

Ideally an Extension (or other software) could just tell Cockpit (via a dedicated API, and/or cockpit_extras) "I have a websocket for you", and Cockpit would confirm with the user if they want to accept it, and if so create the connection for them automatically (with no manual setup/configuration required).

Not a requirement for this PR (we can raise it as an Issue), just noting that's a desirable feature for user-friendliness.

Got it! Agree that it should enter the cockpit extras at some point. We can do that after we finish the radcam changes. Do you open the issue?

@rafaellehmkuhl rafaellehmkuhl force-pushed the allow-generic-websocket-connections branch from 82aced6 to 800709a Compare January 31, 2026 02:31
@rafaellehmkuhl rafaellehmkuhl merged commit df171b4 into bluerobotics:master Jan 31, 2026
11 checks passed
@rafaellehmkuhl rafaellehmkuhl deleted the allow-generic-websocket-connections branch January 31, 2026 02:40
@ES-Alexander ES-Alexander added the docs-needed Change needs to be documented label Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-needed Change needs to be documented fast-track Solves an important user complaint - only block for major concerns

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants