Added network arrows in Cooja, fixed so that node ID 1 now is sink
This commit is contained in:
parent
acd9d516d8
commit
f4671d63e1
1 changed files with 15 additions and 15 deletions
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: example-collect.c,v 1.12 2010/03/25 08:52:23 adamdunkels Exp $
|
* $Id: example-collect.c,v 1.13 2010/11/06 10:44:06 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +44,9 @@
|
||||||
#include "net/rime/collect.h"
|
#include "net/rime/collect.h"
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
#include "dev/button-sensor.h"
|
#include "dev/button-sensor.h"
|
||||||
|
#include "powertrace.h"
|
||||||
|
|
||||||
|
#include "net/netstack.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -61,7 +64,6 @@ recv(const rimeaddr_t *originator, uint8_t seqno, uint8_t hops)
|
||||||
seqno, hops,
|
seqno, hops,
|
||||||
packetbuf_datalen(),
|
packetbuf_datalen(),
|
||||||
(char *)packetbuf_dataptr());
|
(char *)packetbuf_dataptr());
|
||||||
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static const struct collect_callbacks callbacks = { recv };
|
static const struct collect_callbacks callbacks = { recv };
|
||||||
|
@ -70,17 +72,16 @@ PROCESS_THREAD(example_collect_process, ev, data)
|
||||||
{
|
{
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
SENSORS_ACTIVATE(button_sensor);
|
|
||||||
|
|
||||||
collect_open(&tc, 130, COLLECT_ROUTER, &callbacks);
|
collect_open(&tc, 130, COLLECT_ROUTER, &callbacks);
|
||||||
|
|
||||||
if(rimeaddr_node_addr.u8[0] == 1 &&
|
if(rimeaddr_node_addr.u8[0] == 1 &&
|
||||||
rimeaddr_node_addr.u8[1] == 1) {
|
rimeaddr_node_addr.u8[1] == 0) {
|
||||||
printf("I am sink\n");
|
printf("I am sink\n");
|
||||||
collect_set_sink(&tc, 1);
|
collect_set_sink(&tc, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
static struct etimer et;
|
static struct etimer et;
|
||||||
|
|
||||||
|
@ -91,20 +92,19 @@ PROCESS_THREAD(example_collect_process, ev, data)
|
||||||
PROCESS_WAIT_EVENT();
|
PROCESS_WAIT_EVENT();
|
||||||
|
|
||||||
if(etimer_expired(&et)) {
|
if(etimer_expired(&et)) {
|
||||||
while(tc.sending) {
|
static rimeaddr_t oldparent;
|
||||||
PROCESS_PAUSE();
|
const rimeaddr_t *parent;
|
||||||
}
|
|
||||||
printf("Sending\n");
|
printf("Sending\n");
|
||||||
packetbuf_clear();
|
packetbuf_clear();
|
||||||
packetbuf_set_datalen(sprintf(packetbuf_dataptr(),
|
packetbuf_set_datalen(sprintf(packetbuf_dataptr(),
|
||||||
"%s", "Hello") + 1);
|
"%s", "Hello") + 1);
|
||||||
collect_send(&tc, 4);
|
collect_send(&tc, 10);
|
||||||
}
|
|
||||||
|
|
||||||
if(ev == sensors_event) {
|
parent = collect_parent(&tc);
|
||||||
if(data == &button_sensor) {
|
if(!rimeaddr_cmp(parent, &oldparent)) {
|
||||||
printf("I am sink\n");
|
printf("#L %d 0\n", oldparent.u8[0]);
|
||||||
collect_set_sink(&tc, 1);
|
printf("#L %d 1\n", parent->u8[0]);
|
||||||
|
rimeaddr_copy(&oldparent, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue