pub struct Identity {
pub unique_id: [u8; 12],
pub version: [u8; 9],
}Expand description
Who a bridge says it is.
Fields§
§unique_id: [u8; 12]The microcontroller’s unique identifier, twelve bytes.
version: [u8; 9]The firmware version, nine characters such as V01.00.00.
Implementations§
Source§impl Identity
impl Identity
Sourcepub fn parse(payload: &[u8]) -> Result<Identity, BridgeError>
pub fn parse(payload: &[u8]) -> Result<Identity, BridgeError>
Reads a ping’s answer.
§Arguments
payload- what followed the header.
§Returns
The identity.
§Errors
BridgeError::Short when fewer than PING_LEN bytes came back.
§Examples
use pamoja_radios::sx1302::bridge::Identity;
let mut payload = [0u8; 21];
payload[12..].copy_from_slice(b"V01.00.00");
let identity = Identity::parse(&payload).unwrap();
assert_eq!(identity.version_str(), Some("V01.00.00"));
assert!(identity.matches_firmware());Sourcepub fn version_str(&self) -> Option<&str>
pub fn version_str(&self) -> Option<&str>
The version as text.
§Returns
The nine characters, or None when the bridge sent something other than text.
Sourcepub fn matches_firmware(&self) -> bool
pub fn matches_firmware(&self) -> bool
Whether the bridge runs the firmware this crate was written against.
§Returns
Whether the version after its first character is FIRMWARE_VERSION. The first
character only says release or debug.
Trait Implementations§
impl Copy for Identity
impl Eq for Identity
impl StructuralPartialEq for Identity
Auto Trait Implementations§
impl Freeze for Identity
impl RefUnwindSafe for Identity
impl Send for Identity
impl Sync for Identity
impl Unpin for Identity
impl UnsafeUnpin for Identity
impl UnwindSafe for Identity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more