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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! # Maviola synchronous API
//!
//! Synchronous API is built around MAVlink [`Node`] with [`SyncApi`]. Upon construction, each node
//! operates on a particular connection. The latter is owned by a node and defines underlying
//! transport (e.g. TCP, UDP, Unix socket). Each connection spawns one or several channels. For
//! example, TCP server creates a channel per each incoming connection. Abstractions related to
//! channels and connections are defined in the [`io`] module.
//!
//! ## Usage
//!
//! To use asynchronous API, you have to first configure node builder using
//! [`Node::sync`](crate::core::node::Node::sync). For example, the following snippet will create
//! an asynchronous TCP client:
//!
//! ```rust,no_run
//! use maviola::prelude::*;
//!
//! let addr = "127.0.0.1:5600";
//!
//! // Create a TCP client node
//! let node = Node::sync::<V2>()
//! /* define other node parameters */
//! # .system_id(1)
//! # .component_id(1)
//! .connection(
//! TcpClient::new(addr) // Configure TCP client connection
//! .unwrap()
//! ).build().unwrap();
//! ```
//!
//! ## Transport
//!
//! The following transports are currently available:
//!
//! * TCP: [`TcpServer`] / [`TcpClient`]
//! * UDP: [`UdpServer`] / [`UdpClient`]
//! * File: [`FileWriter`] / [`FileReader`]
//! * Unix socket: [`SockServer`] / [`SockClient`] (only on Unix-like systems such as Linux or OS X)
//!
//! Connection-level information about each transport is available as a variant of
//! [`ConnectionInfo`](crate::core::io::ConnectionInfo). Channel information is provided by
//! [`ChannelInfo`](crate::core::io::ChannelInfo).
//!
//! ## Events
//!
//! The suggested approach for handling connection with several MAVLink devices is subscribing for
//! [`Node::events`]. This method provides an iterator over all node events. Incoming frames are
//! emitted as [`Event::Frame`]. Such events contain a [`Frame`] / [`Callback`] pair. The latter can
//! be used to respond to a channel from which frame was received or broadcast it to all channels
//! (or, alternatively, to all channels except the one which delivered the original frame).
//!
//! ### Peers
//!
//! Each node handles incoming frame and monitors MAVLink devices represented as
//! [`Peer`](crate::protocol::Peer) objects using MAVLink
//! [heartbeat](https://mavlink.io/en/services/heartbeat.html) protocol. Upon discovery of a peer,
//! an [`Event::NewPeer`] event is emitted. When peers is lost due to missing heartbeats, then
//! [`Event::PeerLost`] is emitted.
//!
//! It is possible to get a list of active peers by [`Node::peers`] or check for peers availability
//! using [`Node::has_peers`].
//!
//! ## Custom connections
//!
//! It is possible to create a custom connection by implementing a
//! [`ConnectionBuilder`](io::ConnectionBuilder) trait. For Custom connections there are reserved
//! [`ConnectionDetails::Custom`](crate::core::io::ConnectionDetails::Custom) and
//! [`ChannelDetails::Custom`](crate::core::io::ChannelDetails::Custom) variants. Check for other
//! relevant abstractions in [`io`] module.
//!
//! ## Low-level I/O
//!
//! Low-level I/O primitives are available in [`core::io`](crate::core::io). Most of these
//! abstractions are re-exported from [Mavio](https://crates.io/crates/mavio), a low-level MAVLink
//! library which serves as a basis for Maviola.
use crate*;
use crate*;
pub