Module meshtastic::api
source · Expand description
This module contains the main API for interacting with Meshtastic devices.
This module exposes the StreamApi
and ConnectedStreamApi
structs, as well
as helper states within the state
module.
The user will create a new instance of the API through calling the StreamApi::new()
method. This will return a new StreamApi
instance. The only method that is exposed
on this struct is the connect
method. This is a compile-time check to force the user
of the library to connect to a radio before attempting to send data onto the mesh.
If successful, the connect
method will return a tuple of the ConnectedStreamApi
instance, as well as a PacketReceiver
. The PacketReceiver
is a tokio channel
that can be used to listen to incoming packets from the radio. Since the user is now
connected to the radio. the resulting ConnectedStreamApi
instance will then be able
to access the configure
method, as well as some additional low-level sender methods.
The configure
method requests the current radio configuration, will return an updated
instance of the ConnectedStreamApi
struct. This resulting instance will then have access
to the full set of API sender methods.
To disconnect from the radio, the user can call the disconnect
method at any time.
Modules§
- These structs are needed to guarantee that the
StreamApi
struct connection methods are called in the correct order. This is done by using the typestate pattern, which is a way of using the type system to enforce state transitions.
Structs§
- A struct that provides a high-level API for communicating with a Meshtastic radio.
- A struct that provides a high-level API for communicating with a Meshtastic radio.
- A struct that provides a reference to an underlying stream for reading/writing data and potentially an accompanying join handle that processes data on the other side of the stream.