MissionPlanner icon indicating copy to clipboard operation
MissionPlanner copied to clipboard

Add MAVLink forwarding via WebSocket server

Open IamPete1 opened this issue 1 year ago • 6 comments

This adds forwarding to WebSockets. I have only tested sending from MissionPlanner to the WebSocket not the other way (my application does not support send). So far I have been using pymavlink with https://github.com/ArduPilot/pymavlink/pull/967.

This very hacky currently. It doesn't work if you open the same connection more than once for example. I'm not cleaning up correctly I guess, but this is right on the edge of my c# knowledge.

This does add Fleck as a new dependency, it makes the server stuff easier. https://github.com/statianzo/Fleck

This is more or less a Fleck example and code copied from the existing client WebServer stuff.

IamPete1 avatar Sep 28 '24 14:09 IamPete1

https://github.com/ArduPilot/MissionPlanner/blob/693c6e3445af310d90fe90daa29f40df6bd64fc6/Utilities/httpserver.cs#L180

This is the internal server I mentioned.

Looks like your code is a client though, vs the existing is serverside

meee1 avatar Sep 28 '24 16:09 meee1

My use case was a browser connecting to MP as the data source

Yours is to push data to somewhere?

meee1 avatar Sep 28 '24 16:09 meee1

https://github.com/ArduPilot/MissionPlanner/blob/693c6e3445af310d90fe90daa29f40df6bd64fc6/ExtLibs/Comms/CommsWebSocket.cs#L16

This one is for connecting to a socketio ws service as a client

meee1 avatar Sep 28 '24 16:09 meee1

My use case was a browser connecting to MP as the data source

Yours is to push data to somewhere?

Right, mission planner connects directly to the vehicle then it forwards onto a web based dashboard.

IamPete1 avatar Sep 28 '24 16:09 IamPete1

I assume you have something working? As I would have thought the dashboard makes the connection to the backend vs the backend connecting to the frontend

Ws://127.0.0.1:56781/websocket/server

Ws://127.0.0.1:56781/websocket/raw

Http://127.0.0.1:56781/hud.html

Example

     https://yar.oborne.me/

meee1 avatar Sep 28 '24 16:09 meee1

I assume you have something working?

https://github.com/IamPete1/WebTools/tree/MAVLink_Dashboard

As with all the WebTools it is 100% client side, so the only option we have is WebSocket client (we could do direct COM ports too but I haven't implemented).

IamPete1 avatar Sep 28 '24 16:09 IamPete1

Turns out MissionPlanner already forwards on ws://127.0.0.1:56781. So we don't need this PR. https://github.com/ArduPilot/WebTools/pull/196 adds auto connection.

IamPete1 avatar Oct 24 '24 09:10 IamPete1