21 #ifndef NET_IEEE802154_H
22 #define NET_IEEE802154_H
38 #define IEEE802154_SFD (0xa7)
44 #define IEEE802154_SHORT_ADDRESS_LEN (2U)
45 #define IEEE802154_LONG_ADDRESS_LEN (8U)
54 #define IEEE802154_MAX_HDR_LEN (23U)
55 #define IEEE802154_MIN_FRAME_LEN (IEEE802154_FCF_LEN + sizeof(uint8_t))
57 #define IEEE802154_FCF_LEN (2U)
58 #define IEEE802154_FCS_LEN (2U)
60 #define IEEE802154_FCF_TYPE_MASK (0x07)
61 #define IEEE802154_FCF_TYPE_BEACON (0x00)
62 #define IEEE802154_FCF_TYPE_DATA (0x01)
63 #define IEEE802154_FCF_TYPE_ACK (0x02)
64 #define IEEE802154_FCF_TYPE_MACCMD (0x03)
66 #define IEEE802154_FCF_SECURITY_EN (0x08)
67 #define IEEE802154_FCF_FRAME_PEND (0x10)
68 #define IEEE802154_FCF_ACK_REQ (0x20)
69 #define IEEE802154_FCF_PAN_COMP (0x40)
71 #define IEEE802154_FCF_DST_ADDR_MASK (0x0c)
72 #define IEEE802154_FCF_DST_ADDR_VOID (0x00)
73 #define IEEE802154_FCF_DST_ADDR_RESV (0x04)
74 #define IEEE802154_FCF_DST_ADDR_SHORT (0x08)
75 #define IEEE802154_FCF_DST_ADDR_LONG (0x0c)
77 #define IEEE802154_FCF_VERS_MASK (0x30)
78 #define IEEE802154_FCF_VERS_V0 (0x00)
79 #define IEEE802154_FCF_VERS_V1 (0x10)
81 #define IEEE802154_FCF_SRC_ADDR_MASK (0xc0)
82 #define IEEE802154_FCF_SRC_ADDR_VOID (0x00)
83 #define IEEE802154_FCF_SRC_ADDR_RESV (0x40)
84 #define IEEE802154_FCF_SRC_ADDR_SHORT (0x80)
85 #define IEEE802154_FCF_SRC_ADDR_LONG (0xc0)
92 #define IEEE802154_CHANNEL_MIN_SUBGHZ (0U)
93 #define IEEE802154_CHANNEL_MAX_SUBGHZ (10U)
94 #define IEEE802154_CHANNEL_MIN (11U)
95 #define IEEE802154_CHANNEL_MAX (26U)
98 #define IEEE802154_FRAME_LEN_MAX (127U)
99 #define IEEE802154G_FRAME_LEN_MAX (2047U)
100 #define IEEE802154_ACK_FRAME_LEN (5U)
105 #define IEEE802154_LIFS_SYMS (40U)
110 #define IEEE802154_SIFS_SYMS (12U)
115 #define IEEE802154_SIFS_MAX_FRAME_SIZE (18U)
120 #define IEEE802154_ACK_TIMEOUT_SYMS (54)
127 #define IEEE802154_RADIO_RSSI_OFFSET (-174)
129 #define IEEE802154_PHY_MR_FSK_PHR_LEN (2)
130 #define IEEE802154_PHY_MR_FSK_2FSK_SFD_LEN (2)
140 #define IEEE802154_PHY_MR_FSK_2FSK_CODED_SFD_0 (0x6F4E)
141 #define IEEE802154_PHY_MR_FSK_2FSK_CODED_SFD_1 (0x632D)
142 #define IEEE802154_PHY_MR_FSK_2FSK_UNCODED_SFD_0 (0x90E4)
143 #define IEEE802154_PHY_MR_FSK_2FSK_UNCODED_SFD_1 (0x7A0E)
152 #define IEEE802154G_ATURNAROUNDTIME_US (1 * US_PER_MS)
158 #define IEEE802154_ATURNAROUNDTIME_IN_SYMBOLS (12)
167 #define IEEE802154_CCA_DURATION_IN_SYMBOLS (8)
198 #define IEEE802154_ADDR_BCAST { 0xff, 0xff }
203 #define IEEE802154_ADDR_BCAST_LEN (IEEE802154_SHORT_ADDRESS_LEN)
220 #if IS_ACTIVE(CONFIG_IEEE802154_DEFAULT_PHY_BPSK)
221 #define CONFIG_IEEE802154_DEFAULT_PHY_MODE IEEE802154_PHY_BPSK
222 #elif IS_ACTIVE(CONFIG_IEEE802154_DEFAULT_PHY_ASK)
223 #define CONFIG_IEEE802154_DEFAULT_PHY_MODE IEEE802154_PHY_ASK
224 #elif IS_ACTIVE(CONFIG_IEEE802154_DEFAULT_PHY_OQPSK)
225 #define CONFIG_IEEE802154_DEFAULT_PHY_MODE IEEE802154_PHY_OQPSK
226 #elif IS_ACTIVE(CONFIG_IEEE802154_DEFAULT_PHY_MR_OQPSK)
227 #define CONFIG_IEEE802154_DEFAULT_PHY_MODE IEEE802154_PHY_MR_OQPSK
228 #elif IS_ACTIVE(CONFIG_IEEE802154_DEFAULT_PHY_MR_OFDM)
229 #define CONFIG_IEEE802154_DEFAULT_PHY_MODE IEEE802154_PHY_MR_OFDM
230 #elif IS_ACTIVE(CONFIG_IEEE802154_DEFAULT_PHY_MR_FSK)
231 #define CONFIG_IEEE802154_DEFAULT_PHY_MODE IEEE802154_PHY_MR_FSK
234 #ifndef CONFIG_IEEE802154_DEFAULT_PHY_MODE
235 #define CONFIG_IEEE802154_DEFAULT_PHY_MODE IEEE802154_PHY_OQPSK
241 #ifndef CONFIG_IEEE802154_DEFAULT_SUBGHZ_CHANNEL
242 #define CONFIG_IEEE802154_DEFAULT_SUBGHZ_CHANNEL (5U)
248 #ifndef CONFIG_IEEE802154_DEFAULT_CHANNEL
249 #define CONFIG_IEEE802154_DEFAULT_CHANNEL (26U)
255 #ifndef CONFIG_IEEE802154_DEFAULT_SUBGHZ_PAGE
256 #define CONFIG_IEEE802154_DEFAULT_SUBGHZ_PAGE (2U)
262 #ifndef CONFIG_IEEE802154_DEFAULT_PANID
263 #define CONFIG_IEEE802154_DEFAULT_PANID (0x0023U)
269 #ifndef IEEE802154_PANID_BCAST
270 #define IEEE802154_PANID_BCAST { 0xff, 0xff }
276 #ifndef CONFIG_IEEE802154_DEFAULT_TXPOWER
277 #define CONFIG_IEEE802154_DEFAULT_TXPOWER (0)
284 #ifndef CONFIG_IEEE802154_DEFAULT_CSMA_CA_MIN_BE
285 #define CONFIG_IEEE802154_DEFAULT_CSMA_CA_MIN_BE (3U)
291 #ifndef CONFIG_IEEE802154_DEFAULT_CSMA_CA_RETRIES
292 #define CONFIG_IEEE802154_DEFAULT_CSMA_CA_RETRIES (4U)
298 #ifndef CONFIG_IEEE802154_DEFAULT_CSMA_CA_MAX_BE
299 #define CONFIG_IEEE802154_DEFAULT_CSMA_CA_MAX_BE (5U)
305 #ifndef CONFIG_IEEE802154_CCA_THRESH_DEFAULT
306 #define CONFIG_IEEE802154_CCA_THRESH_DEFAULT (-70)
312 #ifndef CONFIG_IEEE802154_DEFAULT_MAX_FRAME_RETRANS
313 #define CONFIG_IEEE802154_DEFAULT_MAX_FRAME_RETRANS (4U)
320 #define CONFIG_IEEE802154_AUTO_ACK_DISABLE 0
326 #ifndef CONFIG_IEEE802154_DEFAULT_ACK_REQ
327 #define CONFIG_IEEE802154_DEFAULT_ACK_REQ 1
374 const uint8_t *dst,
size_t dst_len,
376 uint8_t flags, uint8_t seq);
479 eui64->
uint8[0] = addr[i++] ^ 0x02;
480 eui64->
uint8[1] = addr[i++];
481 eui64->
uint8[2] = addr[i++];
482 eui64->
uint8[3] = addr[i++];
483 eui64->
uint8[4] = addr[i++];
484 eui64->
uint8[5] = addr[i++];
485 eui64->
uint8[6] = addr[i++];
486 eui64->
uint8[7] = addr[i++];
490 eui64->
uint8[0] = addr[i++] ^ 0x02;
491 eui64->
uint8[1] = addr[i++];
496 eui64->
uint8[3] = 0xff;
497 eui64->
uint8[4] = 0xfe;
499 eui64->
uint8[6] = addr[i++];
500 eui64->
uint8[7] = addr[i++];
547 const int max = min + (UINT8_MAX - 1);
549 int val = dbm <= min ? min : (dbm >= max ? max : dbm);
Functions to work with different byte orders.
EUI-64 data type definition.
Common macros and compiler attributes/pragmas configuration.
A 16 bit integer in big endian aka network byte order.
Data type to represent an EUI-64.
uint8_t uint8[8]
split into 8 8-bit words.
A 16 bit integer in little endian.