lwmac_internal.h¶
Interface definition for internal functions of LWMAC protocol.
-
GNRC_LWMAC_TX_CONTINUE
¶ Flag to track if the sender can continue to transmit packet to the receiver in its TX procedure.
1
(0x0008U)
LWMAC supports burst transmission based on the pending-bit technique. Namely, if the sender has multi packets for the same receiver, it can successively transmit its packets back to back with this flag set up, with the awareness that the receiver will also keep awake for receptions.
-
GNRC_LWMAC_QUIT_TX
¶ Flag to track if the sender should quit Tx in current cycle.
1
(0x0010U)
This flag is mainly for collision avoidance. In case a node overhears ongoing broadcast packets stream or other ongoing transmissions of other communication pairs during its wake-up period, it sets up this flag, which quits all its potential transmission attempts in this current cycle (started by the wake-up period), thus not to collide with other (neighbor) nodes’ transmissions.
-
GNRC_LWMAC_PHASE_BACKOFF
¶ Flag to track if the device need to reselect a new wake-up phase.
1
(0x0020U)
This flag is mainly for potential collision avoidance. In multi-hop scenario, it could be dangerous that a sender’s wake-up phase is close to its receiver’s, which may lead to collisions when the sender is sending to the receiver while the sender’s son nodes are also sending to the sender. To avoid this, in case a sender finds its phase close to its receiver’s, it sets up this flag and then randomly reselects a new wake-up phase.
-
GNRC_LWMAC_QUIT_RX
¶ Flag to track if the device needs to quit the wake-up (listening) procedure.
1
(0x0040U)
LWMAC adopts an auto wake-up extension scheme. That is, normally, after each data reception in the wake-up period, it extends the wake-up period to another basic duration, thus to receive more potential incoming packets, which is also correlated to the pending-bit transmission scheme to support burst transmissions to boost throughput. However, in some situations, like receiving broadcast (stream) packet, the receiver should immediately goto sleep (by setting up this flag) after one reception, thus not to receive duplicate broadcast packets.
-
GNRC_LWMAC_RTT_EVENT_MARGIN_TICKS
¶ Next RTT event must be at least this far in the future.
1
(RTT_MS_TO_TICKS(2))
When setting an RTT alarm to short in the future it could be possible that the counter already passed the calculated alarm before it could be set.
-
void
gnrc_lwmac_set_tx_continue
(gnrc_netif_t * netif, bool tx_continue)¶ set the
lwmac_internal.h::GNRC_LWMAC_TX_CONTINUE
flag of the deviceParameters
netif: ptr to the network interface tx_continue: value for LWMAC tx-continue flag
-
bool
gnrc_lwmac_get_tx_continue
(gnrc_netif_t * netif)¶ get the
lwmac_internal.h::GNRC_LWMAC_TX_CONTINUE
flag of the deviceParameters
netif: ptr to the network interface Return values
- true if tx continue
- false if tx will not continue
-
void
gnrc_lwmac_set_quit_tx
(gnrc_netif_t * netif, bool quit_tx)¶ set the
lwmac_internal.h::GNRC_LWMAC_QUIT_TX
flag of the deviceParameters
netif: ptr to the network interface quit_tx: value for lwmac_internal.h::GNRC_LWMAC_QUIT_TX
flag
-
bool
gnrc_lwmac_get_quit_tx
(gnrc_netif_t * netif)¶ get the
lwmac_internal.h::GNRC_LWMAC_QUIT_TX
flag of the deviceParameters
netif: ptr to the network interface Return values
- true if quit tx
- false if will not quit tx
-
void
gnrc_lwmac_set_phase_backoff
(gnrc_netif_t * netif, bool backoff)¶ set the
lwmac_internal.h::GNRC_LWMAC_PHASE_BACKOFF
flag of the deviceParameters
netif: ptr to the network interface backoff: value for LWMAC lwmac_internal.h::GNRC_LWMAC_PHASE_BACKOFF
flag
-
bool
gnrc_lwmac_get_phase_backoff
(gnrc_netif_t * netif)¶ get the
lwmac_internal.h::GNRC_LWMAC_PHASE_BACKOFF
flag of the deviceParameters
netif: ptr to the network interface Return values
- true if will run phase-backoff
- false if will not run phase-backoff
-
void
gnrc_lwmac_set_quit_rx
(gnrc_netif_t * netif, bool quit_rx)¶ set the
lwmac_internal.h::GNRC_LWMAC_QUIT_RX
flag of the deviceParameters
netif: ptr to the network interface quit_rx: value for LWMAC lwmac_internal.h::GNRC_LWMAC_QUIT_RX
flag
-
bool
gnrc_lwmac_get_quit_rx
(gnrc_netif_t * netif)¶ get the
lwmac_internal.h::GNRC_LWMAC_QUIT_RX
flag of the deviceParameters
netif: ptr to the network interface Return values
- true if will quit rx
- false if will not quit rx
-
void
gnrc_lwmac_set_dutycycle_active
(gnrc_netif_t * netif, bool active)¶ set the
sys/include/net/gnrc/lwmac/types.h::GNRC_LWMAC_DUTYCYCLE_ACTIVE
flag of LWMACParameters
netif: ptr to the network interface active: value for LWMAC sys/include/net/gnrc/lwmac/types.h::GNRC_LWMAC_DUTYCYCLE_ACTIVE
flag
-
bool
gnrc_lwmac_get_dutycycle_active
(gnrc_netif_t * netif)¶ get the
sys/include/net/gnrc/lwmac/types.h::GNRC_LWMAC_DUTYCYCLE_ACTIVE
flag of LWMACParameters
netif: ptr to the network interface Return values
- true if active
- false if not active
-
void
gnrc_lwmac_set_reschedule
(gnrc_netif_t * netif, bool reschedule)¶ set the
sys/include/net/gnrc/lwmac/types.h::GNRC_LWMAC_NEEDS_RESCHEDULE
flag of LWMACParameters
netif: ptr to the network interface reschedule: value for sys/include/net/gnrc/lwmac/types.h::GNRC_LWMAC_NEEDS_RESCHEDULE
flag
-
bool
gnrc_lwmac_get_reschedule
(gnrc_netif_t * netif)¶ get the
sys/include/net/gnrc/lwmac/types.h::GNRC_LWMAC_NEEDS_RESCHEDULE
flag of LWMACParameters
netif: ptr to the network interface Return values
- true if needs rescheduling
- false if no need for rescheduling
-
int
_gnrc_lwmac_transmit
(gnrc_netif_t * netif,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* pkt)¶ send a packet over the network interface in LWMAC
-
int
_gnrc_lwmac_parse_packet
(include/net/gnrc/pkt.h::gnrc_pktsnip_t
* pkt, gnrc_lwmac_packet_info_t * info)¶ Parse an incoming packet and extract important information.
Copies addresses into
info
, but header points insidepkt
.Parameters
pkt: packet that will be parsed info: structure that will hold parsed information Return values
- 0 if correctly parsed
- <0 on error
-
netopt.h::netopt_state_t
_gnrc_lwmac_get_netdev_state
(gnrc_netif_t * netif)¶ Shortcut to get the state of netdev.
Parameters
netif: ptr to the network interface Return values
- state of netdev
-
void
_gnrc_lwmac_set_netdev_state
(gnrc_netif_t * netif,netopt.h::netopt_state_t
devstate)¶ Shortcut to set the state of netdev.
Parameters
netif: ptr to the network interface devstate: new state for netdev
-
uint32_t
_gnrc_lwmac_ticks_to_phase
(uint32_t ticks)¶ Convert RTT ticks to device phase.
Parameters
ticks: RTT ticks Return values
- device phase
-
uint32_t
_gnrc_lwmac_phase_now
(void)¶ Get device’s current phase.
Return values
- device phase
-
uint32_t
_gnrc_lwmac_ticks_until_phase
(uint32_t phase)¶ Calculate how many ticks remaining to the targeted phase in the future.
Parameters
phase: device phase Return values
- RTT ticks
-
int
_gnrc_lwmac_dispatch_defer
(include/net/gnrc/pkt.h::gnrc_pktsnip_t
* buffer,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* pkt)¶ Store the received packet to the dispatch buffer and remove possible duplicate packets.
Parameters
buffer: RX dispatch packet buffer pkt: received packet Return values
- 0 if correctly stored
- <0 on error