Represent and work with MAVLink v1/2 message frames
Summary
Functions
Sign an already packed MAVLink 2 frame.
Validate the MAVLink 2 signature trailer for an already parsed signed frame.
Types
@type message() :: XMAVLink.Message.t()
@type t() :: %XMAVLink.Frame{ checksum: 0..65535, compatible_flags: non_neg_integer(), crc_extra: XMAVLink.Types.crc_extra(), incompatible_flags: non_neg_integer(), mavlink_1_raw: binary() | nil, mavlink_2_raw: binary() | nil, message: message() | nil, message_id: XMAVLink.Types.message_id(), payload: binary(), payload_length: 0..255, sequence_number: 0..255, signature: XMAVLink.Frame.Signature.t() | nil, source_component: 1..255, source_system: 1..255, target: :broadcast | :system | :system_component | :component, target_component: 0..255, target_system: 0..255, version: version() }
@type version() :: 1 | 2
Functions
@spec sign_frame(t(), <<_::256>>, 0..255, 0..281_474_976_710_655) :: {:ok, t()} | {:error, :already_signed | :checksum_invalid | :invalid_crc_extra | :invalid_link_id | :invalid_mavlink_2_frame | :invalid_secret_key | :invalid_timestamp | :mavlink_1_not_signable | :missing_crc_extra | :missing_mavlink_2_raw | :unsupported_incompatible_flags}
Sign an already packed MAVLink 2 frame.
This is a low-level frame utility. It sets MAVLINK_IFLAG_SIGNED,
recalculates the checksum for the signed header, and appends the 13-byte
MAVLink 2 signature trailer. It does not manage link timestamp state or
router/connection signing policy. The existing packed frame checksum must
already match the frame's crc_extra.
@spec signed?(t() | non_neg_integer()) :: boolean()
@spec validate_and_unpack(t(), module(), XMAVLink.Signing.t() | nil) :: {:ok, t(), XMAVLink.Signing.t() | nil} | {:unknown_message, XMAVLink.Signing.t() | nil} | {:error, :failed_to_unpack | :checksum_invalid | :unknown_message | XMAVLink.Signing.validate_error(), XMAVLink.Signing.t() | nil}
@spec validate_signature(t(), <<_::256>>) :: :ok | {:error, :invalid_secret_key | :invalid_mavlink_2_frame | :signature_invalid | :unsigned_frame}
Validate the MAVLink 2 signature trailer for an already parsed signed frame.
This only verifies the cryptographic signature over the signed packet bytes. It does not enforce timestamp replay rules or unpack the frame payload.