Skip to content

tor1kk/mavlink-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MAVLink Wrapper

MAVLink communication wrapper module for Zephyr RTOS.

Adding the module

Add the module to your project's west.yaml:

projects:
    -   name: mavlink-wrapper
        url: https://github.com/tor1kk/mavlink-wrapper.git
        revision: main
        path: modules/mavlink-wrapper
        submodules: true

Configure

prj.conf:

CONFIG_MAVWRAP=y
CONFIG_MAVWRAP_TRANSPORT_NETIF=y
CONFIG_NETWORKING=y
CONFIG_NET_IPV4=y
CONFIG_NET_UDP=y
CONFIG_NET_DHCPV4=y  # optional

DeviceTree

UDP / network interface

/ {
    mavlink: mavlink-wrapper {
        compatible = "mavlink-wrapper";
        transport = <&mac>;
        net-interface;
        net-type = "udp";
        
        use-dhcp;               // or local-ip = "192.168.1.10";
        local-port = <14550>;
        remote-ip = "192.168.1.100";
        remote-port = <14551>;
    };
};

Serial interface

mavlink: mavlink-wrapper {
    compatible = "mavlink-wrapper";
    transport = <&usart1>;
    serial-interface;
};

Usage

#include <mavwrap.h>

const struct device *mav = DEVICE_DT_GET(DT_NODELABEL(mavlink));

void rx_callback(const struct device *dev, const mavlink_message_t *msg, void *data) {
    printk("Got message ID: %u\n", msg->msgid);
}

void main(void) {
    mavwrap_set_rx_callback(mav, rx_callback, NULL);
    
    // Send heartbeat
    mavlink_message_t msg;
    mavlink_msg_heartbeat_pack(1, 1, &msg, 
        MAV_TYPE_QUADROTOR, MAV_AUTOPILOT_GENERIC,
        MAV_MODE_FLAG_SAFETY_ARMED, 0, MAV_STATE_ACTIVE);
    mavwrap_send_message(mav, &msg);
}

About

Zephyr MAVLink wrapper / transport driver

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published