Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
IEEE 802.15.4 Library

IEEE 802.15.4 library. More...

Data Structures

struct  ieee802154_security_ctx
 
struct  ieee802154_context
 
struct  ieee802154_filter
 
struct  ieee802154_key
 
struct  ieee802154_config
 
struct  ieee802154_radio_api
 IEEE 802.15.4 radio interface API. More...
 

Macros

#define IEEE802154_MAX_ADDR_LENGTH   8
 
#define IEEE802154_NO_CHANNEL   USHRT_MAX
 
#define IEEE802154_L2_CTX_TYPE   struct ieee802154_context
 
#define IEEE802154_AR_FLAG_SET   (0x20)
 

Typedefs

typedef void(* energy_scan_done_cb_t) (const struct device *dev, int16_t max_ed)
 
typedef void(* ieee802154_event_cb_t) (const struct device *dev, enum ieee802154_event evt, void *event_params)
 

Enumerations

enum  ieee802154_channel { IEEE802154_SUB_GHZ_CHANNEL_MIN = 0 , IEEE802154_SUB_GHZ_CHANNEL_MAX = 10 , IEEE802154_2_4_GHZ_CHANNEL_MIN = 11 , IEEE802154_2_4_GHZ_CHANNEL_MAX = 26 }
 IEEE 802.15.4 Channel assignments. More...
 
enum  ieee802154_hw_caps {
  IEEE802154_HW_FCS = BIT(0) , IEEE802154_HW_PROMISC = BIT(1) , IEEE802154_HW_FILTER = BIT(2) , IEEE802154_HW_CSMA = BIT(3) ,
  IEEE802154_HW_2_4_GHZ = BIT(4) , IEEE802154_HW_TX_RX_ACK = BIT(5) , IEEE802154_HW_SUB_GHZ = BIT(6) , IEEE802154_HW_ENERGY_SCAN = BIT(7) ,
  IEEE802154_HW_TXTIME = BIT(8) , IEEE802154_HW_SLEEP_TO_TX = BIT(9) , IEEE802154_HW_TX_SEC = BIT(10) , IEEE802154_HW_RXTIME = BIT(11)
}
 
enum  ieee802154_filter_type {
  IEEE802154_FILTER_TYPE_IEEE_ADDR , IEEE802154_FILTER_TYPE_SHORT_ADDR , IEEE802154_FILTER_TYPE_PAN_ID , IEEE802154_FILTER_TYPE_SRC_IEEE_ADDR ,
  IEEE802154_FILTER_TYPE_SRC_SHORT_ADDR
}
 
enum  ieee802154_event { IEEE802154_EVENT_TX_STARTED , IEEE802154_EVENT_RX_FAILED , IEEE802154_EVENT_SLEEP }
 
enum  ieee802154_rx_fail_reason { IEEE802154_RX_FAIL_NOT_RECEIVED , IEEE802154_RX_FAIL_INVALID_FCS , IEEE802154_RX_FAIL_ADDR_FILTERED , IEEE802154_RX_FAIL_OTHER }
 
enum  ieee802154_tx_mode {
  IEEE802154_TX_MODE_DIRECT , IEEE802154_TX_MODE_CCA , IEEE802154_TX_MODE_CSMA_CA , IEEE802154_TX_MODE_TXTIME ,
  IEEE802154_TX_MODE_TXTIME_CCA
}
 
enum  ieee802154_fpb_mode { IEEE802154_FPB_ADDR_MATCH_THREAD , IEEE802154_FPB_ADDR_MATCH_ZIGBEE }
 
enum  ieee802154_config_type {
  IEEE802154_CONFIG_AUTO_ACK_FPB , IEEE802154_CONFIG_ACK_FPB , IEEE802154_CONFIG_PAN_COORDINATOR , IEEE802154_CONFIG_PROMISCUOUS ,
  IEEE802154_CONFIG_EVENT_HANDLER , IEEE802154_CONFIG_MAC_KEYS , IEEE802154_CONFIG_FRAME_COUNTER , IEEE802154_CONFIG_RX_SLOT ,
  IEEE802154_CONFIG_CSL_PERIOD , IEEE802154_CONFIG_CSL_RX_TIME , IEEE802154_CONFIG_ENH_ACK_HEADER_IE
}
 

Functions

static bool ieee802154_is_ar_flag_set (struct net_buf *frag)
 Check if AR flag is set on the frame inside given net_pkt. More...
 
enum net_verdict ieee802154_radio_handle_ack (struct net_if *iface, struct net_pkt *pkt)
 Radio driver ACK handling function that hw drivers should use. More...
 
void ieee802154_init (struct net_if *iface)
 Initialize L2 stack for a given interface. More...
 

