lwmac/types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Daniel Krebs
3  * 2016 INRIA
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
22 #ifndef NET_GNRC_LWMAC_TYPES_H
23 #define NET_GNRC_LWMAC_TYPES_H
24 
25 #include "msg.h"
26 #include "xtimer.h"
27 #include "net/gnrc/lwmac/hdr.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 #define GNRC_LWMAC_EVENT_RTT_TYPE (0x4300)
37 
41 #define GNRC_LWMAC_EVENT_RTT_START (0x4301)
42 
46 #define GNRC_LWMAC_EVENT_RTT_STOP (0x4302)
47 
51 #define GNRC_LWMAC_EVENT_RTT_PAUSE (0x4303)
52 
56 #define GNRC_LWMAC_EVENT_RTT_RESUME (0x4304)
57 
61 #define GNRC_LWMAC_EVENT_RTT_WAKEUP_PENDING (0x4305)
62 
66 #define GNRC_LWMAC_EVENT_RTT_SLEEP_PENDING (0x4306)
67 
71 #define GNRC_LWMAC_EVENT_TIMEOUT_TYPE (0x4400)
72 
78 #define GNRC_LWMAC_DUTYCYCLE_ACTIVE (0x01)
79 
86 #define GNRC_LWMAC_NEEDS_RESCHEDULE (0x02)
87 
91 #define GNRC_LWMAC_RADIO_IS_ON (0x04)
92 
97 #ifndef GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD
98 #define GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD (0U)
99 #endif
100 
104 #ifndef GNRC_LWMAC_TIMEOUT_COUNT
105 #define GNRC_LWMAC_TIMEOUT_COUNT (3U)
106 #endif
107 
111 typedef enum {
123 
127 typedef enum {
139 
143 #define GNRC_LWMAC_TX_STATE_INITIAL GNRC_LWMAC_TX_STATE_STOPPED
144 
148 typedef enum {
158 
162 #define GNRC_LWMAC_RX_STATE_INITIAL GNRC_LWMAC_RX_STATE_STOPPED
163 
167 #define GNRC_LWMAC_PHASE_UNINITIALIZED (0)
168 
172 #define GNRC_LWMAC_PHASE_MAX (-1)
173 
177 typedef enum {
187 
191 typedef struct {
194  bool expired;
195  gnrc_lwmac_timeout_type_t type;
197 
201 typedef struct lwmac {
202  gnrc_lwmac_state_t state;
203  uint32_t last_wakeup;
204  uint8_t lwmac_info;
207 #if (GNRC_LWMAC_ENABLE_DUTYCYLE_RECORD == 1)
208  /* Parameters for recording duty-cycle */
209  uint32_t last_radio_on_time_ticks;
210  uint32_t radio_off_time_ticks;
211  uint32_t system_start_time_ticks;
212  uint32_t awake_duration_sum_ticks;
213  uint32_t pkt_start_sending_time_ticks;
215 #endif
216 } gnrc_lwmac_t;
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #endif /* NET_GNRC_LWMAC_TYPES_H */
223 
TX is handled in own state machine.
Definition: lwmac/types.h:119
Undefined state of LWMAC.
Definition: lwmac/types.h:112
msg_t msg
msg entity
Definition: lwmac/types.h:193
Turn off radio to conserve power.
Definition: lwmac/types.h:120
Wait for a wakeup request.
Definition: lwmac/types.h:151
#define GNRC_LWMAC_TIMEOUT_COUNT
The default largest number of parallel timeouts in LWMAC.
Definition: lwmac/types.h:105
Wake up period timeout for going to sleep.
Definition: lwmac/types.h:183
xtimer_t timer
xtimer entity
Definition: lwmac/types.h:192
WR timeout, waiting WA.
Definition: lwmac/types.h:179
bool expired
If type != DISABLED, this indicates if timeout has expired.
Definition: lwmac/types.h:194
Listen the channel for receiving packets.
Definition: lwmac/types.h:117
Reception over, but nothing received.
Definition: lwmac/types.h:156
Reset LWMAC's main state machine.
Definition: lwmac/types.h:116
LWMAC timeout structure.
Definition: lwmac/types.h:191
Wait for actual payload data.
Definition: lwmac/types.h:154
gnrc_lwmac_timeout_type_t
LWMAC timeout types.
Definition: lwmac/types.h:177
gnrc_lwmac_timeout_t timeouts[GNRC_LWMAC_TIMEOUT_COUNT]
Store timeouts used for protocol.
Definition: lwmac/types.h:205
RX is handled in own state machine.
Definition: lwmac/types.h:118
Initiate transmission.
Definition: lwmac/types.h:129
Wait until WR sent to set timeout.
Definition: lwmac/types.h:132
Recption has finished successfully.
Definition: lwmac/types.h:155
Timeout for waiting to send the next broadcast packet.
Definition: lwmac/types.h:184
Wait for dest node's wakeup ackknowledge.
Definition: lwmac/types.h:133
Start LWMAC's main state machine.
Definition: lwmac/types.h:114
Wait until WA sent to set timeout.
Definition: lwmac/types.h:153
gnrc_lwmac_state_t state
Internal state of MAC layer.
Definition: lwmac/types.h:202
Tx schedule stopped, stop sending packet.
Definition: lwmac/types.h:128
Send wakeup ackknowledge to requesting node.
Definition: lwmac/types.h:152
Payload data couldn't be delivered to dest.
Definition: lwmac/types.h:137
Messaging API for inter process communication.
Wait if packet was ACKed.
Definition: lwmac/types.h:135
xtimer interface definitions
Describes a message object which can be sent between threads.
Definition: msg.h:184
gnrc_lwmac_rx_state_t
RX states of LWMAC.
Definition: lwmac/types.h:148
Timeout awaiting the end of the whole broadcast period.
Definition: lwmac/types.h:185
directly goes to SUCCESSFUL or FAILED when finished
Definition: lwmac/types.h:130
gnrc_lwmac_tx_state_t
TX states of LWMAC.
Definition: lwmac/types.h:127
Send a wakeup request.
Definition: lwmac/types.h:131
Stop LWMAC's main state machine.
Definition: lwmac/types.h:115
gnrc_lwmac_timeout_type_t type
timeout type
Definition: lwmac/types.h:195
struct lwmac gnrc_lwmac_t
LWMAC specific structure for storing internal states.
gnrc_lwmac_state_t
Internal states of LWMAC.
Definition: lwmac/types.h:111
uint32_t last_wakeup
Used to calculate wakeup times.
Definition: lwmac/types.h:203
Transmission has finished successfully.
Definition: lwmac/types.h:136
Initiate reception.
Definition: lwmac/types.h:150
Timeout is diabled.
Definition: lwmac/types.h:178
Rx schedule stopped.
Definition: lwmac/types.h:149
LWMAC specific structure for storing internal states.
Definition: lwmac/types.h:201
xtimer timer structure
Definition: xtimer.h:70
LWMAC's main state machine has been stopped.
Definition: lwmac/types.h:113
uint8_t lwmac_info
LWMAC's internal informations (flags)
Definition: lwmac/types.h:204
Send the actual payload data.
Definition: lwmac/types.h:134
Timeout for waiting receiver's wake-up phase.
Definition: lwmac/types.h:182
Count of LWMAC's states.
Definition: lwmac/types.h:121
Maximum WR duration timeout awaiting WA.
Definition: lwmac/types.h:180
Header definition LWMAC.
Timeout awaiting data packet from receiver.
Definition: lwmac/types.h:181