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 
90 typedef enum {
97 
102 typedef enum {
113 
118 typedef enum {
128 
132 typedef enum {
137 
141 typedef enum {
147 
151 typedef enum {
164 
168 typedef enum {
173 
177 typedef enum {
193 
197 typedef struct {
200 
207 typedef struct {
209  uint8_t queue_indicator;
211 
215 typedef struct {
216  uint8_t total_slots_num;
217  uint8_t sub_channel_seq;
219 
223 typedef struct {
225  uint8_t seq;
226  uint8_t life_cycle;
228 
233 typedef struct {
236  uint8_t queue_head;
239 
243 typedef struct {
247  uint8_t seq;
249 
253 typedef struct {
254  uint16_t sub_channel_seq;
255  uint8_t slots_position;
256  uint8_t slots_num;
258 
262 typedef struct {
265  bool expired;
266  gnrc_gomach_timeout_type_t type;
268 
272 #define GNRC_GOMACH_TIMEOUT_INIT { {}, {}, false, GNRC_GOMACH_TIMEOUT_DISABLED }
273 
277 typedef struct gomach {
278  gnrc_gomach_basic_state_t basic_state;
279  gnrc_gomach_init_state_t init_state;
283  uint16_t sub_channel_seq;
284  uint16_t pub_channel_1;
285  uint16_t pub_channel_2;
286  uint16_t cur_pub_channel;
287  uint8_t cp_extend_count;
288  uint32_t last_wakeup;
289  uint32_t backoff_phase_us;
290  uint16_t gomach_info;
293  int16_t rx_pkt_rssi;
295  uint8_t rx_pkt_lqi;
298 #if (GNRC_MAC_ENABLE_DUTYCYCLE_RECORD == 1)
299  /* Parameters for recording duty-cycle */
300  uint64_t last_radio_on_time_ticks;
302  uint64_t radio_off_time_ticks;
304  uint64_t system_start_time_ticks;
306  uint64_t awake_duration_sum_ticks;
308 #endif
309 } gnrc_gomach_t;
310 
311 #ifdef __cplusplus
312 }
313 #endif
314 
315 #endif /* NET_GNRC_GOMACH_TYPES_H */
316 
gnrc_gomach_l2_addr_t node_addr
Node&#39;s address.
Definition: gomach/types.h:208
uint16_t pub_channel_2
Public channel 2.
Definition: gomach/types.h:285
Types used by the kernel.
uint16_t subchannel_occu_flags
Sub-channel usage indicator.
Definition: gomach/types.h:281
GoMacH&#39;s slot-schedule-unit.
Definition: gomach/types.h:207
struct gomach gnrc_gomach_t
GoMacH&#39;s specific structure for storing internal states.
End of the vTDMA period.
Definition: gomach/types.h:159
Broadcast packet in GoMacH.
Definition: gomach/types.h:171
uint64_t last_wakeup_phase_us
Last cycle wakeup phase.
Definition: gomach/types.h:292
Timeout of vTDMA period end.
Definition: gomach/types.h:190
Timeout is disabled.
Definition: gomach/types.h:178
Send preamble in t2u.
Definition: gomach/types.h:121
Timeout of maximum preamble duration.
Definition: gomach/types.h:183
gnrc_gomach_timeout_type_t type
GoMacH timeout type.
Definition: gomach/types.h:266
Listen for incoming packets in vTDMA.
Definition: gomach/types.h:158
Announce the sub-channel sequence of the node.
Definition: gomach/types.h:143
Initiate t2u procedure.
Definition: gomach/types.h:119
GoMacH internal L2 address structure.
Definition: gomach/types.h:197
gnrc_gomach_init_state_t
State-machine states of initialization procedure of GoMacH.
Definition: gomach/types.h:141
bool expired
Timeout expiration indicator.
Definition: gomach/types.h:265
Transmit to phase-known node in GoMacH.
Definition: gomach/types.h:170
uint8_t slots_num
Node&#39;s allocated slots number.
Definition: gomach/types.h:256
Prepare the initialization procedure of GoMacH.
Definition: gomach/types.h:142
#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:293
gnrc_gomach_l2_addr_t node_addr
Node&#39;s address.
Definition: gomach/types.h:224
End of packet listen period.
Definition: gomach/types.h:154
Listen for incoming packets.
Definition: gomach/types.h:153
xtimer_t timer
xtimer entity.
Definition: gomach/types.h:263
Transmit data in receiver&#39;s CP period.
Definition: gomach/types.h:105
Wait for broadcast TX finish.
Definition: gomach/types.h:93
Wait for the node&#39;s allocated slots period.
Definition: gomach/types.h:108
#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:132
uint16_t gomach_info
GoMacH&#39;s internal information.
Definition: gomach/types.h:290
gnrc_gomach_listen_state_t
State-machine states of duty-cycled listening procedure of GoMacH.
Definition: gomach/types.h:151
Turn radio off to sleep.
Definition: gomach/types.h:161
uint32_t last_wakeup
Last wake-up timing.
Definition: gomach/types.h:288
Prepare settings before sending preamble.
Definition: gomach/types.h:120
GoMacH&#39;s vTDMA (dynamic slots allocation) management unit.
Definition: gomach/types.h:215
End of the initialization procedure of GoMacH.
Definition: gomach/types.h:145
Wait for preamble-ACK from receiver.
Definition: gomach/types.h:123
Timeout of maximum CP duration.
Definition: gomach/types.h:188
End of t2u procedure.
Definition: gomach/types.h:126
gnrc_gomach_t2u_state_t
State-machine states of Transmission-to-phase-unknown (t2u) procedure of GoMacH.
Definition: gomach/types.h:118
uint8_t rx_pkt_lqi
LQI of latest received packet.
Definition: gomach/types.h:295
Timeout of waiting reception complete.
Definition: gomach/types.h:189
Wait for next broadcast TX timing.
Definition: gomach/types.h:94
gnrc_gomach_timeout_t timeouts[GNRC_GOMACH_TIMEOUT_COUNT]
GoMacH&#39;s timeouts.
Definition: gomach/types.h:280
uint8_t total_slots_num
Number of total allocated transmission slots.
Definition: gomach/types.h:216
uint32_t backoff_phase_us
Phase backoff time.
Definition: gomach/types.h:289
Timeout of CP (wake-up) period ending.
Definition: gomach/types.h:187
End of broadcast procedure.
Definition: gomach/types.h:95
gnrc_gomach_timeout_type_t
GoMacH timeout types.
Definition: gomach/types.h:177
gnrc_gomach_hdr_t * header
GoMacH header of packet.
Definition: gomach/types.h:244
Transmit data in allocate slots.
Definition: gomach/types.h:109
uint8_t life_cycle
Lifetime of this record unit.
Definition: gomach/types.h:226
Send data packet to the receiver.
Definition: gomach/types.h:124
uint8_t queue_head
Check queue&#39;s head.
Definition: gomach/types.h:236
Timeout of next broadcast transmission.
Definition: gomach/types.h:180
uint8_t queue_indicator
Node&#39;s queue-length indicator.
Definition: gomach/types.h:209
Includes all essential GNRC network stack base modules.
msg_t msg
msg entity.
Definition: gomach/types.h:264
Wait for send beacon TX finish.
Definition: gomach/types.h:156
Sender&#39;s vTDMA (dynamic slots allocation) management unit.
Definition: gomach/types.h:253
uint16_t sub_channel_seq
Sub-channel sequence.
Definition: gomach/types.h:283
GoMacH frame header.
Initiate the listen period.
Definition: gomach/types.h:152
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:155
Header definition of GoMacH.
Initiate the sleep period.
Definition: gomach/types.h:160
GoMacH&#39;s specific structure for storing internal states.
Definition: gomach/types.h:277
gnrc_gomach_l2_addr_t src_addr
Copied source address of packet.
Definition: gomach/types.h:245
Wait for announce TX finish.
Definition: gomach/types.h:144
Initiate t2k procedure.
Definition: gomach/types.h:103
uint8_t seq
Node&#39;s MAC packet sequence.
Definition: gomach/types.h:225
GoMacH&#39;s data structure for recording sender&#39;s past TX information.
Definition: gomach/types.h:223
Initiate the vTDMA period.
Definition: gomach/types.h:157
Transmit to phase-unknown node in GoMacH.
Definition: gomach/types.h:169
Wait for receiver&#39;s CP (wake-up) period.
Definition: gomach/types.h:104
gnrc_gomach_basic_state_t basic_state
Basic state.
Definition: gomach/types.h:278
Initiate GoMacH.
Definition: gomach/types.h:133
uint16_t sub_channel_seq
Receiver&#39;s sub-channel sequence.
Definition: gomach/types.h:254
GoMacH&#39;s data structure for recording TX information for avoiding receiving duplicate packets...
Definition: gomach/types.h:233
gnrc_gomach_bcast_state_t
State-machine states of Broadcast procedure of GoMacH.
Definition: gomach/types.h:90
Send broadcast packet.
Definition: gomach/types.h:92
End of the sleep period.
Definition: gomach/types.h:162
gnrc_gomach_l2_addr_t dst_addr
Copied destination address of packet.
Definition: gomach/types.h:246
Type to pass information about packet parsing.
Definition: gomach/types.h:243
Timeout of waiting own slots.
Definition: gomach/types.h:186
xtimer timer structure
Definition: xtimer.h:70
uint16_t cur_pub_channel
Current public channel.
Definition: gomach/types.h:286
End of t2k procedure.
Definition: gomach/types.h:111
GoMacH&#39;s transmission procedure.
Definition: gomach/types.h:135
Timeout of next preamble transmission.
Definition: gomach/types.h:181
uint8_t slots_position
Node&#39;s own slots position.
Definition: gomach/types.h:255
GoMacH&#39;s duty-cycled listen procedure.
Definition: gomach/types.h:134
GoMacH&#39;s timeout structure.
Definition: gomach/types.h:262
Timeout of waiting beacon.
Definition: gomach/types.h:185
Timeout of maximum preamble interval.
Definition: gomach/types.h:182
gnrc_gomach_t2k_state_t
State-machine states of Transmission-to-phase-known (t2k) procedure of GoMacH.
Definition: gomach/types.h:102
gnrc_gomach_transmit_state_t
State-machine states of basic transmission management procedure of GoMacH.
Definition: gomach/types.h:168
Initiate broadcast.
Definition: gomach/types.h:91
uint16_t pub_channel_1
Public channel 1.
Definition: gomach/types.h:284
Wait for CP transmission finish.
Definition: gomach/types.h:106
gnrc_gomach_init_state_t init_state
Initialization state.
Definition: gomach/types.h:279
Wait for Send preamble TX finish.
Definition: gomach/types.h:122
uint8_t seq
MAC sequence of the received packet.
Definition: gomach/types.h:247
Timeout of waiting receiver&#39;s CP period.
Definition: gomach/types.h:184
uint8_t cp_extend_count
CP extend count.
Definition: gomach/types.h:287
Timeout of maximum transmission duration.
Definition: gomach/types.h:191
Wait receiver&#39;s beacon.
Definition: gomach/types.h:107
Wait for TX finish in TX-slot.
Definition: gomach/types.h:110
#define IEEE802154_LONG_ADDRESS_LEN
long address (EUI-64)
Wait for Send data TX finish.
Definition: gomach/types.h:125
GoMacH internal L2 address structure.
uint8_t sub_channel_seq
Receiver&#39;s sub-channel sequence.
Definition: gomach/types.h:217
Timeout of broadcast procedure end.
Definition: gomach/types.h:179