pub struct MeshRadio<R> { /* private fields */ }Expand description
A node on a LoRa mesh: a radio, the node’s address, and the rules it keeps.
Build it around a configured radio, connect to start listening,
then send and receive as over any other pamoja transport.
Implementations§
Source§impl<R: LoraRadio> MeshRadio<R>
impl<R: LoraRadio> MeshRadio<R>
Sourcepub fn new(radio: R, node: u32, duty_cycle_permille: u32) -> MeshRadio<R>
pub fn new(radio: R, node: u32, duty_cycle_permille: u32) -> MeshRadio<R>
Builds a node around a radio that is already configured.
Frames start with [Frame::DEFAULT_HOP_LIMIT] hops, and the node relays what it
hears.
§Arguments
radio- the radio, tuned to the channel the mesh uses.node- this node’s address, which every frame it sends carries as its source.duty_cycle_permille- the region’s duty-cycle limit in parts per thousand, such as10for 1%, or1000where the region sets none.
§Returns
The node, not yet connected.
Sourcepub fn with_hop_limit(self, hop_limit: u8) -> MeshRadio<R>
pub fn with_hop_limit(self, hop_limit: u8) -> MeshRadio<R>
Sourcepub fn without_relaying(self) -> MeshRadio<R>
pub fn without_relaying(self) -> MeshRadio<R>
Returns the node with relaying off, so it only sends and receives its own traffic.
§Returns
The node.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Sourcepub fn duty_cycle(&self) -> &DutyCycle
pub fn duty_cycle(&self) -> &DutyCycle
Returns the duty-cycle guard, to see how long the radio must still stay silent.
§Returns
The guard, whose clock is microseconds since the node was built.
Trait Implementations§
Source§impl<R: LoraRadio + Send> Receive for MeshRadio<R>
impl<R: LoraRadio + Send> Receive for MeshRadio<R>
Source§async fn recv(&mut self) -> Result<Option<Message>>
async fn recv(&mut self) -> Result<Option<Message>>
Awaits the next message whose topic a subscription matches.
A frame relayed on the way is sent before the message is handed up, and a message already taken off the air waits in the node if the call is dropped meanwhile, so nothing received is lost to a cancellation.
§Returns
The next message; the air never ends, so never None.
§Errors
Returns [Error::Closed] before connect, and
[Error::Transport] if the radio fails.