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
//! # API extensions for asynchronous MAVLink node
pub
pub
pub use AsyncApi;
pub use Callback;
pub use Event;
pub use ;
pub use EventReceiver;
pub use FrameSender;
use crate;
use crateNode;
/// <sup>[`async`](crate::asnc)</sup>
/// Asynchronous node representing an edge MAVLink device.
///
/// An edge node is a MAVlink device with defined system `ID` and component `ID`. It can send and
/// receive MAVLink messages, emit automatic heartbeats and perform other active tasks.
///
/// # Examples
///
/// Create an asynchronous TCP server node:
///
/// ```rust,no_run
/// # #[tokio::main(flavor = "current_thread")] async fn main() {
/// use tokio_stream::StreamExt;
/// use maviola::prelude::*;
/// use maviola::asnc::prelude::*;
///
/// let addr = "127.0.0.1:5600";
///
/// // Create a node from configuration
/// let mut node = Node::asnc::<V2>()
/// .system_id(1) // System `ID`
/// .component_id(1) // Component `ID`
/// .connection(
/// TcpServer::new(addr) // Configure TCP server connection
/// .unwrap()
/// ).build().await.unwrap();
///
/// // Activate node to start sending heartbeats
/// node.activate().await.unwrap();
///
/// // Process incoming events
/// let mut events = node.events().unwrap();
/// while let Some(event) = events.next().await {
/// match event {
/// Event::NewPeer(peer) => {
/// /* handle a new peer */
/// }
/// Event::PeerLost(peer) => {
/// /* handle a peer, that becomes inactive */
/// }
/// Event::Frame(frame, res) => {
/// // Send back any incoming frame directly to its sender's channel
/// res.respond(&frame).unwrap();
/// }
/// Event::Invalid(frame, err, callback) => {
/// /* Process invalid frame */
/// }
/// }
/// }
/// # }
/// ```
pub type EdgeNode<V> = ;
/// <sup>[`async`](crate::asnc)</sup>
/// Asynchronous node representing a MAVLink proxy.
pub type ProxyNode<V> = ;