Cockpit usually gets its MAVLink messages through a MAVLink2REST interface provided by BlueOS. It is technically possible to switch it over to using a UDP MAVLink connection, but doing so requires the whole connection to be switched to that (so you would also need to change where/how your vehicle is trying to connect, or lose access to it).
The easiest way to get messages to Cockpit is to send them through the existing MAVLink routing functionality on the vehicle, which you can do either by
- Connecting to a MAVLink Endpoint in BlueOS with your code, using a library like Pymavlink
- This is closest to your current code
- You may need to set up a new endpoint, if the others are already in use by other services
- Directly sending the message to the BlueOS MAVLink2REST interface, via a HTTP request
- This avoids needing a MAVLink library, and the connections to and handling of data streams
- There are several BlueOS services and Extensions that do this, because it uses substantially fewer resources if your program doesn’t actually need access to all the data in the MAVLink stream
For future reference, we’re also in the process of adding a means to just directly send data to Cockpit via HTTP requests, without MAVLink required at all.