Main Content


Add MAVLink keys from .env file

Since R2023a



    addmavlinkkeys(filename) adds the MAVLink keys stored in the .env file filename to the MATLAB® session. Use MAVLink keys in signing channels for message signing. See the mavlinksigning object for more details.


    collapse all

    Check the contents of the keys.env file. The file contains two keys. Key1 is a 32-element uint8 vector and Key2 is a 32-element uint8 vector encoded using base 64 encoding using the function.

    type keys.env
    Key1 = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32]
    Key2_Base64 = "1xOIT/+tTcjdXaCH794ihyStgzxDll+ZLw3SAzolIu0=" 

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


    List all of the keys in the current MATLAB session.

    keys = lsmavlinkkeys
    keys = 1x2 string
        "Key1"    "Key2"

    Remove both the Key and Key_Base64 MAVLink keys.


    Input Arguments

    collapse all

    MAVLink keys file, specified as a string scalar, string array, or character vector. Use a string array to add keys from multiple .env files simultaneously. You must specify the absolute or relative path to each file, and each file path must end with ".env".

    The files store MAVLink keys in one of these formats:

    • KeyName = KeyValue, where KeyName is the desired key name, and KeyValue is a 32-element uint8 vector.

    • KeyName_Base64 = KeyValueStr, where KeyName is the desired key name, and KeyValueStr is a string scalar converted from a 32-element uint8 vector using base 64 encoding. For more information about base 64 encoding, see the function.

    Example: addmavlinkkeys("keys.env") adds keys from the "keys.env" file on the MATLAB path.

    Data Types: string | char

    Version History

    Introduced in R2023a