Detailed Description

IEEE 802.15.4 library.

Macro Definition Documentation

◆ IEEE802154_AR_FLAG_SET

#define IEEE802154_AR_FLAG_SET   (0x20)

◆ IEEE802154_L2_CTX_TYPE

#define IEEE802154_L2_CTX_TYPE   struct ieee802154_context

◆ IEEE802154_MAX_ADDR_LENGTH

#define IEEE802154_MAX_ADDR_LENGTH   8

◆ IEEE802154_NO_CHANNEL

#define IEEE802154_NO_CHANNEL   USHRT_MAX

Typedef Documentation

◆ energy_scan_done_cb_t

typedef void(* energy_scan_done_cb_t) (const struct device *dev, int16_t max_ed)

◆ ieee802154_event_cb_t

typedef void(* ieee802154_event_cb_t) (const struct device *dev, enum ieee802154_event evt, void *event_params)

Enumeration Type Documentation

◆ ieee802154_channel

#include <include/net/ieee802154_radio.h>

IEEE 802.15.4 Channel assignments.

Channel numbering for 868 MHz, 915 MHz, and 2450 MHz bands.

  • Channel 0 is for 868.3 MHz.
  • Channels 1-10 are for 906 to 924 MHz with 2 MHz channel spacing.
  • Channels 11-26 are for 2405 to 2530 MHz with 5 MHz channel spacing.

For more information, please refer to 802.15.4-2015 Section 10.1.2.2.

Enumerator
IEEE802154_SUB_GHZ_CHANNEL_MIN 
IEEE802154_SUB_GHZ_CHANNEL_MAX 
IEEE802154_2_4_GHZ_CHANNEL_MIN 
IEEE802154_2_4_GHZ_CHANNEL_MAX 

◆ ieee802154_config_type

#include <include/net/ieee802154_radio.h>

IEEE802.15.4 driver configuration types.

Enumerator
IEEE802154_CONFIG_AUTO_ACK_FPB 

Indicates how radio driver should set Frame Pending bit in ACK responses for Data Requests. If enabled, radio driver should determine whether to set the bit or not based on the information provided with IEEE802154_CONFIG_ACK_FPB config and FPB address matching mode specified. Otherwise, Frame Pending bit should be set to 1(see IEEE Std 802.15.4-2006, 7.2.2.3.1).

IEEE802154_CONFIG_ACK_FPB 

Indicates whether to set ACK Frame Pending bit for specific address or not. Disabling the Frame Pending bit with no address provided (NULL pointer) should disable it for all enabled addresses.

IEEE802154_CONFIG_PAN_COORDINATOR 

Indicates whether the device is a PAN coordinator.

IEEE802154_CONFIG_PROMISCUOUS 

Enable/disable promiscuous mode.

IEEE802154_CONFIG_EVENT_HANDLER 

Specifies new radio event handler. Specifying NULL as a handler will disable radio events notification.

IEEE802154_CONFIG_MAC_KEYS 

Updates MAC keys and key index for radios supporting transmit security.

IEEE802154_CONFIG_FRAME_COUNTER 

Sets the current MAC frame counter value for radios supporting transmit security.

IEEE802154_CONFIG_RX_SLOT 

Configure a radio reception slot. This can be used for any scheduler reception, e.g.: Zigbee GP device, CSL, TSCH, etc.

In order to configure a CSL receiver the upper layer should combine several configuration options in the following way:

  1. Use IEEE802154_CONFIG_ENH_ACK_HEADER_IE once to inform the radio driver of the short and extended addresses of the peer to which it should inject CSL IEs.
  2. Use IEEE802154_CONFIG_CSL_RX_TIME periodically, before each use of IEEE802154_CONFIG_CSL_PERIOD setting parameters of the nearest CSL RX window, and before each use of IEEE_CONFIG_RX_SLOT setting parameters of the following (not the nearest one) CSL RX window, to allow the radio driver to calculate the proper CSL Phase to the nearest CSL window to inject in the CSL IEs for both transmitted data and ack frames.
  3. Use IEEE802154_CONFIG_CSL_PERIOD on each value change to update the current CSL period value which will be injected in the CSL IEs together with the CSL Phase based on IEEE802154_CONFIG_CSL_RX_TIME.
  4. Use IEEE802154_CONFIG_RX_SLOT periodically to schedule the immediate receive window earlier enough before the expected window start time, taking into account possible clock drifts and scheduling uncertainties.

This diagram shows the usage of the four options over time: Start CSL Schedule CSL window

ENH_ACK_HEADER_IE CSL_RX_TIME (following window) | | | CSL_RX_TIME (nearest window) | RX_SLOT (nearest window) | | | | | | CSL_PERIOD | | | | | | | v v v v v -------------------------------------------------------—[ CSL window ]--—+ ^ | | | +------------------— loop ------—+

