2008-02-04 23:42:17 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008, Swedish Institute of Computer Science.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This file is part of the Contiki operating system.
|
|
|
|
*
|
2009-03-12 21:58:20 +00:00
|
|
|
* $Id: shell-rime.c,v 1.13 2009/03/12 21:58:20 adamdunkels Exp $
|
2008-02-04 23:42:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* A brief description of what this file is.
|
|
|
|
* \author
|
|
|
|
* Adam Dunkels <adam@sics.se>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "contiki.h"
|
|
|
|
#include "contiki-conf.h"
|
|
|
|
#include "shell-rime.h"
|
|
|
|
|
|
|
|
#include "dev/leds.h"
|
|
|
|
|
2008-07-07 23:22:59 +00:00
|
|
|
#include "lib/crc16.h"
|
2009-02-11 11:08:53 +00:00
|
|
|
#include "lib/random.h"
|
2008-02-04 23:42:17 +00:00
|
|
|
|
|
|
|
#include "net/rime.h"
|
|
|
|
#include "net/rime/neighbor.h"
|
|
|
|
#include "net/rime/route.h"
|
2008-08-15 19:06:14 +00:00
|
|
|
#include "net/rime/netflood.h"
|
2008-02-04 23:42:17 +00:00
|
|
|
|
|
|
|
#include "net/rime/timesynch.h"
|
|
|
|
|
2008-11-17 22:52:10 +00:00
|
|
|
#if CONTIKI_TARGET_NETSIM
|
2008-02-04 23:42:17 +00:00
|
|
|
#include "ether.h"
|
2008-11-17 22:52:10 +00:00
|
|
|
#endif /* CONTIKI_TARGET_NETSIM */
|
2008-02-04 23:42:17 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#ifndef HAVE_SNPRINTF
|
|
|
|
int snprintf(char *str, size_t size, const char *format, ...);
|
|
|
|
#endif /* HAVE_SNPRINTF */
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define COLLECT_REXMITS 4
|
|
|
|
|
|
|
|
enum {
|
2008-08-15 19:06:14 +00:00
|
|
|
NETFLOOD_TYPE_NODES,
|
2008-02-04 23:42:17 +00:00
|
|
|
};
|
|
|
|
|
2008-08-15 19:06:14 +00:00
|
|
|
struct netflood_msg {
|
2008-02-04 23:42:17 +00:00
|
|
|
uint8_t type;
|
|
|
|
};
|
|
|
|
|
2008-08-15 19:06:14 +00:00
|
|
|
static uint8_t nodes_seqno;
|
|
|
|
|
2008-07-07 23:22:59 +00:00
|
|
|
#define COLLECT_MSG_HDRSIZE 4
|
2008-02-04 23:42:17 +00:00
|
|
|
struct collect_msg {
|
|
|
|
uint16_t timestamp;
|
2008-07-07 23:22:59 +00:00
|
|
|
uint16_t crc;
|
2008-02-04 23:42:17 +00:00
|
|
|
uint8_t data[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct collect_conn collect;
|
2008-08-15 19:06:14 +00:00
|
|
|
static struct netflood_conn netflood;
|
2008-02-04 23:42:17 +00:00
|
|
|
static struct ctimer ctimer;
|
|
|
|
static int waiting_for_nodes = 0;
|
|
|
|
static int waiting_for_collect = 0;
|
|
|
|
static int messages_received = 0;
|
|
|
|
|
|
|
|
|
|
|
|
static int is_sink = 0;
|
|
|
|
|
|
|
|
/* XXX ideas not implemented yet:
|
|
|
|
|
|
|
|
* download: download file from specific node.
|
|
|
|
|
|
|
|
* traceroute
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2008-02-24 20:58:35 +00:00
|
|
|
PROCESS(shell_mac_process, "mac");
|
|
|
|
SHELL_COMMAND(mac_command,
|
|
|
|
"mac",
|
|
|
|
"mac <onoroff>: turn MAC protocol on (1) or off (0)",
|
|
|
|
&shell_mac_process);
|
2008-02-04 23:42:17 +00:00
|
|
|
PROCESS(shell_nodes_process, "nodes");
|
|
|
|
SHELL_COMMAND(nodes_command,
|
|
|
|
"nodes",
|
|
|
|
"nodes: get a list of nodes in the network",
|
|
|
|
&shell_nodes_process);
|
|
|
|
PROCESS(shell_send_process, "send");
|
|
|
|
SHELL_COMMAND(send_command,
|
|
|
|
"send",
|
|
|
|
"send: send data to the collector node",
|
|
|
|
&shell_send_process);
|
|
|
|
PROCESS(shell_collect_process, "collect");
|
|
|
|
SHELL_COMMAND(collect_command,
|
|
|
|
"collect",
|
|
|
|
"collect: collect data from the network",
|
|
|
|
&shell_collect_process);
|
|
|
|
#if WITH_TREEDEPTH
|
|
|
|
PROCESS(shell_treedepth_process, "treedepth");
|
|
|
|
SHELL_COMMAND(treedepth_command,
|
|
|
|
"treedepth",
|
|
|
|
"treedepth: print the collection tree depth",
|
|
|
|
&shell_treedepth_process);
|
|
|
|
#endif /* WITH_TREEDEPTH */
|
|
|
|
PROCESS(shell_neighbors_process, "neighbors");
|
|
|
|
SHELL_COMMAND(neighbors_command,
|
|
|
|
"neighbors",
|
|
|
|
"neighbors: dump neighbor list in binary format",
|
|
|
|
&shell_neighbors_process);
|
|
|
|
PROCESS(shell_routes_process, "routes");
|
|
|
|
SHELL_COMMAND(routes_command,
|
|
|
|
"routes",
|
|
|
|
"routes: dump route list in binary format",
|
|
|
|
&shell_routes_process);
|
|
|
|
PROCESS(shell_packetize_process, "packetize");
|
|
|
|
SHELL_COMMAND(packetize_command,
|
|
|
|
"packetize",
|
|
|
|
"packetize: put data into one packet",
|
|
|
|
&shell_packetize_process);
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2008-02-24 20:58:35 +00:00
|
|
|
PROCESS_THREAD(shell_mac_process, ev, data)
|
|
|
|
{
|
|
|
|
int onoroff;
|
|
|
|
const char *next;
|
|
|
|
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
onoroff = shell_strtolong((char *)data, &next);
|
|
|
|
if(next == data) {
|
2008-07-02 14:08:06 +00:00
|
|
|
shell_output_str(&mac_command, "mac: current MAC layer: ", rime_mac->name);
|
|
|
|
shell_output_str(&mac_command, "mac usage: ", mac_command.description);
|
2008-02-24 20:58:35 +00:00
|
|
|
} else {
|
|
|
|
if(onoroff) {
|
|
|
|
rime_mac->on();
|
2008-07-02 14:08:06 +00:00
|
|
|
shell_output_str(&mac_command, "mac: turned MAC on: ", rime_mac->name);
|
2008-02-24 20:58:35 +00:00
|
|
|
} else {
|
|
|
|
rime_mac->off(1);
|
2008-07-02 14:08:06 +00:00
|
|
|
shell_output_str(&mac_command, "mac: turned MAC off (keeping radio on): ",
|
|
|
|
rime_mac->name);
|
2008-02-24 20:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2008-02-04 23:42:17 +00:00
|
|
|
PROCESS_THREAD(shell_packetize_process, ev, data)
|
|
|
|
{
|
|
|
|
static struct queuebuf *q = NULL;
|
|
|
|
static char *ptr;
|
|
|
|
static int size;
|
|
|
|
int len;
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
struct shell_input *input;
|
|
|
|
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
|
|
|
|
|
|
|
|
if(q == NULL) {
|
2009-03-12 21:58:20 +00:00
|
|
|
packetbuf_clear();
|
|
|
|
q = queuebuf_new_from_packetbuf();
|
2008-02-04 23:42:17 +00:00
|
|
|
if(q == NULL) {
|
|
|
|
shell_output_str(&packetize_command, "packetize: could not allocate packet buffer", "");
|
|
|
|
PROCESS_EXIT();
|
|
|
|
}
|
|
|
|
ptr = queuebuf_dataptr(q);
|
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
input = data;
|
|
|
|
|
|
|
|
len = input->len1 + input->len2;
|
|
|
|
|
2009-03-12 21:58:20 +00:00
|
|
|
if(len + size >= PACKETBUF_SIZE ||
|
2008-02-04 23:42:17 +00:00
|
|
|
len == 0) {
|
|
|
|
shell_output(&packetize_command,
|
|
|
|
ptr, size,
|
|
|
|
"", 0);
|
|
|
|
queuebuf_free(q);
|
|
|
|
q = NULL;
|
|
|
|
PROCESS_EXIT();
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(ptr + size, input->data1, input->len1);
|
|
|
|
size += input->len1;
|
|
|
|
memcpy(ptr + size, input->data2, input->len2);
|
|
|
|
size += input->len2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(shell_routes_process, ev, data)
|
|
|
|
{
|
|
|
|
struct {
|
|
|
|
uint16_t len;
|
|
|
|
uint16_t dest;
|
|
|
|
uint16_t nexthop;
|
|
|
|
uint16_t hop_count;
|
|
|
|
uint16_t seqno;
|
|
|
|
} msg;
|
|
|
|
int i;
|
|
|
|
struct route_entry *r;
|
|
|
|
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
|
|
msg.len = 4;
|
|
|
|
for(i = 0; i < route_num(); ++i) {
|
|
|
|
r = route_get(i);
|
|
|
|
rimeaddr_copy((rimeaddr_t *)&msg.dest, &r->dest);
|
|
|
|
rimeaddr_copy((rimeaddr_t *)&msg.nexthop, &r->nexthop);
|
|
|
|
msg.hop_count = r->hop_count;
|
|
|
|
msg.seqno = r->seqno;
|
|
|
|
shell_output(&routes_command, &msg, sizeof(msg), "", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(shell_neighbors_process, ev, data)
|
|
|
|
{
|
|
|
|
struct {
|
|
|
|
uint16_t len;
|
|
|
|
uint16_t addr;
|
|
|
|
uint16_t rtmetric;
|
|
|
|
uint16_t etx;
|
|
|
|
} msg;
|
|
|
|
int i;
|
|
|
|
struct neighbor *n;
|
|
|
|
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
|
|
|
for(i = 0; i < neighbor_num(); ++i) {
|
|
|
|
|
|
|
|
n = neighbor_get(i);
|
|
|
|
|
|
|
|
if(!rimeaddr_cmp(&n->addr, &rimeaddr_null)) {
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
|
|
msg.len = 3;
|
|
|
|
rimeaddr_copy((rimeaddr_t *)&msg.addr, &n->addr);
|
|
|
|
msg.rtmetric = n->rtmetric;
|
|
|
|
msg.etx = neighbor_etx(n);
|
|
|
|
shell_output(&neighbors_command, &msg, sizeof(msg), "", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(shell_nodes_process, ev, data)
|
|
|
|
{
|
|
|
|
static struct etimer etimer;
|
2008-08-15 19:06:14 +00:00
|
|
|
struct netflood_msg *msg;
|
2008-02-04 23:42:17 +00:00
|
|
|
char buf[10];
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
|
|
|
if(!is_sink) {
|
|
|
|
|
|
|
|
shell_output_str(&nodes_command,
|
|
|
|
"Setting up a collection network...", "");
|
|
|
|
#if TIMESYNCH_CONF_ENABLED
|
|
|
|
timesynch_set_authority_level(0);
|
|
|
|
#endif
|
|
|
|
collect_set_sink(&collect, 1);
|
|
|
|
|
|
|
|
etimer_set(&etimer, CLOCK_SECOND * 2);
|
|
|
|
PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
|
|
|
|
is_sink = 1;
|
|
|
|
}
|
|
|
|
|
2009-03-12 21:58:20 +00:00
|
|
|
packetbuf_clear();
|
|
|
|
msg = packetbuf_dataptr();
|
|
|
|
packetbuf_set_datalen(sizeof(struct netflood_msg));
|
2008-08-15 19:06:14 +00:00
|
|
|
msg->type = NETFLOOD_TYPE_NODES;
|
|
|
|
netflood_send(&netflood, nodes_seqno++);
|
2008-02-04 23:42:17 +00:00
|
|
|
|
|
|
|
etimer_set(&etimer, CLOCK_SECOND * 10);
|
|
|
|
waiting_for_nodes = 1;
|
|
|
|
shell_output_str(&nodes_command,
|
|
|
|
"Request sent, waiting for replies...", "");
|
|
|
|
messages_received = 0;
|
|
|
|
|
|
|
|
PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
|
|
|
|
snprintf(buf, sizeof(buf), "%d", messages_received);
|
|
|
|
shell_output_str(&nodes_command, buf, " nodes heard");
|
|
|
|
|
|
|
|
waiting_for_nodes = 0;
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
#if WITH_TREEDEPTH
|
|
|
|
PROCESS_THREAD(shell_treedepth_process, ev, data)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", collect_depth(&collect));
|
|
|
|
|
|
|
|
shell_output_str(&treedepth_command, buf, "");
|
|
|
|
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
#endif /* WITH_TREEDEPTH */
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(shell_collect_process, ev, data)
|
|
|
|
{
|
|
|
|
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
|
|
|
#if TIMESYNCH_CONF_ENABLED
|
|
|
|
timesynch_set_authority_level(0);
|
|
|
|
#endif
|
|
|
|
collect_set_sink(&collect, 1);
|
|
|
|
|
|
|
|
is_sink = 1;
|
|
|
|
waiting_for_collect = 1;
|
|
|
|
|
|
|
|
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
|
|
|
|
|
|
|
|
waiting_for_collect = 0;
|
|
|
|
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(shell_send_process, ev, data)
|
|
|
|
{
|
|
|
|
struct shell_input *input;
|
|
|
|
int len;
|
|
|
|
struct collect_msg *msg;
|
|
|
|
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
|
|
|
|
input = data;
|
|
|
|
|
|
|
|
len = input->len1 + input->len2;
|
|
|
|
|
|
|
|
if(len == 0) {
|
|
|
|
PROCESS_EXIT();
|
|
|
|
}
|
|
|
|
|
2009-03-12 21:58:20 +00:00
|
|
|
if(len < PACKETBUF_SIZE) {
|
|
|
|
packetbuf_clear();
|
|
|
|
packetbuf_set_datalen(len + COLLECT_MSG_HDRSIZE);
|
|
|
|
msg = packetbuf_dataptr();
|
2008-02-04 23:42:17 +00:00
|
|
|
memcpy(msg->data, input->data1, input->len1);
|
|
|
|
memcpy(msg->data + input->len1, input->data2, input->len2);
|
|
|
|
#if TIMESYNCH_CONF_ENABLED
|
|
|
|
msg->timestamp = timesynch_time();
|
|
|
|
#else
|
|
|
|
msg->timestamp = 0;
|
|
|
|
#endif
|
2008-07-07 23:22:59 +00:00
|
|
|
msg->crc = crc16_data(msg->data, len, 0);
|
2008-02-04 23:42:17 +00:00
|
|
|
/* printf("Sending %d bytes\n", len);*/
|
|
|
|
collect_send(&collect, COLLECT_REXMITS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
2008-07-03 09:52:15 +00:00
|
|
|
recv_collect(const rimeaddr_t *originator, u8_t seqno, u8_t hops)
|
2008-02-04 23:42:17 +00:00
|
|
|
{
|
|
|
|
struct collect_msg *collect_msg;
|
|
|
|
rtimer_clock_t latency;
|
2008-07-07 23:22:59 +00:00
|
|
|
int len;
|
2008-02-04 23:42:17 +00:00
|
|
|
|
2009-03-12 21:58:20 +00:00
|
|
|
collect_msg = packetbuf_dataptr();
|
2008-02-04 23:42:17 +00:00
|
|
|
|
|
|
|
#if TIMESYNCH_CONF_ENABLED
|
|
|
|
latency = timesynch_time() - collect_msg->timestamp;
|
|
|
|
#else
|
|
|
|
latency = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(waiting_for_collect) {
|
|
|
|
struct {
|
|
|
|
uint16_t len;
|
|
|
|
uint16_t originator;
|
|
|
|
uint16_t seqno;
|
|
|
|
uint16_t hops;
|
|
|
|
uint16_t latency;
|
|
|
|
} msg;
|
|
|
|
|
2009-03-12 21:58:20 +00:00
|
|
|
if(packetbuf_datalen() >= COLLECT_MSG_HDRSIZE) {
|
|
|
|
len = packetbuf_datalen() - COLLECT_MSG_HDRSIZE;
|
2008-07-07 23:22:59 +00:00
|
|
|
|
|
|
|
if(collect_msg->crc == crc16_data(collect_msg->data, len, 0)) {
|
2009-03-12 21:58:20 +00:00
|
|
|
msg.len = 5 + (packetbuf_datalen() - COLLECT_MSG_HDRSIZE) / 2;
|
2008-07-07 23:22:59 +00:00
|
|
|
rimeaddr_copy((rimeaddr_t *)&msg.originator, originator);
|
|
|
|
msg.seqno = seqno;
|
|
|
|
msg.hops = hops;
|
|
|
|
msg.latency = latency;
|
2009-03-12 21:58:20 +00:00
|
|
|
/* printf("recv_collect datalen %d\n", packetbuf_datalen());*/
|
2008-07-07 23:22:59 +00:00
|
|
|
|
|
|
|
shell_output(&collect_command,
|
|
|
|
&msg, sizeof(msg),
|
2009-03-12 21:58:20 +00:00
|
|
|
collect_msg->data, packetbuf_datalen() - COLLECT_MSG_HDRSIZE);
|
2008-07-07 23:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-04 23:42:17 +00:00
|
|
|
} else if(waiting_for_nodes) {
|
|
|
|
char buf[40];
|
|
|
|
snprintf(buf, sizeof(buf), "%d.%d, %d hops, latency %lu ms",
|
|
|
|
originator->u8[0], originator->u8[1],
|
|
|
|
hops, (1000L * latency) / RTIMER_ARCH_SECOND);
|
|
|
|
shell_output_str(&nodes_command, "Message from node ", buf);
|
|
|
|
messages_received++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
static const struct collect_callbacks collect_callbacks = { recv_collect };
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
send_collect(void *dummy)
|
|
|
|
{
|
|
|
|
struct collect_msg msg;
|
|
|
|
#if TIMESYNCH_CONF_ENABLED
|
|
|
|
msg.timestamp = timesynch_time();
|
|
|
|
#else
|
|
|
|
msg.timestamp = 0;
|
|
|
|
#endif
|
2009-03-12 21:58:20 +00:00
|
|
|
packetbuf_copyfrom(&msg, COLLECT_MSG_HDRSIZE);
|
2008-02-04 23:42:17 +00:00
|
|
|
collect_send(&collect, COLLECT_REXMITS);
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2008-08-16 10:04:55 +00:00
|
|
|
static int
|
|
|
|
recv_netflood(struct netflood_conn *c, rimeaddr_t *from,
|
|
|
|
rimeaddr_t *originator, uint8_t seqno, uint8_t hops)
|
2008-02-04 23:42:17 +00:00
|
|
|
{
|
2008-08-15 19:06:14 +00:00
|
|
|
struct netflood_msg *msg;
|
2008-02-04 23:42:17 +00:00
|
|
|
|
2009-03-12 21:58:20 +00:00
|
|
|
msg = packetbuf_dataptr();
|
2008-08-15 19:06:14 +00:00
|
|
|
if(msg->type == NETFLOOD_TYPE_NODES) {
|
2009-02-11 11:08:53 +00:00
|
|
|
ctimer_set(&ctimer, random_rand() % (CLOCK_SECOND * 8),
|
2008-02-04 23:42:17 +00:00
|
|
|
send_collect, NULL);
|
|
|
|
}
|
2008-08-16 10:04:55 +00:00
|
|
|
return 1;
|
2008-02-04 23:42:17 +00:00
|
|
|
}
|
2008-08-15 19:06:14 +00:00
|
|
|
const static struct netflood_callbacks netflood_callbacks = { recv_netflood,
|
|
|
|
NULL, NULL };
|
2008-02-04 23:42:17 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
shell_rime_init(void)
|
|
|
|
{
|
2008-08-15 19:06:14 +00:00
|
|
|
netflood_open(&netflood, CLOCK_SECOND * 8,
|
|
|
|
SHELL_RIME_CHANNEL_NODES, &netflood_callbacks);
|
|
|
|
collect_open(&collect, SHELL_RIME_CHANNEL_COLLECT, &collect_callbacks);
|
2008-02-04 23:42:17 +00:00
|
|
|
|
|
|
|
shell_register_command(&collect_command);
|
2008-02-24 20:58:35 +00:00
|
|
|
shell_register_command(&mac_command);
|
2008-02-04 23:42:17 +00:00
|
|
|
shell_register_command(&neighbors_command);
|
|
|
|
shell_register_command(&nodes_command);
|
|
|
|
shell_register_command(&packetize_command);
|
|
|
|
shell_register_command(&routes_command);
|
|
|
|
shell_register_command(&send_command);
|
|
|
|
|
|
|
|
#if WITH_TREEDEPTH
|
|
|
|
shell_register_command(&treedepth_command);
|
|
|
|
#endif /* WITH_TREEDEPTH */
|
|
|
|
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|