gomach/types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Shuguo Zhuo
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 
19 #ifndef NET_GNRC_GOMACH_TYPES_H
20 #define NET_GNRC_GOMACH_TYPES_H
21 
22 #include <stdint.h>
23 #include <stdbool.h>
24 
25 #include "kernel_types.h"
26 #include "xtimer.h"
27 #include "net/gnrc.h"
28 #include "net/gnrc/gomach/hdr.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 #define GNRC_GOMACH_EVENT_RTT_TYPE (0x4300)
38 
42 #define GNRC_GOMACH_EVENT_RTT_NEW_CYCLE (0x4301)
43 
47 #define GNRC_GOMACH_EVENT_TIMEOUT_TYPE (0x4400)
48 
52 #define GNRC_GOMACH_PHASE_UNINITIALIZED (0)
53 
57 #define GNRC_GOMACH_PHASE_MAX (-1)
58 
62 #define GNRC_GOMACH_DUPCHK_BUFFER_SIZE (8U)
63 
67 #define GNRC_GOMACH_TIMEOUT_COUNT (6U)
68 
73 #define GNRC_GOMACH_SLOSCH_UNIT_COUNT (11U)
74 
79 #define GNRC_GOMACH_TYPE_UNKNOWN (0U)
80 
85 #define GNRC_GOMACH_TYPE_KNOWN (1U)
86 
92 #ifndef GNRC_GOMACH_ENABLE_DUTYCYLE_RECORD
93 #define GNRC_GOMACH_ENABLE_DUTYCYLE_RECORD (0U)
94 #endif
95 
99 typedef enum {
106 
111 typedef enum {
122 
127 typedef enum {
137 
141 typedef enum {
146 
150 typedef enum {
156 
160 typedef enum {
173 
177 typedef enum {
182 
186 typedef enum {
202 
206 typedef struct {
209 
216 typedef struct {
218  uint8_t queue_indicator;
220 
224 typedef struct {
225  uint8_t total_slots_num;
226  uint8_t sub_channel_seq;
228 
232 typedef struct {
234  uint8_t seq;
235  uint8_t life_cycle;
237 
242 typedef struct {
245  uint8_t queue_head;
248 
252 typedef struct {
256  uint8_t seq;
258 
262 typedef struct {
263  uint16_t sub_channel_seq;
264  uint8_t slots_position;
265  uint8_t slots_num;
267 
271 typedef struct {
274  bool expired;
275  gnrc_gomach_timeout_type_t type;
277 
281 #define GNRC_GOMACH_TIMEOUT_INIT { {}, {}, false, GNRC_GOMACH_TIMEOUT_DISABLED }
282 
286 typedef struct gomach {
287  gnrc_gomach_basic_state_t basic_state;
288  gnrc_gomach_init_state_t init_state;
292  uint16_t sub_channel_seq;
293  uint16_t pub_channel_1;
294  uint16_t pub_channel_2;
295  uint16_t cur_pub_channel;
296  uint8_t cp_extend_count;
297  uint32_t last_wakeup;
298  uint32_t backoff_phase_us;
299  uint16_t gomach_info;
302  int16_t rx_pkt_rssi;
304  uint8_t rx_pkt_lqi;
308 #if (GNRC_GOMACH_ENABLE_DUTYCYLE_RECORD == 1)
309  /* Parameters for recording duty-cycle */
310  uint64_t last_radio_on_time_ticks;
312  uint64_t radio_off_time_ticks;
314  uint64_t system_start_time_ticks;
316  uint64_t awake_duration_sum_ticks;
318 #endif
319 } gnrc_gomach_t;
320 
321 #ifdef __cplusplus
322 }
323 #endif
324 
325 #endif /* NET_GNRC_GOMACH_TYPES_H */
326 
gnrc_gomach_l2_addr_t node_addr
Node&#39;s address.
Definition: gomach/types.h:217
uint16_t pub_channel_2
Public channel 2.
Definition: gomach/types.h:294
Types used by the kernel.
uint16_t subchannel_occu_flags
Sub-channel usage indicator.
Definition: gomach/types.h:290
GoMacH&#39;s slot-schedule-unit.
Definition: gomach/types.h:216
struct gomach gnrc_gomach_t
GoMacH&#39;s specific structure for storing internal states.
End of the vTDMA period.
Definition: gomach/types.h:168
Broadcast packet in GoMacH.
Definition: gomach/types.h:180
uint64_t last_wakeup_phase_us
Last cycle wakeup phase.
Definition: gomach/types.h:301
Timeout of vTDMA period end.
Definition: gomach/types.h:199
Timeout is disabled.
Definition: gomach/types.h:187
Send preamble in t2u.
Definition: gomach/types.h:130
Timeout of maximum preamble duration.
Definition: gomach/types.h:192
gnrc_gomach_timeout_type_t type
GoMacH timeout type.
Definition: gomach/types.h:275
Listen for incoming packets in vTDMA.
Definition: gomach/types.h:167
Announce the sub-channel sequence of the node.
Definition: gomach/types.h:152
Initiate t2u procedure.
Definition: gomach/types.h:128
GoMacH internal L2 address structure.
Definition: gomach/types.h:206
gnrc_gomach_init_state_t
State-machine states of initialization procedure of GoMacH.
Definition: gomach/types.h:150
bool expired
Timeout expiration indicator.
Definition: gomach/types.h:274
Transmit to phase-known node in GoMacH.
Definition: gomach/types.h:179
uint8_t slots_num
Node&#39;s allocated slots number.
Definition: gomach/types.h:265
Prepare the initialization procedure of GoMacH.
Definition: gomach/types.h:151
#define GNRC_GOMACH_TIMEOUT_COUNT
The default largest number of parallel timeouts in GoMacH.
Definition: gomach/types.h:67
int16_t rx_pkt_rssi
RSSI of latest received packet in dBm.
Definition: gomach/types.h:302
gnrc_gomach_l2_addr_t node_addr
Node&#39;s address.
Definition: gomach/types.h:233
End of packet listen period.
Definition: gomach/types.h:163
Listen for incoming packets.
Definition: gomach/types.h:162
xtimer_t timer
xtimer entity.
Definition: gomach/types.h:272
Transmit data in receiver&#39;s CP period.
Definition: gomach/types.h:114
Wait for broadcast TX finish.
Definition: gomach/types.h:102
Wait for the node&#39;s allocated slots period.
Definition: gomach/types.h:117
#define GNRC_GOMACH_DUPCHK_BUFFER_SIZE
GoMacH check duplicate packet buffer size.
Definition: gomach/types.h:62
gnrc_gomach_basic_state_t
State-machine states of basic management procedure of GoMacH.
Definition: gomach/types.h:141
uint16_t gomach_info
GoMacH&#39;s internal information.
Definition: gomach/types.h:299
gnrc_gomach_listen_state_t
State-machine states of duty-cycled listening procedure of GoMacH.
Definition: gomach/types.h:160
Turn radio off to sleep.
Definition: gomach/types.h:170
uint32_t last_wakeup
Last wake-up timing.
Definition: gomach/types.h:297
Prepare settings before sending preamble.
Definition: gomach/types.h:129
GoMacH&#39;s vTDMA (dynamic slots allocation) management unit.
Definition: gomach/types.h:224
End of the initialization procedure of GoMacH.
Definition: gomach/types.h:154
Wait for preamble-ACK from receiver.
Definition: gomach/types.h:132
Timeout of maximum CP duration.
Definition: gomach/types.h:197
End of t2u procedure.
Definition: gomach/types.h:135
gnrc_gomach_t2u_state_t
State-machine states of Transmission-to-phase-unknown (t2u) procedure of GoMacH.
Definition: gomach/types.h:127
uint8_t rx_pkt_lqi
LQI of latest received packet.
Definition: gomach/types.h:304
Timeout of waiting reception complete.
Definition: gomach/types.h:198
Wait for next broadcast TX timing.
Definition: gomach/types.h:103
gnrc_gomach_timeout_t timeouts[GNRC_GOMACH_TIMEOUT_COUNT]
GoMacH&#39;s timeouts.
Definition: gomach/types.h:289
uint8_t total_slots_num
Number of total allocated transmission slots.
Definition: gomach/types.h:225
uint32_t backoff_phase_us
Phase backoff time.
Definition: gomach/types.h:298
Timeout of CP (wake-up) period ending.
Definition: gomach/types.h:196
End of broadcast procedure.
Definition: gomach/types.h:104
gnrc_gomach_timeout_type_t
GoMacH timeout types.
Definition: gomach/types.h:186
gnrc_gomach_hdr_t * header
GoMacH header of packet.
Definition: gomach/types.h:253
Transmit data in allocate slots.
Definition: gomach/types.h:118
uint8_t life_cycle
Lifetime of this record unit.
Definition: gomach/types.h:235
Send data packet to the receiver.
Definition: gomach/types.h:133
uint8_t queue_head
Check queue&#39;s head.
Definition: gomach/types.h:245
Timeout of next broadcast transmission.
Definition: gomach/types.h:189
uint8_t queue_indicator
Node&#39;s queue-length indicator.
Definition: gomach/types.h:218
Includes all essential GNRC network stack base modules.
msg_t msg
msg entity.
Definition: gomach/types.h:273
Wait for send beacon TX finish.
Definition: gomach/types.h:165
Sender&#39;s vTDMA (dynamic slots allocation) management unit.
Definition: gomach/types.h:262
uint16_t sub_channel_seq
Sub-channel sequence.
Definition: gomach/types.h:292
GoMacH frame header.
Initiate the listen period.
Definition: gomach/types.h:161
xtimer interface definitions
Describes a message object which can be sent between threads.
Definition: msg.h:184
Send beacon packet when needed.
Definition: gomach/types.h:164
Header definition of GoMacH.
Initiate the sleep period.
Definition: gomach/types.h:169
GoMacH&#39;s specific structure for storing internal states.
Definition: gomach/types.h:286
gnrc_gomach_l2_addr_t src_addr
Copied source address of packet.
Definition: gomach/types.h:254
Wait for announce TX finish.
Definition: gomach/types.h:153
Initiate t2k procedure.
Definition: gomach/types.h:112
uint8_t seq
Node&#39;s MAC packet sequence.
Definition: gomach/types.h:234
GoMacH&#39;s data structure for recording sender&#39;s past TX information.
Definition: gomach/types.h:232
Initiate the vTDMA period.
Definition: gomach/types.h:166
Transmit to phase-unknown node in GoMacH.
Definition: gomach/types.h:178
Wait for receiver&#39;s CP (wake-up) period.
Definition: gomach/types.h:113
gnrc_gomach_basic_state_t basic_state
Basic state.
Definition: gomach/types.h:287
Initiate GoMacH.
Definition: gomach/types.h:142
uint16_t sub_channel_seq
Receiver&#39;s sub-channel sequence.
Definition: gomach/types.h:263
GoMacH&#39;s data structure for recording TX information for avoiding receiving duplicate packets...
Definition: gomach/types.h:242
gnrc_gomach_bcast_state_t
State-machine states of Broadcast procedure of GoMacH.
Definition: gomach/types.h:99
Send broadcast packet.
Definition: gomach/types.h:101
End of the sleep period.
Definition: gomach/types.h:171
gnrc_gomach_l2_addr_t dst_addr
Copied destination address of packet.
Definition: gomach/types.h:255
Type to pass information about packet parsing.
Definition: gomach/types.h:252
Timeout of waiting own slots.
Definition: gomach/types.h:195
xtimer timer structure
Definition: xtimer.h:70
uint16_t cur_pub_channel
Current public channel.
Definition: gomach/types.h:295
End of t2k procedure.
Definition: gomach/types.h:120
GoMacH&#39;s transmission procedure.
Definition: gomach/types.h:144
Timeout of next preamble transmission.
Definition: gomach/types.h:190
uint8_t slots_position
Node&#39;s own slots position.
Definition: gomach/types.h:264
GoMacH&#39;s duty-cycled listen procedure.
Definition: gomach/types.h:143
GoMacH&#39;s timeout structure.
Definition: gomach/types.h:271
Timeout of waiting beacon.
Definition: gomach/types.h:194
Timeout of maximum preamble interval.
Definition: gomach/types.h:191
gnrc_gomach_t2k_state_t
State-machine states of Transmission-to-phase-known (t2k) procedure of GoMacH.
Definition: gomach/types.h:111
gnrc_gomach_transmit_state_t
State-machine states of basic transmission management procedure of GoMacH.
Definition: gomach/types.h:177
Initiate broadcast.
Definition: gomach/types.h:100
uint16_t pub_channel_1
Public channel 1.
Definition: gomach/types.h:293
Wait for CP transmission finish.
Definition: gomach/types.h:115
gnrc_gomach_init_state_t init_state
Initialization state.
Definition: gomach/types.h:288
Wait for Send preamble TX finish.
Definition: gomach/types.h:131
uint8_t seq
MAC sequence of the received packet.
Definition: gomach/types.h:256
Timeout of waiting receiver&#39;s CP period.
Definition: gomach/types.h:193
uint8_t cp_extend_count
CP extend count.
Definition: gomach/types.h:296
Timeout of maximum transmission duration.
Definition: gomach/types.h:200
Wait receiver&#39;s beacon.
Definition: gomach/types.h:116
Wait for TX finish in TX-slot.
Definition: gomach/types.h:119
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
Wait for Send data TX finish.
Definition: gomach/types.h:134
GoMacH internal L2 address structure.
uint8_t sub_channel_seq
Receiver&#39;s sub-channel sequence.
Definition: gomach/types.h:226
Timeout of broadcast procedure end.
Definition: gomach/types.h:188