IEEE802154_CONFIG_CSL_PERIOD 

Configure CSL receiver (Endpoint) period

IEEE802154_CONFIG_CSL_RX_TIME 

Configure the next CSL receive window center, in units of microseconds, based on the radio time.

IEEE802154_CONFIG_ENH_ACK_HEADER_IE 

Indicates whether to inject IE into ENH ACK Frame for specific address or not. Disabling the ENH ACK with no address provided (NULL pointer) should disable it for all enabled addresses.

◆ ieee802154_event

#include <include/net/ieee802154_radio.h>

Enumerator
IEEE802154_EVENT_TX_STARTED 
IEEE802154_EVENT_RX_FAILED 
IEEE802154_EVENT_SLEEP 

◆ ieee802154_filter_type

#include <include/net/ieee802154_radio.h>

Enumerator
IEEE802154_FILTER_TYPE_IEEE_ADDR 
IEEE802154_FILTER_TYPE_SHORT_ADDR 
IEEE802154_FILTER_TYPE_PAN_ID 
IEEE802154_FILTER_TYPE_SRC_IEEE_ADDR 
IEEE802154_FILTER_TYPE_SRC_SHORT_ADDR 

◆ ieee802154_fpb_mode

#include <include/net/ieee802154_radio.h>

IEEE802.15.4 Frame Pending Bit table address matching mode.

Enumerator
IEEE802154_FPB_ADDR_MATCH_THREAD 

The pending bit shall be set only for addresses found in the list.

IEEE802154_FPB_ADDR_MATCH_ZIGBEE 

The pending bit shall be cleared for short addresses found in the list.

◆ ieee802154_hw_caps

#include <include/net/ieee802154_radio.h>

Enumerator
IEEE802154_HW_FCS 
IEEE802154_HW_PROMISC 
IEEE802154_HW_FILTER 
IEEE802154_HW_CSMA 
IEEE802154_HW_2_4_GHZ 
IEEE802154_HW_TX_RX_ACK 
IEEE802154_HW_SUB_GHZ 
IEEE802154_HW_ENERGY_SCAN 
IEEE802154_HW_TXTIME 
IEEE802154_HW_SLEEP_TO_TX 
IEEE802154_HW_TX_SEC 
IEEE802154_HW_RXTIME 

◆ ieee802154_rx_fail_reason

#include <include/net/ieee802154_radio.h>

Enumerator
IEEE802154_RX_FAIL_NOT_RECEIVED 
IEEE802154_RX_FAIL_INVALID_FCS 
IEEE802154_RX_FAIL_ADDR_FILTERED 
IEEE802154_RX_FAIL_OTHER 

◆ ieee802154_tx_mode

#include <include/net/ieee802154_radio.h>

IEEE802.15.4 Transmission mode.

Enumerator
IEEE802154_TX_MODE_DIRECT 

Transmit packet immediately, no CCA.

IEEE802154_TX_MODE_CCA 

Perform CCA before packet transmission.

IEEE802154_TX_MODE_CSMA_CA 

Perform full CSMA CA procedure before packet transmission.

IEEE802154_TX_MODE_TXTIME 

Transmit packet in the future, at specified time, no CCA.

IEEE802154_TX_MODE_TXTIME_CCA 

Transmit packet in the future, perform CCA before transmission.

Function Documentation

◆ ieee802154_init()

void ieee802154_init ( struct net_if iface)

#include <include/net/ieee802154_radio.h>

Initialize L2 stack for a given interface.

Parameters
ifaceA valid pointer on a network interface

◆ ieee802154_is_ar_flag_set()

static bool ieee802154_is_ar_flag_set ( struct net_buf frag)
inlinestatic

#include <include/net/ieee802154_radio.h>

Check if AR flag is set on the frame inside given net_pkt.

Parameters
fragA valid pointer on a net_buf structure, must not be NULL, and its length should be at least made of 1 byte (ACK frames are the smallest frames on 15.4 and made of 3 bytes, not not counting the FCS part).
Returns
True if AR flag is set, False otherwise

◆ ieee802154_radio_handle_ack()

enum net_verdict ieee802154_radio_handle_ack ( struct net_if iface,
struct net_pkt pkt 
)

#include <include/net/ieee802154_radio.h>

Radio driver ACK handling function that hw drivers should use.

ACK handling requires fast handling and thus such function helps to hook directly the hw drivers to the radio driver.

Parameters
ifaceA valid pointer on a network interface that received the packet
pktA valid pointer on a packet to check
Returns
NET_OK if it was handled, NET_CONTINUE otherwise