Loading...
Searching...
No Matches
ieee802154.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2019 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
20#ifndef NET_NETDEV_IEEE802154_H
21#define NET_NETDEV_IEEE802154_H
22
23#include "net/eui_provider.h"
24#include "net/ieee802154.h"
25#if IS_USED(MODULE_IEEE802154_SECURITY)
27#endif
28#include "net/gnrc/nettype.h"
29#include "net/netopt.h"
30#include "net/netdev.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
46#define NETDEV_IEEE802154_SEND_MASK (0x0028)
47#define NETDEV_IEEE802154_RAW (0x0002)
51#define NETDEV_IEEE802154_SRC_MODE_LONG (0x0004)
55#define NETDEV_IEEE802154_SECURITY_EN (IEEE802154_FCF_SECURITY_EN)
56
60#define NETDEV_IEEE802154_ACK_REQ (IEEE802154_FCF_ACK_REQ)
61
65#define NETDEV_IEEE802154_FRAME_PEND (IEEE802154_FCF_FRAME_PEND)
74#define NETDEV_RX_IEEE802154_INFO_FLAG_TIMESTAMP (0x01)
91
100typedef struct {
106#ifdef MODULE_GNRC
107 gnrc_nettype_t proto;
108#endif
109
113 uint16_t pan;
114
118 uint8_t short_addr[IEEE802154_SHORT_ADDRESS_LEN];
119
123 uint8_t long_addr[IEEE802154_LONG_ADDRESS_LEN];
124 uint8_t seq;
125 uint8_t chan;
126 uint8_t page;
127 uint16_t flags;
128 int16_t txpower;
129#if IS_USED(MODULE_IEEE802154_SECURITY) || defined(DOXYGEN)
131#endif
134
139 int16_t rssi;
140 uint8_t lqi;
141 uint8_t flags;
142#if IS_USED(MODULE_NETDEV_IEEE802154_RX_TIMESTAMP)
143 uint64_t timestamp;
144#endif
146
156 uint64_t timestamp)
157{
158 (void)dest;
159 (void)timestamp;
160#if IS_USED(MODULE_NETDEV_IEEE802154_RX_TIMESTAMP)
161 dest->timestamp = timestamp;
163#endif
164}
165
178 const netdev_ieee802154_rx_info_t *info,
179 uint64_t *dest)
180{
181 (void)info;
182 (void)dest;
183#if IS_USED(MODULE_NETDEV_IEEE802154_RX_TIMESTAMP)
185 *dest = info->timestamp;
186 return 0;
187 }
188#endif
189
190 return -1;
191}
192
202
217 size_t max_len);
218
245int netdev_ieee802154_set(netdev_ieee802154_t *dev, netopt_t opt, const void *value,
246 size_t value_len);
247
265
278{
279 /* generate EUI-64 and short address */
280 netdev_eui64_get(&dev->netdev, (eui64_t *)&dev->long_addr);
283}
284
285#ifdef __cplusplus
286}
287#endif
288
289#endif /* NET_NETDEV_IEEE802154_H */
Definitions low-level network driver interface.
EUI-48 and EUI-64 address provider.
struct netdev_ieee802154_rx_info netdev_ieee802154_rx_info_t
Received packet status information for IEEE 802.15.4 radios.
netdev_ieee802154_cca_mode_t
Option parameter to be used with NETOPT_CCA_MODE to set the mode of the clear channel assessment (CCA...
Definition ieee802154.h:82
int netdev_ieee802154_dst_filter(netdev_ieee802154_t *dev, const uint8_t *mhr)
This function compares destination address and pan id with addresses and pan id of the device.
#define NETDEV_RX_IEEE802154_INFO_FLAG_TIMESTAMP
Timestamp valid.
Definition ieee802154.h:74
static void netdev_ieee802154_rx_info_set_timestamp(netdev_ieee802154_rx_info_t *dest, uint64_t timestamp)
Write the given timestamp to the given RX info struct.
Definition ieee802154.h:154
int netdev_ieee802154_get(netdev_ieee802154_t *dev, netopt_t opt, void *value, size_t max_len)
Fallback function for netdev IEEE 802.15.4 devices' _get function.
static int netdev_ieee802154_rx_info_get_timestamp(const netdev_ieee802154_rx_info_t *info, uint64_t *dest)
Get the timestamp to from the RX info.
Definition ieee802154.h:177
void netdev_ieee802154_reset(netdev_ieee802154_t *dev)
Reset function for ieee802154 common fields.
static void netdev_ieee802154_setup(netdev_ieee802154_t *dev)
Configure the hardware address of a IEEE 802.15.4 devices.
Definition ieee802154.h:277
int netdev_ieee802154_set(netdev_ieee802154_t *dev, netopt_t opt, const void *value, size_t value_len)
Fallback function for netdev IEEE 802.15.4 devices' _set function.
@ NETDEV_IEEE802154_CCA_MODE_4
ALOHA.
Definition ieee802154.h:86
@ NETDEV_IEEE802154_CCA_MODE_2
Carrier sense only.
Definition ieee802154.h:84
@ NETDEV_IEEE802154_CCA_MODE_1
Energy above threshold.
Definition ieee802154.h:83
@ NETDEV_IEEE802154_CCA_MODE_6
UWB preamble sense based on the packet with the multiplexed preamble.
Definition ieee802154.h:88
@ NETDEV_IEEE802154_CCA_MODE_5
UWB preamble sense based on the SHR of a frame.
Definition ieee802154.h:87
@ NETDEV_IEEE802154_CCA_MODE_3
Carrier sense with energy above threshold.
Definition ieee802154.h:85
static void eui_short_from_eui64(eui64_t *addr_long, network_uint16_t *addr_short)
Get a short unicast address from an EUI-64.
void netdev_eui64_get(netdev_t *netdev, eui64_t *addr)
Generates an EUI-64 address for the netdev interface.
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition nettype.h:51
#define IEEE802154_SHORT_ADDRESS_LEN
IEEE 802.15.4 address lengths.
Definition ieee802154.h:44
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
Definition ieee802154.h:45
netopt_t
Global list of configuration options available throughout the network stack, e.g.
Definition netopt.h:45
IEEE 802.15.4 security interface.
Definition of global configuration options.
Protocol type definitions.
Struct to hold IEEE 802.15.4 security information.
Received packet status information for IEEE 802.15.4 radios.
Definition ieee802154.h:138
uint8_t flags
Flags e.g.
Definition ieee802154.h:141
uint8_t lqi
LQI of a received frame.
Definition ieee802154.h:140
int16_t rssi
RSSI of a received frame in dBm.
Definition ieee802154.h:139
Extended structure to hold IEEE 802.15.4 driver state.
Definition ieee802154.h:100
uint8_t long_addr[IEEE802154_LONG_ADDRESS_LEN]
Long address in network byte order.
Definition ieee802154.h:123
uint8_t seq
sequence number
Definition ieee802154.h:124
uint16_t pan
IEEE 802.15.4 specific fields.
Definition ieee802154.h:113
uint8_t short_addr[IEEE802154_SHORT_ADDRESS_LEN]
Short address in network byte order.
Definition ieee802154.h:118
ieee802154_sec_context_t sec_ctx
security context
Definition ieee802154.h:130
netdev_t netdev
netdev_t base class
Definition ieee802154.h:101
int16_t txpower
tx power in dBm
Definition ieee802154.h:128
uint8_t chan
channel
Definition ieee802154.h:125
uint16_t flags
flags as defined above
Definition ieee802154.h:127
uint8_t page
channel page
Definition ieee802154.h:126
Structure to hold driver state.
Definition netdev.h:362
IEEE 802.15.4 header definitions.
A 16 bit integer in big endian aka network byte order.
Definition byteorder.h:74
Data type to represent an EUI-64.
Definition eui64.h:55