19#ifndef GOMACH_INTERNAL_H
20#define GOMACH_INTERNAL_H
34#define GNRC_GOMACH_INFO_TX_FINISHED (0x0008U)
39#define GNRC_GOMACH_INFO_PKT_RECEIVED (0x0010U)
44#define GNRC_GOMACH_INTERNAL_INFO_ND_UPDATE (0x0001U)
49#define GNRC_GOMACH_INTERNAL_INFO_QUIT_CYCLE (0x0002U)
54#define GNRC_GOMACH_INTERNAL_INFO_CP_END (0x0004U)
59#define GNRC_GOMACH_INTERNAL_INFO_VTDMA_END (0x0008U)
64#define GNRC_GOMACH_INTERNAL_INFO_UNINTD_PREAMBLE (0x0010U)
69#define GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLE (0x0020U)
74#define GNRC_GOMACH_INTERNAL_INFO_DUTY_CYCLE_START (0x0040U)
79#define GNRC_GOMACH_INTERNAL_INFO_PHASE_BACKOFF (0x0080U)
84#define GNRC_GOMACH_INTERNAL_INFO_BEACON_FAIL (0x0200U)
89#define GNRC_GOMACH_INTERNAL_INFO_BUFFER_FULL (0x0400U)
94#define GNRC_GOMACH_INTERNAL_INFO_ENTER_NEW_CYCLE (0x0800U)
99#define GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLEACK (0x1000U)
104#define GNRC_GOMACH_INTERNAL_INFO_ON_PUBCHAN_1 (0x2000U)
109#define GNRC_GOMACH_INTERNAL_INFO_MAX_PREAM_INTERV (0x4000U)
114#define GNRC_GOMACH_INTERNAL_INFO_RADIO_IS_ON (0x8000U)
130 netif->
mac.
mac_info &= ~GNRC_GOMACH_INFO_TX_FINISHED;
161 netif->
mac.
mac_info &= ~GNRC_GOMACH_INFO_PKT_RECEIVED;
192 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_QUIT_CYCLE;
223 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLE;
254 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_CP_END;
285 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_VTDMA_END;
312 if (uintd_preamble) {
316 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_UNINTD_PREAMBLE;
347 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_ND_UPDATE;
378 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_DUTY_CYCLE_START;
409 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_PHASE_BACKOFF;
440 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_BEACON_FAIL;
471 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_BUFFER_FULL;
502 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_ENTER_NEW_CYCLE;
533 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLEACK;
564 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_ON_PUBCHAN_1;
595 netif->
mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_MAX_PREAM_INTERV;
700 sizeof(channel_num));
#define assert(cond)
abort the program if assertion is false
Definition for GNRC's network interfaces.
static void gnrc_gomach_set_unintd_preamble(gnrc_netif_t *netif, bool uintd_preamble)
Set the GNRC_GOMACH_INTERNAL_INFO_UNINTD_PREAMBLE flag of the device.
static bool gnrc_gomach_get_got_preamble_ack(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLEACK flag of the device.
static bool gnrc_gomach_get_update(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_ND_UPDATE flag of the device.
static bool gnrc_gomach_get_vTDMA_end(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_VTDMA_END flag of the device.
int gnrc_gomach_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt, netopt_enable_t csma_enable)
Send a pktsnip in GoMacH.
static bool gnrc_gomach_get_enter_new_cycle(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_ENTER_NEW_CYCLE flag of the device.
#define GNRC_GOMACH_INTERNAL_INFO_PHASE_BACKOFF
Flag to track if node need to backoff its phase in GoMacH.
#define GNRC_GOMACH_INTERNAL_INFO_ENTER_NEW_CYCLE
Flag to track if node has entered a new cycle in GoMacH.
#define GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLE
Flag to track if need to quit the current cycle in GoMacH.
int gnrc_gomach_send_preamble_ack(gnrc_netif_t *netif, gnrc_gomach_packet_info_t *info)
Reply a preamble-ACK packet in GoMacH.
int gnrc_gomach_dispatch_defer(gnrc_pktsnip_t *buffer[], gnrc_pktsnip_t *pkt)
Store the received packet to the dispatch buffer.
void gnrc_gomach_packet_process_in_wait_beacon(gnrc_netif_t *netif)
Process the received packets when waiting for the beacon during t2k procedure in GoMacH.
static bool gnrc_gomach_get_unintd_preamble(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_UNINTD_PREAMBLE flag of the device.
static bool gnrc_gomach_get_phase_backoff(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_PHASE_BACKOFF flag of the device.
void gnrc_gomach_indicator_update(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt, gnrc_gomach_packet_info_t *pa_info)
Update the queue-length indicator of the packet sender.
void gnrc_gomach_update_neighbor_phase(gnrc_netif_t *netif)
Update the TX neighbors' phases in GoMacH.
void gnrc_gomach_process_preamble_ack(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
Process the received preamble-ACK packet to get phase-locked with the sender.
static netopt_state_t gnrc_gomach_get_netdev_state(gnrc_netif_t *netif)
Shortcut to get the state of netdev.
static void gnrc_gomach_set_on_pubchan_1(gnrc_netif_t *netif, bool on_pubchan_1)
Set the GNRC_GOMACH_INTERNAL_INFO_ON_PUBCHAN_1 flag of the device.
bool gnrc_gomach_find_next_tx_neighbor(gnrc_netif_t *netif)
Find a neighbor that is next to send packet to.
static bool gnrc_gomach_get_duty_cycle_start(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_DUTY_CYCLE_START flag of the device.
int gnrc_gomach_send_preamble(gnrc_netif_t *netif, netopt_enable_t csma_enable)
Send a preamble packet to the targeted neighbor.
static void gnrc_gomach_set_enter_new_cycle(gnrc_netif_t *netif, bool enter)
Set the GNRC_GOMACH_INTERNAL_INFO_ENTER_NEW_CYCLE flag of the device.
bool gnrc_gomach_check_duplicate(gnrc_netif_t *netif, gnrc_gomach_packet_info_t *pa_info)
Check if the received packet is a duplicate packet.
#define GNRC_GOMACH_INTERNAL_INFO_MAX_PREAM_INTERV
Flag to track if node has reached maximum preamble interval.
static void gnrc_gomach_set_ack_req(gnrc_netif_t *netif, netopt_enable_t ack_req)
Set the ACK-require parameter of the device.
#define GNRC_GOMACH_INTERNAL_INFO_QUIT_CYCLE
Flag to track if need to quit the current cycle in GoMacH.
static bool gnrc_gomach_get_cp_end(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_CP_END flag of the device.
static void gnrc_gomach_set_pkt_received(gnrc_netif_t *netif, bool received)
Set the GNRC_GOMACH_INFO_PKT_RECEIVED flag of the device.
static bool gnrc_gomach_get_on_pubchan_1(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_ON_PUBCHAN_1 flag of the device.
static void gnrc_gomach_set_buffer_full(gnrc_netif_t *netif, bool full)
Set the GNRC_GOMACH_INTERNAL_INFO_BUFFER_FULL flag of the device.
void gnrc_gomach_cp_packet_process(gnrc_netif_t *netif)
Process packets received during the CP (wake-up) period of GoMacH.
static void gnrc_gomach_set_duty_cycle_start(gnrc_netif_t *netif, bool start)
Set the GNRC_GOMACH_INTERNAL_INFO_DUTY_CYCLE_START flag of the device.
uint64_t gnrc_gomach_phase_now(gnrc_netif_t *netif)
Get device's current phase.
static void gnrc_gomach_set_got_preamble_ack(gnrc_netif_t *netif, bool got)
Set the GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLEACK flag of the device.
static void gnrc_gomach_set_phase_backoff(gnrc_netif_t *netif, bool backoff)
Set the GNRC_GOMACH_INTERNAL_INFO_PHASE_BACKOFF flag of the device.
void gnrc_gomach_set_netdev_state(gnrc_netif_t *netif, netopt_state_t devstate)
Shortcut to set the state of netdev.
void gnrc_gomach_packet_process_in_vtdma(gnrc_netif_t *netif)
Process the received packets in the vTDMA period in GoMacH.
static bool gnrc_gomach_get_got_preamble(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLE flag of the device.
static bool gnrc_gomach_get_tx_finish(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INFO_TX_FINISHED flag of the device.
int _gnrc_gomach_transmit(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
send a packet over the network interface in GoMacH
static void gnrc_gomach_set_tx_finish(gnrc_netif_t *netif, bool tx_finish)
Set the GNRC_GOMACH_INFO_TX_FINISHED flag of the device.
static bool gnrc_gomach_get_beacon_fail(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_BEACON_FAIL flag of the device.
int gnrc_gomach_send_beacon(gnrc_netif_t *netif)
Broadcast a beacon packet in GoMacH.
void gnrc_gomach_init_choose_subchannel(gnrc_netif_t *netif)
Choose a sub-channel for a device running GoMacH.
int gnrc_gomach_bcast_subchann_seq(gnrc_netif_t *netif, netopt_enable_t use_csma)
Broadcast the chosen sub-channel sequence to the device's neighbors.
#define GNRC_GOMACH_INTERNAL_INFO_ND_UPDATE
Flag to track if need to update GoMacH.
#define GNRC_GOMACH_INTERNAL_INFO_DUTY_CYCLE_START
Flag to track if node's duty-cycle has started in GoMacH.
static void gnrc_gomach_set_got_preamble(gnrc_netif_t *netif, bool got_preamble)
Set the GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLE flag of the device.
static bool gnrc_gomach_get_pkt_received(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INFO_PKT_RECEIVED flag of the device.
#define GNRC_GOMACH_INTERNAL_INFO_UNINTD_PREAMBLE
Flag to track if the node has received unintended preamble.
static void gnrc_gomach_set_beacon_fail(gnrc_netif_t *netif, bool fail)
Set the GNRC_GOMACH_INTERNAL_INFO_BEACON_FAIL flag of the device.
void gnrc_gomach_update_neighbor_pubchan(gnrc_netif_t *netif)
Update the TX neighbors' public channel phase in GoMacH.
#define GNRC_GOMACH_INFO_PKT_RECEIVED
Flag to track if a packet has been successfully received.
static void gnrc_gomach_turn_channel(gnrc_netif_t *netif, uint16_t channel_num)
Turn the radio to a specific channel.
#define GNRC_GOMACH_INTERNAL_INFO_VTDMA_END
Flag to track if vTDMA has ended in GoMacH.
void gnrc_gomach_process_pkt_in_wait_preamble_ack(gnrc_netif_t *netif)
Process the received packets to when waiting for the preamble-ACK packet.
static bool gnrc_gomach_get_quit_cycle(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_QUIT_CYCLE flag of the device.
static void gnrc_gomach_set_update(gnrc_netif_t *netif, bool update)
Set the GNRC_GOMACH_INTERNAL_INFO_ND_UPDATE flag of the device.
#define GNRC_GOMACH_INTERNAL_INFO_ON_PUBCHAN_1
Flag to track if node's radio is on public-channel-1.
static bool gnrc_gomach_get_buffer_full(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_BUFFER_FULL flag of the device.
#define GNRC_GOMACH_INTERNAL_INFO_BEACON_FAIL
Flag to track if beacon transmission fail in GoMacH.
static void gnrc_gomach_set_quit_cycle(gnrc_netif_t *netif, bool quit)
Set the GNRC_GOMACH_INTERNAL_INFO_QUIT_CYCLE flag of the device.
#define GNRC_GOMACH_INFO_TX_FINISHED
Flag to track if the transmission has finished.
#define GNRC_GOMACH_INTERNAL_INFO_CP_END
Flag to track if CP period has ended in GoMacH.
#define GNRC_GOMACH_INTERNAL_INFO_GOT_PREAMBLEACK
Flag to track if node has got preamble-ACK in GoMacH.
int gnrc_gomach_send_data(gnrc_netif_t *netif, netopt_enable_t csma_enable)
Send a data packet to the targeted neighbor.
static bool gnrc_gomach_get_max_pream_interv(gnrc_netif_t *netif)
Get the GNRC_GOMACH_INTERNAL_INFO_MAX_PREAM_INTERV flag of the device.
static void gnrc_gomach_set_autoack(gnrc_netif_t *netif, netopt_enable_t autoack)
Set the auto-ACK parameter of the device.
void gnrc_gomach_beacon_process(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
Process the received beacon packet.
#define GNRC_GOMACH_INTERNAL_INFO_BUFFER_FULL
Flag to track if node's packet buffer is full in GoMacH.
static void gnrc_gomach_set_vTDMA_end(gnrc_netif_t *netif, bool vtdma_end)
Set the GNRC_GOMACH_INTERNAL_INFO_VTDMA_END flag of the device.
static void gnrc_gomach_set_max_pream_interv(gnrc_netif_t *netif, bool max)
Set the GNRC_GOMACH_INTERNAL_INFO_MAX_PREAM_INTERV flag of the device.
static void gnrc_gomach_set_cp_end(gnrc_netif_t *netif, bool cp_end)
Set the GNRC_GOMACH_INTERNAL_INFO_CP_END flag of the device.
#define ENOSYS
Function not supported.
netopt_enable_t
Binary parameter for enabling and disabling options.
netopt_state_t
Option parameter to be used with NETOPT_STATE to set or get the state of a network device or protocol...
@ NETOPT_STATE
(netopt_state_t) state of network device
@ NETOPT_ACK_REQ
(netopt_enable_t) acknowledgement request on outgoing frames
@ NETOPT_AUTOACK
(netopt_enable_t) automatic link layer ACKs
@ NETOPT_CHANNEL
(uint16_t) channel number
Low-level RTT (Real Time Timer) peripheral driver interface definitions.
Type to pass information about packet parsing.
uint16_t mac_info
general information for the MAC protocol
Representation of a network interface.
gnrc_netif_mac_t mac
Common MAC module component
netdev_t * dev
Network device of the network interface.
Type to represent parts (either headers or payload) of a packet, called snips.
int(* get)(netdev_t *dev, netopt_t opt, void *value, size_t max_len)
Get an option value from a given network device.
int(* set)(netdev_t *dev, netopt_t opt, const void *value, size_t value_len)
Set an option value for a given network device.
const struct netdev_driver * driver
ptr to that driver's interface.