capsules_extra::ieee802154::virtual_mac

Struct MacUser

Source
pub struct MacUser<'a, M: MacDevice<'a>> { /* private fields */ }
Expand description

Keep state for each Mac user.

All users of the virtualized MAC interface need to create one of these and register it with the MAC device muxer MuxMac by calling MuxMac#add_user. Then, each MacUser behaves exactly like an independent MAC device, except MAC device state is shared between all MacUsers because there is only one MAC device. For example, the MAC device address is shared, so calling set_address on one MacUser sets the MAC address for all MacUsers.

Implementations§

Source§

impl<'a, M: MacDevice<'a>> MacUser<'a, M>

Source

pub const fn new(mux: &'a MuxMac<'a, M>) -> Self

Trait Implementations§

Source§

impl<'a, M: MacDevice<'a>> ListNode<'a, MacUser<'a, M>> for MacUser<'a, M>

Source§

fn next(&'a self) -> &'a ListLink<'a, MacUser<'a, M>>

Source§

impl<'a, M: MacDevice<'a>> MacDevice<'a> for MacUser<'a, M>

Source§

fn set_transmit_client(&self, client: &'a dyn TxClient)

Sets the transmission client of this MAC device
Source§

fn set_receive_client(&self, client: &'a dyn RxClient)

Sets the receive client of this MAC device
Source§

fn get_address(&self) -> u16

The short 16-bit address of the MAC device
Source§

fn get_address_long(&self) -> [u8; 8]

The long 64-bit address (EUI-64) of the MAC device
Source§

fn get_pan(&self) -> u16

The 16-bit PAN ID of the MAC device
Source§

fn set_address(&self, addr: u16)

Set the short 16-bit address of the MAC device
Source§

fn set_address_long(&self, addr: [u8; 8])

Set the long 64-bit address (EUI-64) of the MAC device
Source§

fn set_pan(&self, id: u16)

Set the 16-bit PAN ID of the MAC device
Source§

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.
Source§

fn is_on(&self) -> bool

Returns if the MAC device is currently on.
Source§

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. Read more
Source§

fn transmit(&self, frame: Frame) -> Result<(), (ErrorCode, &'static mut [u8])>

Transmits a frame that has been prepared by the above process. If the transmission process fails, the buffer inside the frame is returned so that it can be re-used.

Auto Trait Implementations§

§

impl<'a, M> !Freeze for MacUser<'a, M>

§

impl<'a, M> !RefUnwindSafe for MacUser<'a, M>

§

impl<'a, M> !Send for MacUser<'a, M>

§

impl<'a, M> !Sync for MacUser<'a, M>

§

impl<'a, M> Unpin for MacUser<'a, M>

§

impl<'a, M> !UnwindSafe for MacUser<'a, M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.