Crate maviola

source ·
Expand description

§Maviola

A high-level MAVLink communication library written in Rust.

🇺🇦 repository crates.io docs.rs issues

Maviola provides abstractions such as communication nodes, networks, or devices and implements stateful features of MAVLink protocol: sequencing, message signing, automatic heartbeats, and so on.

This library is a part of Mavka toolchain. It is based on Mavio, a low-level MAVLink library, and compatible with MAVSpec MAVLink dialects generator.

§📖 Documentation

If you want to learn how to use Maviola, start from reading Maviola Playbook. This page contains only a brief introduction.

§Usage

Maviola provides both synchronous and asynchronous API. The synchronous API is available in sync module and can be enabled by sync feature flag. The asynchronous API is based on Tokio, it can be found in asnc module and is enabled by async feature flag.

Here is a simple example of a synchronous TCP server:

use maviola::prelude::*;
use maviola::sync::prelude::*;

// Create a synchronous MAVLink node
// with MAVLink protocol version set to `V2`
let server = Node::sync::<V2>()
     // Set device system and component IDs
     .id(MavLinkId::new(17, 42))
     // Define connection settings
     .connection(TcpServer::new("127.0.0.1:5600")?)
     .build()?;

// Handle node events
for event in server.events() {
     match event {
         // Handle incoming MAVLink frame
         Event::Frame(frame, callback) => {
             // Handle heartbeat message
             if let Ok(DefaultDialect::Heartbeat(msg)) = frame.decode::<DefaultDialect>() {
                 // Respond with the same heartbeat message to all clients,
                 // except the one that sent this message
                 callback.broadcast(&server.next_frame(&msg)?)?;
             }
         }
         _ => {
             /* Handle other node events */
         }
     }
}

You can learn more about this example in Quickstart section that gets into details.

Also check Overview, Synchronous API, and Asynchronous API documentation sections for details on how to use different types of API.

§Features

Maviola is designed to hide most of its functionality under corresponding feature flags. If you need certain features, you have to explicitly opt-in.

§API Modes

These features are not mutually exclusive, you can use both synchronous and asynchronous API in different parts of the project.

Maviola packages standard MAVLink dialects under corresponding feature flags. It is possible to define your own dialects with XML message definitions using MAVSpec or even create your ad-hoc dialects using pure Rust.

Check Dialects documentation section for details.

§Unstable Features

Some parts of the API are still considered to be unstable and available only under the unstable feature flag. We mark unstable and experimental entities with in documentation.

§Embedded Devices

Maviola is based on Mavio, a low-level library with no-std support. If you are looking for a solution for embedded devices, then Mavio would probably be a better option.

Modules§