Trait capsules_extra::ieee802154::device::MacDevice
source · pub trait MacDevice<'a> {
// Required methods
fn set_transmit_client(&self, client: &'a dyn TxClient);
fn set_receive_client(&self, client: &'a dyn RxClient);
fn get_address(&self) -> u16;
fn get_address_long(&self) -> [u8; 8];
fn get_pan(&self) -> u16;
fn set_address(&self, addr: u16);
fn set_address_long(&self, addr: [u8; 8]);
fn set_pan(&self, id: u16);
fn config_commit(&self);
fn is_on(&self) -> bool;
fn prepare_data_frame(
&self,
buf: &'static mut [u8],
dst_pan: PanID,
dst_addr: MacAddress,
src_pan: PanID,
src_addr: MacAddress,
security_needed: Option<(SecurityLevel, KeyId)>,
) -> Result<Frame, &'static mut [u8]>;
fn transmit(
&self,
frame: Frame,
) -> Result<(), (ErrorCode, &'static mut [u8])>;
}
Required Methods§
sourcefn set_transmit_client(&self, client: &'a dyn TxClient)
fn set_transmit_client(&self, client: &'a dyn TxClient)
Sets the transmission client of this MAC device
sourcefn set_receive_client(&self, client: &'a dyn RxClient)
fn set_receive_client(&self, client: &'a dyn RxClient)
Sets the receive client of this MAC device
sourcefn get_address(&self) -> u16
fn get_address(&self) -> u16
The short 16-bit address of the MAC device
sourcefn get_address_long(&self) -> [u8; 8]
fn get_address_long(&self) -> [u8; 8]
The long 64-bit address (EUI-64) of the MAC device
sourcefn set_address(&self, addr: u16)
fn set_address(&self, addr: u16)
Set the short 16-bit address of the MAC device
sourcefn set_address_long(&self, addr: [u8; 8])
fn set_address_long(&self, addr: [u8; 8])
Set the long 64-bit address (EUI-64) of the MAC device
sourcefn config_commit(&self)
fn config_commit(&self)
This method must be called after one or more calls to set_*
. If
set_*
is called without calling config_commit
, there is no guarantee
that the underlying hardware configuration (addresses, pan ID) is in
line with this MAC device implementation.
sourcefn prepare_data_frame(
&self,
buf: &'static mut [u8],
dst_pan: PanID,
dst_addr: MacAddress,
src_pan: PanID,
src_addr: MacAddress,
security_needed: Option<(SecurityLevel, KeyId)>,
) -> Result<Frame, &'static mut [u8]>
fn prepare_data_frame( &self, buf: &'static mut [u8], dst_pan: PanID, dst_addr: MacAddress, src_pan: PanID, src_addr: MacAddress, security_needed: Option<(SecurityLevel, KeyId)>, ) -> Result<Frame, &'static mut [u8]>
Prepares a mutable buffer slice as an 802.15.4 frame by writing the appropriate header bytes into the buffer. This needs to be done before adding the payload because the length of the header is not fixed.
buf
: The mutable buffer slice to usedst_pan
: The destination PAN IDdst_addr
: The destination MAC addresssrc_pan
: The source PAN IDsrc_addr
: The source MAC addresssecurity_needed
: Whether or not this frame should be secured. This needs to be specified beforehand so that the auxiliary security header can be pre-inserted.
Returns either a Frame that is ready to have payload appended to it, or the mutable buffer if the frame cannot be prepared for any reason