Main Content


Store MAVLink signing channel information

Since R2022a


    The mavlinksigning enables you protect UAVs from unauthorized communication using message signing. Use this object to store up to 16 MAVLink signing channels, and use the addmavlinkkeys, lsmavlinkkeys, rmmavlinkkeys functions to add, list, and remove MAVLink keys in the current MATLAB session for use with signing channels.


    Note that message signing is not the same as message encryption. MAVLink does not provide message encryption. See MAVLink Message Signing (Authentication) for more details about MAVLink message signing.




    stream = mavlinksigning creates a mavlinksigning object to store signing channels.

    Object Functions

    addChannelAdd MAVLink signing channel
    removeChannelRemove MAVLink signing channel


    collapse all

    Create a mavlinksigning object to store MAVLink signing channels.

    stream = mavlinksigning;

    Load and list the keys from the keys.env file.

    ans = 1x2 string
        "Key1"    "Key2"

    Add channel with a system ID of 1, component ID of 2, link ID of 3.

    ans = struct with fields:
              Stream: [1x1 mavlinksigning]
            SystemID: 1
         ComponentID: 2
              LinkID: 3
                 Key: "Key1"
           Timestamp: 25778414177899
        CreationTime: 03-Mar-2023 14:42:21

    Remove the same channel.


    Add MAVLink signing keys from the keys.env file to the MATLAB session.

    ans = 1x2 string
        "Key1"    "Key2"

    Create MAVLink signing streams for UAV and the ground control system.

    signingStream = mavlinksigning;
    signingChannelUAV = signingStream.addChannel(1,1,1,"Key1");
    signingChannelGCS =  signingStream.addChannel(255,1,1,"Key1");

    Create signed dialect and MAVLink IO object.

    dialectUAV = mavlinkdialect("common.xml",2,SigningChannel=signingChannelUAV);
    dialectGCS = mavlinkdialect("common.xml",2,SigningChannel=signingChannelGCS);
    ioUAV = mavlinkio(dialectUAV);

    Create signed message and display the signature at the end of the buffer.

    msg = dialectUAV.createmsg("HEARTBEAT");
    buffer = ioUAV.serializemsg(msg)
    buffer = 1x34 uint8 row vector
       253     9     1     0     0     1     1     0     0     0     0     0     0     0     0     0     0     0     3    86    89     1   123   219   228     3   114    23   120     7    70   191    57    57

    Read the signed message.

    [msgReceived,status] = dialectGCS.deserializemsg(buffer,OutputAllMessages=true)
    msgReceived = struct with fields:
              MsgID: 0
           SystemID: 1
        ComponentID: 1
            Payload: [1x1 struct]
                Seq: 0
    status = 0

    Version History

    Introduced in R2022a