nrfmin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2017 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 
72 #ifndef NRFMIN_H
73 #define NRFMIN_H
74 
75 #include "net/netdev.h"
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
85 #define NRFMIN_CHAN_MIN (0U)
86 #define NRFMIN_CHAN_DEFAULT (0U) /* 2400MHz */
87 #define NRFMIN_CHAN_MAX (32)
88 
93 #define NRFMIN_TXPOWER_DEFAULT (0) /* 0dBm */
94 
98 #define NRFMIN_ADDR_BCAST (0xffff)
99 
103 #ifndef NRFMIN_PAYLOAD_MAX
104 #define NRFMIN_PAYLOAD_MAX (200U)
105 #endif
106 
111 #define NRFMIN_HDR_LEN (sizeof(nrfmin_hdr_t))
112 #define NRFMIN_PKT_MAX (NRFMIN_HDR_LEN + NRFMIN_PAYLOAD_MAX)
113 
118 typedef struct __attribute__((packed)) {
119  uint8_t len;
120  uint16_t src_addr;
121  uint16_t dst_addr;
122  uint8_t proto;
123 } nrfmin_hdr_t;
124 
128 typedef union {
129  struct __attribute__((packed)) {
131  uint8_t payload[NRFMIN_PAYLOAD_MAX];
132  } pkt;
133  uint8_t raw[NRFMIN_PKT_MAX];
134 } nrfmin_pkt_t;
135 
139 extern netdev_t nrfmin_dev;
140 
144 extern const netdev_driver_t nrfmin_netdev;
145 
149 void nrfmin_setup(void);
150 
156 uint16_t nrfmin_get_addr(void);
157 
163 void nrfmin_set_addr(uint16_t addr);
164 
170 void nrfmin_get_iid(uint16_t *iid);
171 
177 uint16_t nrfmin_get_channel(void);
178 
187 int nrfmin_set_channel(uint16_t chan);
188 
195 
205 
211 int16_t nrfmin_get_txpower(void);
212 
218 void nrfmin_set_txpower(int16_t power);
219 
220 
221 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif /* NRFMIN_H */
227 
netdev_driver
Structure to hold driver interface -> function mapping.
Definition: netdev.h:344
nrfmin_netdev
const netdev_driver_t nrfmin_netdev
Reference to the netdev driver interface.
nrfmin_hdr_t::proto
uint8_t proto
protocol of payload
Definition: nrfmin.h:122
nrfmin_get_iid
void nrfmin_get_iid(uint16_t *iid)
Get the IID build from the 16-bit node address.
nrfmin_hdr_t::len
uint8_t len
packet length, including this header
Definition: nrfmin.h:119
NRFMIN_PAYLOAD_MAX
#define NRFMIN_PAYLOAD_MAX
Default maximum payload length (must be <= 250)
Definition: nrfmin.h:104
nrfmin_set_txpower
void nrfmin_set_txpower(int16_t power)
Set the used transmission power.
nrfmin_set_channel
int nrfmin_set_channel(uint16_t chan)
Set the active channel.
nrfmin_hdr_t::src_addr
uint16_t src_addr
source address of the packet
Definition: nrfmin.h:120
netopt_state_t
netopt_state_t
Option parameter to be used with NETOPT_STATE to set or get the state of a network device or protocol...
Definition: netopt.h:805
nrfmin_set_state
int nrfmin_set_state(netopt_state_t val)
Put the device into the given state.
nrfmin_hdr_t
Header format used for our custom nrfmin link layer.
Definition: nrfmin.h:118
netdev.h
Definitions low-level network driver interface.
nrfmin_pkt_t
In-memory structure of a nrfmin radio packet.
Definition: nrfmin.h:128
netdev
Structure to hold driver state.
Definition: netdev.h:302
nrfmin_get_state
netopt_state_t nrfmin_get_state(void)
Get the current radio state.
nrfmin_hdr_t::dst_addr
uint16_t dst_addr
destination address
Definition: nrfmin.h:121
nrfmin_get_channel
uint16_t nrfmin_get_channel(void)
Get the current channel.
nrfmin_get_txpower
int16_t nrfmin_get_txpower(void)
Get the current transmit power.
nrfmin_setup
void nrfmin_setup(void)
Setup the device driver's data structures.
nrfmin_get_addr
uint16_t nrfmin_get_addr(void)
Get the currently active address.
nrfmin_set_addr
void nrfmin_set_addr(uint16_t addr)
Set the 16-bit radio address.
nrfmin_dev
netdev_t nrfmin_dev
Export the netdev device descriptor.
nrfmin_pkt_t::hdr
nrfmin_hdr_t hdr
the nrfmin header
Definition: nrfmin.h:130