Main Content

mavlinksigning

Store MAVLink signing channel information

Since R2022a

    Description

    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

    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.

    Creation

    Description

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

    example

    Object Functions

    addChannelAdd MAVLink signing channel
    removeChannelRemove MAVLink signing channel

    Examples

    collapse all

    Create a mavlinksigning object to store MAVLink signing channels.

    stream = mavlinksigning;

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

    addmavlinkkeys("keys.env");
    lsmavlinkkeys
    ans = 1×2 string
        "Key1"    "Key2"
    
    

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

    addChannel(stream,1,2,3,"Key1")
    ans = struct with fields:
              Stream: [1×1 mavlinksigning]
            SystemID: 1
         ComponentID: 2
              LinkID: 3
                 Key: "Key1"
           Timestamp: 31835935982956
        CreationTime: 01-Feb-2025 17:09:19
    
    

    Remove the same channel.

    removeChannel(stream,1,2,3)

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

    addmavlinkkeys("keys.env")
    lsmavlinkkeys
    ans = 1×2 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 = 1×34 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   176   165    13   100   244    28     0   253   178   211    60   164
    
    

    Read the signed message.

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

    Version History

    Introduced in R2022a