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
//! Interface to the ARDOP modem
//!
//! This module contains:
//!
//! * [ArdopTnc](struct.ArdopTnc.html): The main interface
//! to ARDOP
//! * [DiscoveredPeer](struct.DiscoveredPeer.html): A peer discovered
//! by monitoring
//! * [PingAck](struct.PingAck.html): Responses to ping requests
//! * [TncError](enum.TncError.html): Errors which occur
//! with the *local* ARDOP TNC, such as a broken TCP
//! connection
//! * [TncResult](type.TncResult.html): The `Result` type
//! for TNC operations.
//!
//! # Example
//!
//! ```no_run
//! use std::net::SocketAddr;
//! use async_std::prelude::*;
//! use futures::prelude::*;
//!
//! use ardop_interface::tnc::*;
//!
//! fn main() {
//! async_std::task::block_on(async {
//! let addr = "127.0.0.1:8515".parse().unwrap();
//! let mut tnc = ArdopTnc::new(&addr, "MYC4LL")
//! .await
//! .unwrap();
//! match tnc.version().await {
//! Ok(version) => println!("Connected to TNC version {}", version),
//! Err(e) => println!("Can't query TNC version: {}", e)
//! }
//! if let Err(e) = tnc.set_gridsquare("EM00").await {
//! println!("Can't set GRIDSQUARE: {}", e);
//! }
//! })
//! }
//! ```
//!
//! # TNC Commands
//!
//! `ardop_interface` supports the following common TNC commands.
//! More commands are listed on the `ArdopTnc`
//! [page](struct.ArdopTnc.html).
//!
//! * [`ARQCALL`](struct.ArdopTnc.html#method.connect)
//! * [`LISTEN`](struct.ArdopTnc.html#method.listen)
//! * [`ARQTIMEOUT`](struct.ArdopTnc.html#method.set_arqtimeout)
//! * [`CWID`](struct.ArdopTnc.html#method.set_cwid)
//! * [`GRIDSQUARE`](struct.ArdopTnc.html#method.set_gridsquare)
//! * [`LEADER`](struct.ArdopTnc.html#method.set_leader)
//! * [`MYAUX`](struct.ArdopTnc.html#method.set_myaux)
//! * [`PING`](struct.ArdopTnc.html#method.ping)
//! * [`VERSION`](struct.ArdopTnc.html#method.version)
//! * [`TWOTONETEST`](struct.ArdopTnc.html#method.twotonetest)
//!
//! All commands are sent with a reasonable (and adjustable) timeout.
//! If the TNC fails to respond in a timely manner, a
//! [TncError](enum.TncError.html) is raised.
//!
//! # Error Handling
//!
//! Most operations on the [ArdopTnc](struct.ArdopTnc.html) return
//! a [TncResult](type.TncResult.html). If the TNC rejects your command,
//! then the `Err()` half of the result will be set to the reason for
//! the failure. For example, attempting to make an ARQ connection while
//! already connected will probably raise a TNC error.
//!
//! TNC operations which interface with a remote peer can also fail.
//! These failures are contained in an *inner* error structure. For
//! example, if a peer rejects a connection due to a bandwidth mismatch,
//! then [`connect()`](struct.ArdopTnc.html#method.connect) will return
//! `Ok(Err(ConnectionFailedReason::IncompatibleBandwidth))`. The outer
//! error indicates that the TNC successfully attempted the command, and
//! the inner error indicates that the peer rejected (or did not answer)
//! it.
pub use ;
pub use DiscoveredPeer;
pub use ;
pub use ;