#include "contiki.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
#include "node-id.h"
PROCESS(example_unicast_process,
"Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);
static uint16_t count=0, count2=0;
static uint16_t first=0;
static uint8_t rec[100];
static void
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
printf("rec %u\n",seq);
if (first==0){
first=seq;
}
leds_off(1);
if (seq <=100+first){
rec[seq-first]=1;
}
count++;
if (count==101){
uint16_t i=0;
uint16_t l=0;
for (i=0; i<100; i++){
if (rec[i]==0){
printf("lost %u\n",i);
l++;
}
}
printf("loss %u\n",l);
}
leds_on(1);
printf("unicast message received from %d.%d\n",
from->u8[0], from->u8[1]);
int16_t rssi = packetbuf_attr(PACKETBUF_ATTR_RSSI);
}
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static struct unicast_conn uc;
{
unicast_open(&uc, 146, &unicast_callbacks);
printf("go\n");
while(1) {
rimeaddr_t addr;
static uint8_t a[10];
leds_on(2);
a[0]=count2;
count2++;
addr.u8[0] = 2;
addr.u8[1] = 0;
unicast_send(&uc, &addr);
}
leds_off(2);
}
}