Module meshtastic::utils
source · Expand description
This module exposes utility functions that aren’t fundamental to the operation of the library, but simplify the configuration and usage of member methods.
The DEFAULT_DTR_PIN_STATE
and DEFAULT_RTS_PIN_STATE
constants are used to define the
default pin states of the DTR and RTS pins of the serial connection. The DEFAULT_SERIAL_BAUD
constant is used to define the default baud rate of incoming serial connections created by the
build_serial_stream
method.
Additionally, this module exposes helper methods that are used internally to format data packets. These methods are intended for use by more advanced users.
The stream
module contains helper methods that are used to build connection stream instances.
Modules§
- This module contains utility functions that are used to build the
Stream
instances that are used to connect to the radio. Since theStreamApi::connect
method only requires that streams implement thetokio::io::AsyncReadExt
andtokio::io::AsyncWriteExt
methods, there are countless ways a user could theoretically connect to a radio.
Constants§
- The default pin state of the DTR pin of incoming serial connections created by the
build_serial_stream
method. - The default pin state of the RTS pin of incoming serial connections created by the
build_serial_stream
method. - The default baud rate of incoming serial connections created by the
build_serial_stream
method.
Functions§
- A helper function that returns the number of seconds since the unix epoch.
- A helper function that takes a vector of bytes (u8) representing an encoded packet, and reuturns a new vector of bytes representing the encoded packet with the required packet header attached.
- A helper method to generate random numbers using the
rand
crate. - A helper function that takes a vector of bytes (u8) representing an encoded packet with a 4-byte header, and returns a new vector of bytes representing the encoded packet with the packet header removed.