[−][src]Struct rn2xx3::Driver
The main driver instance.
Implementations
impl<F, S, E> Driver<F, S> where
S: Read<u8, Error = E> + Write<u8, Error = E>,
F: Frequency,
[src]
S: Read<u8, Error = E> + Write<u8, Error = E>,
F: Frequency,
Basic commands.
pub fn read_line(&mut self) -> RnResult<&[u8]>
[src]
Read a CR/LF terminated line from the serial port.
The string is returned without the line termination.
pub fn send_raw_command_nowait(&mut self, command: &[&str]) -> RnResult<()>
[src]
Send a raw command to the module and do not wait for the response.
Note: If you use this for a command that returns a response (e.g.
sleep
), you will have to manually read the response using the
read_line()
method.
pub fn send_raw_command(&mut self, command: &[&str]) -> RnResult<&[u8]>
[src]
Send a raw command to the module and return the response.
pub fn send_raw_command_str(&mut self, command: &[&str]) -> RnResult<&str>
[src]
Send a raw command and decode the resulting bytes to a &str
.
pub fn ensure_known_state(&mut self) -> RnResult<()>
[src]
Clear the module serial buffers and ensure a known good state.
Implementation details
This is done by first reading and discarding all available bytes from the serial port.
Afterwards, to ensure that there's no valid command in the input
buffer, the letter 'z' is sent, followed by a newline. There is no
valid command that ends with 'z' and it's not a valid hex character, so
the module should return invalid_param
. If it doesn't, the same
procedure is repeated 2 more times until giving up.
Unexpected errors while reading or writing are propagated to the caller.
impl<F, S, E> Driver<F, S> where
S: Read<u8, Error = E> + Write<u8, Error = E>,
F: Frequency,
[src]
S: Read<u8, Error = E> + Write<u8, Error = E>,
F: Frequency,
System commands.
pub fn free(self) -> S
[src]
Destroy this driver instance, return the wrapped serial device.
pub fn reset(&mut self) -> RnResult<&str>
[src]
Reset and restart the RN module. Return the version string.
pub fn factory_reset(&mut self) -> RnResult<&str>
[src]
Reset the module's configuration data and user EEPROM to factory default values and restart the module.
All configuration parameters will be restored to factory default values. Return the version string.
pub fn hweui(&mut self) -> RnResult<&str>
[src]
Return the preprogrammed EUI node address as uppercase hex string.
pub fn version(&mut self) -> RnResult<&str>
[src]
Return the version string.
pub fn model(&mut self) -> RnResult<Model>
[src]
Return the model of the module.
pub fn vdd(&mut self) -> RnResult<u16>
[src]
Measure and return the Vdd voltage in millivolts.
pub fn nvm_set(&mut self, addr: u16, byte: u8) -> RnResult<()>
[src]
Set the NVM byte at addr
to the specified value.
The address must be between 0x300 and 0x3ff, otherwise
Error::BadParameter
is returned.
pub fn nvm_get(&mut self, addr: u16) -> RnResult<u8>
[src]
Get the NVM byte at addr
.
The address must be between 0x300 and 0x3ff, otherwise
Error::BadParameter
is returned.
pub fn sleep(&mut self, duration: Duration) -> RnResult<()>
[src]
Put the system to sleep (with millisecond precision).
The module can be forced to exit from sleep by sending a break condition followed by a 0x55 character at the new baud rate.
Note: This command is asynchronous, it will not wait for the module
to wake up. You need to call wait_for_wakeup()
to
wait for the module before sending any other command.
pub fn wait_for_wakeup(&mut self, force: bool) -> RnResult<()>
[src]
After sleep mode has been enabled, wait for wakeup and clear
the sleep
flag.
If a sleep is in progress, this will block until the module sends a line on the serial bus.
If the sleep
flag is not set, then the method will return immediately
without a serial read unless the force
flag is set to true
. This is
required if you create a new driver instance for a module that is still
in sleep mode.
Note: If the module responds with a response that is not the string
"ok"
, a Error::ParsingError
will be returned, but
the sleep
flag will still be cleared (since the module is obviously
not in sleep mode anymore).
impl<F, S, E> Driver<F, S> where
S: Read<u8, Error = E> + Write<u8, Error = E>,
F: Frequency,
[src]
S: Read<u8, Error = E> + Write<u8, Error = E>,
F: Frequency,
MAC commands.
pub fn save_config(&mut self) -> RnResult<()>
[src]
Save MAC configuration parameters.
This command will save LoRaWAN Class A protocol configuration
parameters to the user EEPROM. When the next sys reset
command is issued, the LoRaWAN Class A protocol
configuration will be initialized with the last saved parameters.
The LoRaWAN Class A protocol configuration savable parameters are:
band
, deveui
, appeui
, appkey
, nwkskey
, appskey
, devaddr
as well as all channel parameters (e.g. frequeny, duty cycle, data).
pub fn set_dev_addr_hex(&mut self, val: &str) -> RnResult<()>
[src]
Set the unique network device address.
The parameter must be a 4-byte hex string, otherwise Error::BadParameter
will be returned.
pub fn set_dev_addr_slice(&mut self, val: &[u8]) -> RnResult<()>
[src]
Set the unique network device address.
The parameter must be a 4-byte big endian byte slice, otherwise Error::BadParameter
will be returned.
pub fn get_dev_addr_hex(&mut self) -> RnResult<&str>
[src]
Get the unique network device address as hex str.
pub fn get_dev_addr_slice(&mut self) -> RnResult<[u8; 4]>
[src]
Get the unique network device address bytes.
pub fn set_dev_eui_hex(&mut self, val: &str) -> RnResult<()>
[src]
Set the globally unique device identifier.
The parameter must be a 8-byte hex string, otherwise Error::BadParameter
will be returned.
pub fn set_dev_eui_slice(&mut self, val: &[u8]) -> RnResult<()>
[src]
Set the globally unique device identifier.
The parameter must be a 8-byte big endian byte slice, otherwise Error::BadParameter
will be returned.
pub fn get_dev_eui_hex(&mut self) -> RnResult<&str>
[src]
Get the globally unique device identifier as hex str.
pub fn get_dev_eui_slice(&mut self) -> RnResult<[u8; 8]>
[src]
Get the globally unique device identifier bytes.
pub fn set_app_eui_hex(&mut self, val: &str) -> RnResult<()>
[src]
Set the globally unique application identifier.
The parameter must be a 8-byte hex string, otherwise Error::BadParameter
will be returned.
pub fn set_app_eui_slice(&mut self, val: &[u8]) -> RnResult<()>
[src]
Set the globally unique application identifier.
The parameter must be a 8-byte big endian byte slice, otherwise Error::BadParameter
will be returned.
pub fn get_app_eui_hex(&mut self) -> RnResult<&str>
[src]
Get the globally unique application identifier as hex str.
pub fn get_app_eui_slice(&mut self) -> RnResult<[u8; 8]>
[src]
Get the globally unique application identifier bytes.
pub fn set_network_session_key_hex(&mut self, val: &str) -> RnResult<()>
[src]
Set the network session key.
The parameter must be a 16-byte hex string, otherwise Error::BadParameter
will be returned.
pub fn set_network_session_key_slice(&mut self, val: &[u8]) -> RnResult<()>
[src]
Set the network session key.
The parameter must be a 16-byte big endian byte slice, otherwise Error::BadParameter
will be returned.
pub fn set_app_session_key_hex(&mut self, val: &str) -> RnResult<()>
[src]
Set the application session key.
The parameter must be a 16-byte hex string, otherwise Error::BadParameter
will be returned.
pub fn set_app_session_key_slice(&mut self, val: &[u8]) -> RnResult<()>
[src]
Set the application session key.
The parameter must be a 16-byte big endian byte slice, otherwise Error::BadParameter
will be returned.
pub fn set_app_key_hex(&mut self, val: &str) -> RnResult<()>
[src]
Set the application key.
The parameter must be a 16-byte hex string, otherwise Error::BadParameter
will be returned.
pub fn set_app_key_slice(&mut self, val: &[u8]) -> RnResult<()>
[src]
Set the application key.
The parameter must be a 16-byte big endian byte slice, otherwise Error::BadParameter
will be returned.
pub fn set_adr(&mut self, enabled: bool) -> RnResult<()>
[src]
Set whether the ADR (adaptive data rate) mechanism is enabled.
pub fn get_adr(&mut self) -> RnResult<bool>
[src]
Return whether the ADR (adaptive data rate) mechanism is enabled.
pub fn join(&mut self, mode: JoinMode) -> Result<(), JoinError>
[src]
Join the network.
pub fn transmit_hex(
&mut self,
mode: ConfirmationMode,
port: u8,
data: &str
) -> Result<Option<Downlink>, TxError>
[src]
&mut self,
mode: ConfirmationMode,
port: u8,
data: &str
) -> Result<Option<Downlink>, TxError>
Send a hex uplink on the specified port.
If a downlink is received, it is returned.
pub fn transmit_slice(
&mut self,
mode: ConfirmationMode,
port: u8,
data: &[u8]
) -> Result<Option<Downlink>, TxError>
[src]
&mut self,
mode: ConfirmationMode,
port: u8,
data: &[u8]
) -> Result<Option<Downlink>, TxError>
Send an uplink on the specified port.
If a downlink is received, it is returned.
impl<S, E> Driver<Freq433, S> where
S: Read<u8, Error = E> + Write<u8, Error = E>,
[src]
S: Read<u8, Error = E> + Write<u8, Error = E>,
MAC commands for 433 MHz modules.
pub fn set_data_rate(&mut self, data_rate: DataRateEuCn) -> RnResult<()>
[src]
Set the data rate to be used for the following transmissions.
pub fn get_data_rate(&mut self) -> RnResult<DataRateEuCn>
[src]
Return the currently configured data rate.
impl<S, E> Driver<Freq868, S> where
S: Read<u8, Error = E> + Write<u8, Error = E>,
[src]
S: Read<u8, Error = E> + Write<u8, Error = E>,
MAC commands for 868 MHz modules.
pub fn set_data_rate(&mut self, data_rate: DataRateEuCn) -> RnResult<()>
[src]
Set the data rate to be used for the following transmissions.
pub fn get_data_rate(&mut self) -> RnResult<DataRateEuCn>
[src]
Return the currently configured data rate.
impl<S, E> Driver<Freq915, S> where
S: Read<u8, Error = E> + Write<u8, Error = E>,
[src]
S: Read<u8, Error = E> + Write<u8, Error = E>,
MAC commands for 915 MHz modules.
pub fn set_data_rate(&mut self, data_rate: DataRateUs) -> RnResult<()>
[src]
Set the data rate to be used for the following transmissions.
pub fn get_data_rate(&mut self) -> RnResult<DataRateUs>
[src]
Return the currently configured data rate.
Auto Trait Implementations
impl<F, S> RefUnwindSafe for Driver<F, S> where
F: RefUnwindSafe,
S: RefUnwindSafe,
F: RefUnwindSafe,
S: RefUnwindSafe,
impl<F, S> Send for Driver<F, S> where
F: Send,
S: Send,
F: Send,
S: Send,
impl<F, S> Sync for Driver<F, S> where
F: Sync,
S: Sync,
F: Sync,
S: Sync,
impl<F, S> Unpin for Driver<F, S> where
F: Unpin,
S: Unpin,
F: Unpin,
S: Unpin,
impl<F, S> UnwindSafe for Driver<F, S> where
F: UnwindSafe,
S: UnwindSafe,
F: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,