107#ifndef NET_IEEE802154_SUBMAC_H
108#define NET_IEEE802154_SUBMAC_H
119#include "net/ieee802154/radio.h"
283 const uint16_t *panid)
290 submac->
panid = *panid;
325 uint8_t channel_page, int8_t tx_pow);
343 uint16_t channel_num)
365 uint16_t channel_page)
POSIX.1-2008 compliant version of the assert macro.
static int ieee802154_radio_read(ieee802154_dev_t *dev, void *buf, size_t size, ieee802154_rx_info_t *info)
Shortcut to ieee802154_radio_ops::read.
static int ieee802154_radio_len(ieee802154_dev_t *dev)
Shortcut to ieee802154_radio_ops::len.
static int ieee802154_radio_config_addr_filter(ieee802154_dev_t *dev, ieee802154_af_cmd_t cmd, const void *value)
Shortcut to ieee802154_radio_ops::config_addr_filter.
@ IEEE802154_AF_EXT_ADDR
Set extended IEEE 802.15.4 address (eui64_t)
@ IEEE802154_AF_SHORT_ADDR
Set short IEEE 802.15.4 address (network_uint16_t)
@ IEEE802154_AF_PANID
Set PAN ID (uint16_t)
ieee802154_fsm_state_t
Internal SubMAC FSM state machine states.
static int ieee802154_get_frame_length(ieee802154_submac_t *submac)
Get the received frame length.
void ieee802154_submac_ack_timer_cancel(ieee802154_submac_t *submac)
Cancel the ACK timeout timer.
static int ieee802154_set_channel_page(ieee802154_submac_t *submac, uint16_t channel_page)
Set IEEE 802.15.4 channel page.
int ieee802154_send(ieee802154_submac_t *submac, const iolist_t *iolist)
Transmit an IEEE 802.15.4 PSDU.
ieee802154_fsm_state_t ieee802154_submac_process_ev(ieee802154_submac_t *submac, ieee802154_fsm_ev_t ev)
Process an FSM event.
static void ieee802154_submac_tx_done_cb(ieee802154_submac_t *submac)
Indicate the SubMAC that the device finished the transmission procedure.
static int ieee802154_set_short_addr(ieee802154_submac_t *submac, const network_uint16_t *short_addr)
Set the IEEE 802.15.4 short address.
static bool ieee802154_submac_state_is_rx(ieee802154_submac_t *submac)
Check whether the SubMAC is in RX state.
int ieee802154_submac_init(ieee802154_submac_t *submac, const network_uint16_t *short_addr, const eui64_t *ext_addr)
Init the IEEE 802.15.4 SubMAC.
static int ieee802154_set_ext_addr(ieee802154_submac_t *submac, const eui64_t *ext_addr)
Set the IEEE 802.15.4 extended address.
static int ieee802154_set_channel_number(ieee802154_submac_t *submac, uint16_t channel_num)
Set IEEE 802.15.4 channel number.
ieee802154_fsm_ev_t
Internal SubMAC FSM state machine events.
static void ieee802154_submac_bh_process(ieee802154_submac_t *submac)
Indicate the SubMAC that the BH should process an internal event.
static bool ieee802154_submac_state_is_idle(ieee802154_submac_t *submac)
Check whether the SubMAC is in IDLE state.
int ieee802154_set_rx(ieee802154_submac_t *submac)
Set the SubMAC to RX state.
void ieee802154_submac_ack_timer_set(ieee802154_submac_t *submac, uint16_t us)
Set the ACK timeout timer.
void ieee802154_submac_bh_request(ieee802154_submac_t *submac)
ieee802154_submac_bh_process should be called as soon as possible.
int ieee802154_set_idle(ieee802154_submac_t *submac)
Set the SubMAC to IDLE state.
static ieee802154_phy_mode_t ieee802154_get_phy_mode(ieee802154_submac_t *submac)
Get IEEE 802.15.4 PHY mode.
static int ieee802154_set_tx_power(ieee802154_submac_t *submac, int8_t tx_pow)
Set IEEE 802.15.4 transmission power.
static int ieee802154_read_frame(ieee802154_submac_t *submac, void *buf, size_t len, ieee802154_rx_info_t *info)
Read the received frame.
static void ieee802154_submac_ack_timeout_fired(ieee802154_submac_t *submac)
Indicate the SubMAC that the ACK timeout fired.
static int ieee802154_set_panid(ieee802154_submac_t *submac, const uint16_t *panid)
Set the IEEE 802.15.4 PAN ID.
static void ieee802154_submac_rx_done_cb(ieee802154_submac_t *submac)
Indicate the SubMAC that the device received a frame.
static void ieee802154_submac_crc_error_cb(ieee802154_submac_t *submac)
Indicate the SubMAC that a frame with invalid CRC was received.
int ieee802154_set_phy_conf(ieee802154_submac_t *submac, uint16_t channel_num, uint8_t channel_page, int8_t tx_pow)
Set IEEE 802.15.4 PHY configuration (channel, TX power)
@ IEEE802154_FSM_STATE_IDLE
The transceiver is off.
@ IEEE802154_FSM_STATE_NUMOF
Number of SubMAC FSM states.
@ IEEE802154_FSM_STATE_INVALID
Invalid state.
@ IEEE802154_FSM_STATE_PREPARE
The SubMAC is preparing the next transmission.
@ IEEE802154_FSM_STATE_TX
The SubMAC is currently transmitting a frame.
@ IEEE802154_FSM_STATE_RX
SubMAC is ready to receive frames.
@ IEEE802154_FSM_STATE_WAIT_FOR_ACK
The SubMAC is waiting for an ACK frame.
@ IEEE802154_FSM_EV_BH
The Bottom Half should process an event.
@ IEEE802154_FSM_EV_ACK_TIMEOUT
ACK timer fired.
@ IEEE802154_FSM_EV_CRC_ERROR
Radio reports frame was received but CRC failed.
@ IEEE802154_FSM_EV_REQUEST_TX
The upper layer requested to transmit a frame.
@ IEEE802154_FSM_EV_TX_DONE
Radio reports frame was sent.
@ IEEE802154_FSM_EV_REQUEST_SET_IDLE
The upper layer requested to go to IDLE.
@ IEEE802154_FSM_EV_NUMOF
Number of SubMAC FSM events.
@ IEEE802154_FSM_EV_RX_DONE
Radio reports frame was received.
@ IEEE802154_FSM_EV_REQUEST_SET_RX_ON
The upper layer requested to go to RX.
stdio wrapper to extend the C libs stdio
CSMA-CA exponential backoff parameters.
the IEEE802.15.4 device descriptor
RX information associated to a frame.
IEEE 802.15.4 SubMAC callbacks.
IEEE 802.15.4 SubMAC descriptor.
uint8_t backoff_mask
internal value used for random backoff calculation
uint8_t csma_retries_nb
current number of CSMA-CA retries
const ieee802154_submac_cb_t * cb
pointer to the SubMAC callbacks
eui64_t ext_addr
IEEE 802.15.4 extended address.
const iolist_t * psdu
stores the current PSDU
int8_t tx_pow
Transmission power (in dBm)
network_uint16_t short_addr
IEEE 802.15.4 short address.
uint8_t retrans
current number of retransmissions
bool wait_for_ack
SubMAC is waiting for an ACK frame.
uint8_t channel_page
IEEE 802.15.4 channel page.
uint16_t channel_num
IEEE 802.15.4 channel number.
ieee802154_phy_mode_t phy_mode
IEEE 802.15.4 PHY mode.
ieee802154_csma_be_t be
CSMA-CA backoff exponent params.
ieee802154_fsm_state_t fsm_state
State of the SubMAC.
ieee802154_dev_t dev
802.15.4 HAL descriptor
uint8_t csma_retries
maximum number of CSMA-CA retries
uint16_t panid
IEEE 802.15.4 PAN ID.
TX information of the last transmitted frame.
iolist structure definition
IEEE 802.15.4 header definitions.
A 16 bit integer in big endian aka network byte order.
Data type to represent an EUI-64.