#include <stdio.h>
#include "contiki.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#define MAX_RETRANSMISSIONS 4
#define NUM_HISTORY_ENTRIES 4
PROCESS(test_runicast_process,
"runicast test");
AUTOSTART_PROCESSES(&test_runicast_process);
struct history_entry {
struct history_entry *
next;
rimeaddr_t addr;
uint8_t seq;
};
MEMB(history_mem,
struct history_entry, NUM_HISTORY_ENTRIES);
static void
recv_runicast(struct runicast_conn *c, const rimeaddr_t *from, uint8_t seqno)
{
struct history_entry *e =
NULL;
break;
}
}
}
e->seq = seqno;
} else {
if(e->seq == seqno) {
printf("runicast message received from %d.%d, seqno %d (DUPLICATE)\n",
from->u8[0], from->u8[1], seqno);
return;
}
e->seq = seqno;
}
printf("runicast message received from %d.%d, seqno %d\n",
from->u8[0], from->u8[1], seqno);
}
static void
sent_runicast(struct runicast_conn *c, const rimeaddr_t *to, uint8_t retransmissions)
{
printf("runicast message sent to %d.%d, retransmissions %d\n",
to->u8[0], to->u8[1], retransmissions);
}
static void
timedout_runicast(struct runicast_conn *c, const rimeaddr_t *to, uint8_t retransmissions)
{
printf("runicast message timed out when sending to %d.%d, retransmissions %d\n",
to->u8[0], to->u8[1], retransmissions);
}
static const struct runicast_callbacks runicast_callbacks = {recv_runicast,
sent_runicast,
timedout_runicast};
static struct runicast_conn runicast;
{
runicast_open(&runicast, 144, &runicast_callbacks);
}
while(1) {
if(!runicast_is_transmitting(&runicast)) {
rimeaddr_t recv;
recv.u8[0] = 1;
recv.u8[1] = 0;
printf("%u.%u: sending runicast to address %u.%u\n",
recv.u8[0],
recv.u8[1]);
runicast_send(&runicast, &recv, MAX_RETRANSMISSIONS);
}
}
}