mavlink v0.7.0 MAVLink.Router View Source

Connect to serial, udp and tcp ports and listen for, validate and forward MAVLink messages towards their destinations on other connections and/or Elixir processes subscribing to messages.

The rules for MAVLink packet forwarding are described here:

https://mavlink.io/en/guide/routing.html

and here:

http://ardupilot.org/dev/docs/mavlink-routing-in-ardupilot.html

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Send a MAVLink message to one or more recipients using available connections. For now if destination is unreachable it will fail silently.

Subscribes the calling process to messages matching the query. Zero or more of the following query keywords are supported

Un-subscribes calling process from all existing subscriptions

Link to this section Types

Link to this type

subscribe_query_id_key() View Source
subscribe_query_id_key() ::
  :source_system | :source_component | :target_system | :target_component

Link to this type

t() View Source
t() :: %MAVLink.Router{
  component: non_neg_integer(),
  connection_strings: [String.t()],
  connections: %{},
  dialect: module() | nil,
  routes: %{mavlink_address: {mavlink_connection(), MAVLink.Types.version()}},
  sequence_number: MAVLink.Types.sequence_number(),
  subscriptions: [],
  system: non_neg_integer(),
  uarts: [pid()]
}

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

pack_and_send(message, version \\ 2) View Source

Send a MAVLink message to one or more recipients using available connections. For now if destination is unreachable it will fail silently.

Link to this function

start_link(state, opts \\ []) View Source
start_link(
  %{
    dialect: module(),
    system: non_neg_integer(),
    component: non_neg_integer(),
    connection_strings: [String.t()]
  },
  [{atom(), any()}]
) :: {:ok, pid()}

Link to this function

subscribe(query \\ []) View Source
subscribe([{:message, MAVLink.Message.t()} | {subscribe_query_id_key(), 0..255}]) ::
  :ok

Subscribes the calling process to messages matching the query. Zero or more of the following query keywords are supported:

message: message_module source_system: integer 0..255 source_component: integer 0..255 target_system: integer 0..255 target_component: integer 0..255 as_frame: true|false (default false)

For example:

  MAVLink.Router.subscribe message: MAVLink.Message.Heartbeat, source_system: 1
Link to this function

unsubscribe() View Source
unsubscribe() :: :ok

Un-subscribes calling process from all existing subscriptions