42 #include "contiki-conf.h"
45 #include "dev/watchdog.h"
46 #include "lib/random.h"
59 #ifdef CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION
60 #define WITH_PHASE_OPTIMIZATION CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION
62 #define WITH_PHASE_OPTIMIZATION 1
65 #ifndef WITH_FAST_SLEEP
66 #define WITH_FAST_SLEEP 1
69 #ifndef RDC_CONF_HARDWARE_CSMA
70 #define RDC_CONF_HARDWARE_CSMA 0
73 #ifndef RDC_CONF_HARDWARE_ACK
74 #define RDC_CONF_HARDWARE_ACK 0
77 #ifndef RDC_CONF_MCU_SLEEP
78 #define RDC_CONF_MCU_SLEEP 0
81 #if NETSTACK_RDC_CHANNEL_CHECK_RATE >= 64
82 #undef WITH_PHASE_OPTIMIZATION
83 #define WITH_PHASE_OPTIMIZATION 0
87 #ifdef CONTIKIMAC_CONF_CYCLE_TIME
88 #define CYCLE_TIME (CONTIKIMAC_CONF_CYCLE_TIME)
90 #define CYCLE_TIME (RTIMER_ARCH_SECOND / NETSTACK_RDC_CHANNEL_CHECK_RATE)
100 #if RTIMER_ARCH_SECOND & (RTIMER_ARCH_SECOND - 1)
101 #define SYNC_CYCLE_STARTS 1
105 static int we_are_receiving_burst = 0;
109 #ifdef CONTIKIMAC_CONF_INTER_PACKET_DEADLINE
110 #define INTER_PACKET_DEADLINE CONTIKIMAC_CONF_INTER_PACKET_DEADLINE
112 #define INTER_PACKET_DEADLINE CLOCK_SECOND / 32
119 #ifdef CONTIKIMAC_CONF_CCA_COUNT_MAX
120 #define CCA_COUNT_MAX (CONTIKIMAC_CONF_CCA_COUNT_MAX)
122 #define CCA_COUNT_MAX 2
127 #ifdef CONTIKIMAC_CONF_CCA_COUNT_MAX_TX
128 #define CCA_COUNT_MAX_TX (CONTIKIMAC_CONF_CCA_COUNT_MAX_TX)
130 #define CCA_COUNT_MAX_TX 6
135 #ifdef CONTIKIMAC_CONF_CCA_CHECK_TIME
136 #define CCA_CHECK_TIME (CONTIKIMAC_CONF_CCA_CHECK_TIME)
138 #define CCA_CHECK_TIME RTIMER_ARCH_SECOND / 8192
143 #ifdef CONTIKIMAC_CONF_CCA_SLEEP_TIME
144 #define CCA_SLEEP_TIME CONTIKIMAC_CONF_CCA_SLEEP_TIME
146 #if RTIMER_ARCH_SECOND > 8000
147 #define CCA_SLEEP_TIME RTIMER_ARCH_SECOND / 2000
149 #define CCA_SLEEP_TIME (RTIMER_ARCH_SECOND / 2000) + 1
155 #define CHECK_TIME (CCA_COUNT_MAX * (CCA_CHECK_TIME + CCA_SLEEP_TIME))
159 #define CHECK_TIME_TX (CCA_COUNT_MAX_TX * (CCA_CHECK_TIME + CCA_SLEEP_TIME))
164 #ifdef CONTIKIMAC_CONF_LISTEN_TIME_AFTER_PACKET_DETECTED
165 #define LISTEN_TIME_AFTER_PACKET_DETECTED CONTIKIMAC_CONF_LISTEN_TIME_AFTER_PACKET_DETECTED
167 #define LISTEN_TIME_AFTER_PACKET_DETECTED RTIMER_ARCH_SECOND / 80
173 #ifdef CONTIKIMAC_CONF_MAX_SILENCE_PERIODS
174 #define MAX_SILENCE_PERIODS CONTIKIMAC_CONF_MAX_SILENCE_PERIODS
176 #define MAX_SILENCE_PERIODS 5
182 #ifdef CONTIKIMAC_CONF_MAX_NONACTIVITY_PERIODS
183 #define MAX_NONACTIVITY_PERIODS CONTIKIMAC_CONF_MAX_NONACTIVITY_PERIODS
185 #define MAX_NONACTIVITY_PERIODS 10
193 #define STROBE_TIME (CYCLE_TIME + 2 * CHECK_TIME)
197 #ifdef CONTIKIMAC_CONF_GUARD_TIME
198 #define GUARD_TIME CONTIKIMAC_CONF_GUARD_TIME
200 #define GUARD_TIME 10 * CHECK_TIME + CHECK_TIME_TX
204 #ifdef CONTIKIMAC_CONF_INTER_PACKET_INTERVAL
205 #define INTER_PACKET_INTERVAL CONTIKIMAC_CONF_INTER_PACKET_INTERVAL
207 #define INTER_PACKET_INTERVAL RTIMER_ARCH_SECOND / 2500
213 #ifdef CONTIKIMAC_CONF_AFTER_ACK_DETECTECT_WAIT_TIME
214 #define AFTER_ACK_DETECTECT_WAIT_TIME CONTIKIMAC_CONF_AFTER_ACK_DETECTECT_WAIT_TIME
216 #define AFTER_ACK_DETECTECT_WAIT_TIME RTIMER_ARCH_SECOND / 1500
221 #ifdef CONTIKIMAC_CONF_MAX_PHASE_STROBE_TIME
222 #define MAX_PHASE_STROBE_TIME CONTIKIMAC_CONF_MAX_PHASE_STROBE_TIME
224 #define MAX_PHASE_STROBE_TIME RTIMER_ARCH_SECOND / 60
227 #ifdef CONTIKIMAC_CONF_SEND_SW_ACK
228 #define CONTIKIMAC_SEND_SW_ACK CONTIKIMAC_CONF_SEND_SW_ACK
230 #define CONTIKIMAC_SEND_SW_ACK 0
239 static volatile uint8_t contikimac_is_on = 0;
240 static volatile uint8_t contikimac_keep_radio_on = 0;
242 static volatile unsigned char we_are_sending = 0;
243 static volatile unsigned char radio_is_on = 0;
248 #define PRINTF(...) printf(__VA_ARGS__)
249 #define PRINTDEBUG(...) printf(__VA_ARGS__)
252 #define PRINTDEBUG(...)
255 #if CONTIKIMAC_CONF_COMPOWER
259 #if WITH_PHASE_OPTIMIZATION
265 #define DEFAULT_STREAM_TIME (4 * CYCLE_TIME)
267 #if CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT
268 static struct timer broadcast_rate_timer;
269 static int broadcast_rate_counter;
276 if(contikimac_is_on && radio_is_on == 0) {
285 if(contikimac_is_on && radio_is_on != 0 &&
286 contikimac_keep_radio_on == 0) {
288 NETSTACK_RADIO.off();
292 static volatile rtimer_clock_t cycle_start;
293 static void powercycle_wrapper(
struct rtimer *t,
void *ptr);
294 static char powercycle(
struct rtimer *t,
void *ptr);
296 schedule_powercycle(
struct rtimer *t, rtimer_clock_t time)
301 if(contikimac_is_on) {
305 if(RTIMER_CLOCK_LT(time, now + RTIMER_GUARD_TIME)) {
306 time = now + RTIMER_GUARD_TIME;
312 PRINTF(
"schedule_powercycle: could not set rtimer\n");
318 schedule_powercycle_fixed(
struct rtimer *t, rtimer_clock_t fixed_time)
323 if(contikimac_is_on) {
326 if(RTIMER_CLOCK_LT(fixed_time, now + RTIMER_GUARD_TIME)) {
327 fixed_time = now + RTIMER_GUARD_TIME;
332 PRINTF(
"schedule_powercycle: could not set rtimer\n");
338 powercycle_turn_radio_off(
void)
340 #if CONTIKIMAC_CONF_COMPOWER
341 uint8_t was_on = radio_is_on;
344 if(we_are_sending == 0 && we_are_receiving_burst == 0) {
346 #if CONTIKIMAC_CONF_COMPOWER
347 if(was_on && !radio_is_on) {
355 powercycle_turn_radio_on(
void)
357 if(we_are_sending == 0 && we_are_receiving_burst == 0) {
363 powercycle_wrapper(
struct rtimer *t,
void *ptr)
369 powercycle(
struct rtimer *t,
void *ptr)
371 #if SYNC_CYCLE_STARTS
372 static volatile rtimer_clock_t sync_cycle_start;
373 static volatile uint8_t sync_cycle_phase;
378 #if SYNC_CYCLE_STARTS
385 static uint8_t packet_seen;
386 static uint8_t
count;
388 #if SYNC_CYCLE_STARTS
391 if(sync_cycle_phase++ == NETSTACK_RDC_CHANNEL_CHECK_RATE) {
392 sync_cycle_phase = 0;
393 sync_cycle_start += RTIMER_ARCH_SECOND;
394 cycle_start = sync_cycle_start;
396 #if (RTIMER_ARCH_SECOND * NETSTACK_RDC_CHANNEL_CHECK_RATE) > 65535
397 cycle_start = sync_cycle_start + ((
unsigned long)(sync_cycle_phase*RTIMER_ARCH_SECOND))/NETSTACK_RDC_CHANNEL_CHECK_RATE;
399 cycle_start = sync_cycle_start + (sync_cycle_phase*RTIMER_ARCH_SECOND)/NETSTACK_RDC_CHANNEL_CHECK_RATE;
403 cycle_start += CYCLE_TIME;
408 for(count = 0; count < CCA_COUNT_MAX; ++
count) {
409 if(we_are_sending == 0 && we_are_receiving_burst == 0) {
410 powercycle_turn_radio_on();
417 if(NETSTACK_RADIO.channel_clear() == 0) {
421 powercycle_turn_radio_off();
426 if (count == CCA_COUNT_MAX - 1) {
430 schedule_powercycle_fixed(t,
RTIMER_NOW() + CCA_SLEEP_TIME);
435 static rtimer_clock_t
start;
436 static uint8_t silence_periods, periods;
439 periods = silence_periods = 0;
440 while(we_are_sending == 0 && radio_is_on &&
442 (start + LISTEN_TIME_AFTER_PACKET_DETECTED))) {
453 if(NETSTACK_RADIO.channel_clear()) {
462 if(NETSTACK_RADIO.receiving_packet()) {
465 if(silence_periods > MAX_SILENCE_PERIODS) {
466 powercycle_turn_radio_off();
469 if(WITH_FAST_SLEEP &&
470 periods > MAX_NONACTIVITY_PERIODS &&
471 !(NETSTACK_RADIO.receiving_packet() ||
472 NETSTACK_RADIO.pending_packet())) {
473 powercycle_turn_radio_off();
476 if(NETSTACK_RADIO.pending_packet()) {
480 schedule_powercycle(t, CCA_CHECK_TIME + CCA_SLEEP_TIME);
484 if(!(NETSTACK_RADIO.receiving_packet() ||
485 NETSTACK_RADIO.pending_packet()) ||
487 (start + LISTEN_TIME_AFTER_PACKET_DETECTED))) {
488 powercycle_turn_radio_off();
493 if(RTIMER_CLOCK_LT(
RTIMER_NOW() - cycle_start, CYCLE_TIME - CHECK_TIME * 4)) {
498 #if RDC_CONF_MCU_SLEEP
499 static uint8_t sleepcycle;
500 if((sleepcycle++ < 16) && !we_are_sending && !radio_is_on) {
501 rtimer_arch_sleep(CYCLE_TIME - (
RTIMER_NOW() - cycle_start));
504 schedule_powercycle_fixed(t, CYCLE_TIME + cycle_start);
508 schedule_powercycle_fixed(t, CYCLE_TIME + cycle_start);
518 broadcast_rate_drop(
void)
520 #if CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT
522 broadcast_rate_counter++;
523 if(broadcast_rate_counter < CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT) {
530 broadcast_rate_counter = 0;
539 send_packet(mac_callback_t mac_callback,
void *mac_callback_ptr,
540 struct rdc_buf_list *buf_list,
541 int is_receiver_awake)
544 #if WITH_PHASE_OPTIMIZATION
545 rtimer_clock_t encounter_time = 0;
548 uint8_t got_strobe_ack = 0;
549 uint8_t is_broadcast = 0;
550 uint8_t is_known_receiver = 0;
554 uint8_t contikimac_was_on;
555 #if !RDC_CONF_HARDWARE_ACK
561 if(!contikimac_is_on && !contikimac_keep_radio_on) {
562 PRINTF(
"contikimac: radio is turned off\n");
563 return MAC_TX_ERR_FATAL;
567 PRINTF(
"contikimac: send_packet data len 0\n");
568 return MAC_TX_ERR_FATAL;
571 #if !NETSTACK_CONF_BRIDGE_MODE
577 PRINTDEBUG(
"contikimac: send broadcast\n");
579 if(broadcast_rate_drop()) {
583 #if NETSTACK_CONF_WITH_IPV6
584 PRINTDEBUG(
"contikimac: send unicast to %02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
585 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
586 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[1],
587 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[2],
588 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[3],
589 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[4],
590 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[5],
591 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[6],
592 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[7]);
594 PRINTDEBUG(
"contikimac: send unicast to %u.%u\n",
595 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
596 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[1]);
600 if(!packetbuf_attr(PACKETBUF_ATTR_IS_CREATED_AND_SECURED)) {
601 packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1);
602 if(NETSTACK_FRAMER.create() < 0) {
603 PRINTF(
"contikimac: framer failed\n");
604 return MAC_TX_ERR_FATAL;
611 if(!is_broadcast && !is_receiver_awake) {
612 #if WITH_PHASE_OPTIMIZATION
613 ret = phase_wait(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
614 CYCLE_TIME, GUARD_TIME,
615 mac_callback, mac_callback_ptr, buf_list);
616 if(ret == PHASE_DEFERRED) {
619 if(ret != PHASE_UNKNOWN) {
620 is_known_receiver = 1;
636 if(NETSTACK_RADIO.receiving_packet() || NETSTACK_RADIO.pending_packet()) {
638 PRINTF(
"contikimac: collision receiving %d, pending %d\n",
639 NETSTACK_RADIO.receiving_packet(), NETSTACK_RADIO.pending_packet());
658 contikimac_was_on = contikimac_is_on;
659 contikimac_is_on = 1;
661 #if !RDC_CONF_HARDWARE_CSMA
664 if(is_receiver_awake == 0) {
666 for(i = 0; i < CCA_COUNT_MAX_TX; ++i) {
669 #if CCA_CHECK_TIME > 0
670 while(RTIMER_CLOCK_LT(
RTIMER_NOW(), t0 + CCA_CHECK_TIME)) { }
672 if(NETSTACK_RADIO.channel_clear() == 0) {
679 while(RTIMER_CLOCK_LT(
RTIMER_NOW(), t0 + CCA_SLEEP_TIME)) { }
686 PRINTF(
"contikimac: collisions before sending\n");
687 contikimac_is_on = contikimac_was_on;
692 #if !RDC_CONF_HARDWARE_ACK
699 seqno = packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO);
704 for(strobes = 0, collisions = 0;
705 got_strobe_ack == 0 && collisions == 0 &&
706 RTIMER_CLOCK_LT(
RTIMER_NOW(), t0 + STROBE_TIME); strobes++) {
710 if(!is_broadcast && (is_receiver_awake || is_known_receiver) &&
711 !RTIMER_CLOCK_LT(
RTIMER_NOW(), t0 + MAX_PHASE_STROBE_TIME)) {
712 PRINTF(
"miss to %d\n", packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0]);
716 #if !RDC_CONF_HARDWARE_ACK
722 #if WITH_PHASE_OPTIMIZATION
725 #if RDC_CONF_HARDWARE_ACK
726 int ret = NETSTACK_RADIO.transmit(transmit_len);
728 NETSTACK_RADIO.transmit(transmit_len);
731 #if RDC_CONF_HARDWARE_ACK
734 if(ret == RADIO_TX_OK) {
737 #if WITH_PHASE_OPTIMIZATION
738 encounter_time = txtime;
742 }
else if (ret == RADIO_TX_NOACK) {
743 }
else if (ret == RADIO_TX_COLLISION) {
744 PRINTF(
"contikimac: collisions while sending\n");
748 while(RTIMER_CLOCK_LT(
RTIMER_NOW(), wt + INTER_PACKET_INTERVAL)) { }
752 while(RTIMER_CLOCK_LT(
RTIMER_NOW(), wt + INTER_PACKET_INTERVAL)) { }
754 if(!is_broadcast && (NETSTACK_RADIO.receiving_packet() ||
755 NETSTACK_RADIO.pending_packet() ||
756 NETSTACK_RADIO.channel_clear() == 0)) {
757 uint8_t ackbuf[ACK_LEN];
759 while(RTIMER_CLOCK_LT(
RTIMER_NOW(), wt + AFTER_ACK_DETECTECT_WAIT_TIME)) { }
761 len = NETSTACK_RADIO.read(ackbuf, ACK_LEN);
762 if(len == ACK_LEN && seqno == ackbuf[ACK_LEN - 1]) {
764 #if WITH_PHASE_OPTIMIZATION
765 encounter_time = txtime;
769 PRINTF(
"contikimac: collisions while sending\n");
779 PRINTF(
"contikimac: send (strobes=%u, len=%u, %s, %s), done\n", strobes,
781 got_strobe_ack ?
"ack" :
"no ack",
782 collisions ?
"collision" :
"no collision");
784 #if CONTIKIMAC_CONF_COMPOWER
799 contikimac_is_on = contikimac_was_on;
807 }
else if(!is_broadcast && !got_strobe_ack) {
813 #if WITH_PHASE_OPTIMIZATION
814 if(is_known_receiver && got_strobe_ack) {
815 PRINTF(
"no miss %d wake-ups %d\n",
816 packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
821 if(collisions == 0 && is_receiver_awake == 0) {
822 phase_update(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
823 encounter_time, ret);
832 qsend_packet(mac_callback_t sent,
void *ptr)
834 int ret = send_packet(sent, ptr,
NULL, 0);
836 mac_call_sent_callback(sent, ptr, ret, 1);
841 qsend_list(mac_callback_t sent,
void *ptr,
struct rdc_buf_list *buf_list)
843 struct rdc_buf_list *curr;
844 struct rdc_buf_list *next;
846 int is_receiver_awake;
849 if(buf_list ==
NULL) {
853 if(we_are_receiving_burst) {
855 queuebuf_to_packetbuf(buf_list->buf);
865 queuebuf_to_packetbuf(curr->buf);
866 if(!packetbuf_attr(PACKETBUF_ATTR_IS_CREATED_AND_SECURED)) {
869 packetbuf_set_attr(PACKETBUF_ATTR_PENDING, 1);
871 packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1);
872 if(NETSTACK_FRAMER.create() < 0) {
873 PRINTF(
"contikimac: framer failed\n");
874 mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
878 packetbuf_set_attr(PACKETBUF_ATTR_IS_CREATED_AND_SECURED, 1);
879 queuebuf_update_from_packetbuf(curr->buf);
882 }
while(next !=
NULL);
885 is_receiver_awake = 0;
891 queuebuf_to_packetbuf(curr->buf);
893 pending = packetbuf_attr(PACKETBUF_ATTR_PENDING);
896 ret = send_packet(sent, ptr, curr, is_receiver_awake);
898 mac_call_sent_callback(sent, ptr, ret, 1);
904 is_receiver_awake = 1;
911 }
while((next !=
NULL) && pending);
918 recv_burst_off(
void *ptr)
921 we_are_receiving_burst = 0;
927 static struct ctimer ct;
930 #if CONTIKIMAC_SEND_SW_ACK
931 int original_datalen;
932 uint8_t *original_dataptr;
938 if(!we_are_receiving_burst) {
944 PRINTF(
"ContikiMAC: ignored ack\n");
960 we_are_receiving_burst = packetbuf_attr(PACKETBUF_ATTR_PENDING);
961 if(we_are_receiving_burst) {
971 #if RDC_WITH_DUPLICATE_DETECTION
976 PRINTF(
"contikimac: Drop duplicate\n");
982 #if CONTIKIMAC_CONF_COMPOWER
998 #if CONTIKIMAC_SEND_SW_ACK
1006 uint8_t ackdata[ACK_LEN] = {0, 0, 0};
1009 ackdata[0] = FRAME802154_ACKFRAME;
1011 ackdata[2] = info154.
seq;
1012 NETSTACK_RADIO.send(ackdata, ACK_LEN);
1019 NETSTACK_MAC.input();
1023 PRINTDEBUG(
"contikimac: data not for us\n");
1038 contikimac_is_on = 1;
1040 #if WITH_PHASE_OPTIMIZATION
1049 if(contikimac_is_on == 0) {
1050 contikimac_is_on = 1;
1051 contikimac_keep_radio_on = 0;
1058 turn_off(
int keep_radio_on)
1060 contikimac_is_on = 0;
1061 contikimac_keep_radio_on = keep_radio_on;
1064 return NETSTACK_RADIO.on();
1067 return NETSTACK_RADIO.off();
1071 static unsigned short
1074 return (1ul *
CLOCK_SECOND * CYCLE_TIME) / RTIMER_ARCH_SECOND;
1077 const struct rdc_driver contikimac_driver = {
1089 contikimac_debug_print(
void)
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
Header file for the real-time timer module.
void mac_sequence_register_seqno(void)
Register the sequence number of the packetbuf.
Protothreads implementation.
uint8_t dest_addr[8]
Destination address.
#define PT_INIT(pt)
Initialize a protothread.
The MAC layer deferred the transmission for a later time.
static void start(void)
Start measurement.
The MAC layer did not get an acknowledgement for the packet.
Header file for the radio API
frame802154_fcf_t fcf
Frame control field.
void compower_attrconv(struct compower_activity *e)
Convert power contumption information to packet attributes.
void compower_clear(struct compower_activity *e)
Clear power consumption information for a communication activity.
#define RTIMER_NOW()
Get the current clock time.
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
#define PT_YIELD(pt)
Yield from the current protothread.
uint8_t seq
Sequence number.
void * list_item_next(void *item)
Get the next item following this item.
An activity record that contains power consumption information for a specific communication activity...
Header file for the communication power accounting module
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
void compower_accumulate(struct compower_activity *e)
Accumulate power contumption for a communication activity.
Header file for MAC sequence numbers management
int packetbuf_holds_broadcast(void)
Checks whether the current packet is a broadcast.
int mac_sequence_is_duplicate(void)
Tell whether the packetbuf is a duplicate packet.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
struct compower_activity compower_idle_activity
The default idle communication activity.
Header file for the ContikiMAC radio duty cycling protocol
The MAC layer transmission could not be performed because of an error.
void(* init)(void)
Initialize the RDC driver.
Header file for the Rime stack
The MAC layer transmission was OK.
#define NULL
The null pointer.
int rtimer_set(struct rtimer *rtimer, rtimer_clock_t time, rtimer_clock_t duration, rtimer_callback_t func, void *ptr)
Post a real-time task.
#define PT_BEGIN(pt)
Declare the start of a protothread inside the C function implementing the protothread.
void watchdog_periodic(void)
Writes the WDT clear sequence.
#define CLOCK_SECOND
A second, measured in system clock time.
int frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
Parses an input frame.
static volatile clock_time_t count
These routines define the AVR-specific calls declared in /core/sys/clock.h CLOCK_SECOND is the number...
The structure of a RDC (radio duty cycling) driver in Contiki.
void ctimer_set(struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr)
Set a callback timer.
uint8_t ack_required
1 bit.
#define PT_END(pt)
Declare the end of a protothread.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
void ctimer_stop(struct ctimer *c)
Stop a pending callback timer.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two Rime addresses.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
Representation of a real-time task.
Common functionality for phase optimization in duty cycling radio protocols
#define RTIMER_TIME(task)
Get the time that a task last was executed.
Parameters used by the frame802154_create() function.
Include file for the Contiki low-layer network stack (NETSTACK)
int timer_expired(struct timer *t)
Check if a timer has expired.