Trait kernel::hil::radio::RadioData

source ·
pub trait RadioData<'a> {
    // Required methods
    fn set_transmit_client(&self, client: &'a dyn TxClient);
    fn set_receive_client(&self, client: &'a dyn RxClient);
    fn set_receive_buffer(&self, receive_buffer: &'static mut [u8]);
    fn transmit(
        &self,
        buf: &'static mut [u8],
        frame_len: usize,
    ) -> Result<(), (ErrorCode, &'static mut [u8])>;
}
Expand description

Send and receive packets with the 802.15.4 radio.

Required Methods§

source

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

Set the client that will be called when packets are transmitted.

source

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

Set the client that will be called when packets are received.

source

fn set_receive_buffer(&self, receive_buffer: &'static mut [u8])

Set the buffer to receive packets into.

§Argument
  • receive_buffer: The buffer to receive into. Must be at least MAX_BUF_SIZE bytes long.
source

fn transmit( &self, buf: &'static mut [u8], frame_len: usize, ) -> Result<(), (ErrorCode, &'static mut [u8])>

Transmit a packet.

The radio will create and insert the PHR (Frame length) field.

§Argument
  • buf: Buffer with the MAC layer 802.15.4 frame to be transmitted. The buffer must conform to the buffer formatted documented in the HIL. That is, the MAC payload (PSDU) must start at the third byte. The first byte must be reserved for the radio driver (i.e. for a SPI transaction) and the second byte is reserved for the PHR. The buffer must be at least frame_len + 2 + MFR_SIZE` bytes long.
  • frame_len: The length of the MAC payload, not including the MFR.
§Return

Ok(()) on success. On Err(), valid errors are:

  • ErrorCode::OFF: The radio is off and cannot transmit.
  • ErrorCode::BUSY: The radio is busy. This is likely to occur because the radio is already transmitting a packet.
  • ErrorCode::SIZE: The buffer does not have room for the MFR (CRC).
  • ErrorCode::FAIL: Internal error occurred.

Implementors§