#include "contiki.h"
#include "lib/random.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
#define CHANNEL 26
struct example_neighbor {
struct example_neighbor *
next;
rimeaddr_t addr;
struct ctimer ctimer;
};
#define NEIGHBOR_TIMEOUT 60 * CLOCK_SECOND
#define MAX_NEIGHBORS 16
MEMB(neighbor_mem,
struct example_neighbor, MAX_NEIGHBORS);
PROCESS(example_multihop_process,
"multihop example");
AUTOSTART_PROCESSES(&example_multihop_process);
static void
remove_neighbor(void *n)
{
struct example_neighbor *e = n;
}
static void
const rimeaddr_t *from,
uint16_t id, uint16_t value)
{
struct example_neighbor *e;
ctimer_set(&e->ctimer, NEIGHBOR_TIMEOUT, remove_neighbor, e);
return;
}
}
ctimer_set(&e->ctimer, NEIGHBOR_TIMEOUT, remove_neighbor, e);
}
}
static void
recv(struct multihop_conn *c, const rimeaddr_t *sender,
const rimeaddr_t *prevhop,
uint8_t hops)
{
}
static rimeaddr_t *
forward(struct multihop_conn *c,
const rimeaddr_t *originator, const rimeaddr_t *dest,
const rimeaddr_t *prevhop, uint8_t hops)
{
int num, i;
struct example_neighbor *n;
i = 0;
for(n =
list_head(neighbor_table); n !=
NULL && i != num; n = n->next) {
++i;
}
printf("%d.%d: Forwarding packet to %d.%d (%d in list), hops %d\n",
n->addr.u8[0], n->addr.u8[1], num,
packetbuf_attr(PACKETBUF_ATTR_HOPS));
return &n->addr;
}
}
printf("%d.%d: did not find a neighbor to foward to\n",
}
static const struct multihop_callbacks multihop_call = {recv, forward};
static struct multihop_conn multihop;
{
multihop_open(&multihop, CHANNEL, &multihop_call);
CHANNEL,
received_announcement);
SENSORS_ACTIVATE(button_sensor);
while(1) {
rimeaddr_t to;
data == &button_sensor);
rimeaddr_t addr2;
addr2.u8[0] = 2;
addr2.u8[1] = 0;
to.u8[0] = 3;
to.u8[1] = 0;
multihop_send(&multihop, &to);
}
}