27 #ifndef NET_IEEE802154_SUBMAC_H
28 #define NET_IEEE802154_SUBMAC_H
37 #include "net/ieee802154/radio.h"
39 #define IEEE802154_SUBMAC_MAX_RETRANSMISSIONS (4U)
44 typedef struct ieee802154_submac ieee802154_submac_t;
134 return submac->
state;
216 const uint16_t *panid)
222 submac->
panid = *panid;
241 uint8_t channel_page, int8_t tx_pow);
256 uint16_t channel_num)
275 uint16_t channel_page)
uint16_t panid
IEEE 802.15.4 PAN ID.
IEEE 802.15.4 header definitions.
eui64_t ext_addr
IEEE 802.15.4 extended address.
static int ieee802154_set_channel_page(ieee802154_submac_t *submac, uint16_t channel_page)
Set IEEE 802.15.4 channel page.
A 16 bit integer in big endian aka network byte order.
static int ieee802154_set_panid(ieee802154_submac_t *submac, const uint16_t *panid)
Set the IEEE 802.15.4 PAN ID.
uint8_t retrans
current number of retransmissions
static int ieee802154_radio_len(ieee802154_dev_t *dev)
Shortcut to ieee802154_radio_ops::len.
RX information associated to a frame.
void ieee802154_submac_tx_done_cb(ieee802154_submac_t *submac)
Indicate the SubMAC that the device finished the transmission procedure.
int ieee802154_set_state(ieee802154_submac_t *submac, ieee802154_submac_state_t state)
Set the internal state of the 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.
uint8_t channel_page
IEEE 802.15.4 channel page.
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_radio_set_hw_addr_filter(ieee802154_dev_t *dev, const network_uint16_t *short_addr, const eui64_t *ext_addr, const uint16_t *pan_id)
Shortcut to ieee802154_radio_ops::set_hw_addr_filter.
ieee802154_submac_state_t
SubMAC states.
int8_t tx_pow
Transmission power (in dBm)
static int ieee802154_get_frame_length(ieee802154_submac_t *submac)
Get the received frame length.
ieee802154_dev_t * dev
pointer to the 802.15.4 HAL descriptor
const ieee802154_submac_cb_t * cb
pointer to the SubMAC callbacks
CSMA-CA exponential backoff parameters.
void ieee802154_submac_rx_done_cb(ieee802154_submac_t *submac)
Indicate the SubMAC that the device received a frame.
TX information of the last transmitted frame.
network_uint16_t short_addr
IEEE 802.15.4 short address.
uint8_t csma_retries
maximum number of CSMA-CA retries
uint8_t csma_retries_nb
current number of CSMA-CA retries
#define IEEE802154_SHORT_ADDRESS_LEN
IEEE 802.15.4 address lengths.
iolist structure definition
the IEEE802.15.4 device descriptor
static int ieee802154_set_short_addr(ieee802154_submac_t *submac, const network_uint16_t *short_addr)
Set the IEEE 802.15.4 short address.
@ IEEE802154_STATE_LISTEN
SubMAC is ready to be used and listening to incoming frames.
bool tx
SubMAC is currently transmitting a frame.
@ IEEE802154_STATE_OFF
SubMAC and network devices are off.
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.
void ieee802154_submac_ack_timer_cancel(ieee802154_submac_t *submac)
Cancel the ACK timeout timer.
static int ieee802154_read_frame(ieee802154_submac_t *submac, void *buf, size_t len, ieee802154_rx_info_t *info)
Read the received frame.
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
IEEE 802.15.4 SubMAC descriptor.
bool wait_for_ack
SubMAC is waiting for an ACK frame.
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)
static int ieee802154_set_tx_power(ieee802154_submac_t *submac, int8_t tx_pow)
Set IEEE 802.15.4 transmission power.
Data type to represent an EUI-64.
int ieee802154_send(ieee802154_submac_t *submac, const iolist_t *iolist)
Transmit an IEEE 802.15.4 PSDU.
ieee802154_csma_be_t be
CSMA-CA backoff exponent params.
@ IEEE802154_STATE_IDLE
SubMAC is ready to be used.
static ieee802154_submac_state_t ieee802154_get_state(ieee802154_submac_t *submac)
Get the internal state of the SubMAC.
uint16_t channel_num
IEEE 802.15.4 channel number.
uint8_t backoff_mask
internal value used for random backoff calculation
IEEE 802.15.4 SubMAC callbacks.
void ieee802154_submac_ack_timeout_fired(ieee802154_submac_t *submac)
Indicate the SubMAC that the ACK timeout fired.
void ieee802154_submac_ack_timer_set(ieee802154_submac_t *submac, uint16_t us)
Set the ACK timeout timer.
ieee802154_submac_state_t state
State of the SubMAC.