2015-09-21 16:53:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015, SICS Swedish ICT.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* A RPL+TSCH node able to act as either a simple node (6ln),
|
|
|
|
* DAG Root (6dr) or DAG Root with security (6dr-sec)
|
|
|
|
* Press use button at startup to configure.
|
|
|
|
*
|
|
|
|
* \author Simon Duquennoy <simonduq@sics.se>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "contiki.h"
|
|
|
|
#include "node-id.h"
|
2017-06-10 12:35:39 +00:00
|
|
|
#include "rpl.h"
|
|
|
|
#include "rpl-dag-root.h"
|
2017-07-07 16:05:27 +00:00
|
|
|
#include "sys/log.h"
|
2015-09-21 16:53:35 +00:00
|
|
|
#include "net/ipv6/uip-ds6-route.h"
|
|
|
|
#include "net/mac/tsch/tsch.h"
|
2017-07-07 16:05:27 +00:00
|
|
|
#include "net/mac/tsch/tsch-log.h"
|
2017-06-10 12:35:39 +00:00
|
|
|
#if UIP_CONF_IPV6_RPL_LITE == 0
|
|
|
|
#include "rpl-private.h"
|
|
|
|
#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */
|
2015-09-21 16:53:35 +00:00
|
|
|
#if WITH_ORCHESTRA
|
|
|
|
#include "orchestra.h"
|
|
|
|
#endif /* WITH_ORCHESTRA */
|
2017-07-06 17:31:14 +00:00
|
|
|
#if WITH_SHELL
|
|
|
|
#include "serial-shell.h"
|
|
|
|
#endif /* WITH_SHELL */
|
2015-09-21 16:53:35 +00:00
|
|
|
|
|
|
|
#define DEBUG DEBUG_PRINT
|
2017-09-22 13:06:44 +00:00
|
|
|
#include "net/ipv6/uip-debug.h"
|
2015-09-21 16:53:35 +00:00
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS(node_process, "RPL Node");
|
|
|
|
AUTOSTART_PROCESSES(&node_process);
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(node_process, ev, data)
|
|
|
|
{
|
2017-07-07 13:23:32 +00:00
|
|
|
int is_coordinator;
|
2015-09-21 16:53:35 +00:00
|
|
|
|
2017-07-07 13:23:32 +00:00
|
|
|
PROCESS_BEGIN();
|
2016-06-09 14:47:00 +00:00
|
|
|
|
2017-07-07 13:23:32 +00:00
|
|
|
is_coordinator = 0;
|
2016-11-26 10:47:59 +00:00
|
|
|
|
2017-07-06 17:31:14 +00:00
|
|
|
#if WITH_SHELL
|
|
|
|
serial_shell_init();
|
2017-07-15 13:19:09 +00:00
|
|
|
log_set_level("all", LOG_LEVEL_WARN);
|
2017-07-07 16:05:27 +00:00
|
|
|
tsch_log_stop();
|
2017-07-06 17:31:14 +00:00
|
|
|
#endif /* WITH_SHELL */
|
|
|
|
|
2017-05-17 11:48:01 +00:00
|
|
|
#if CONTIKI_TARGET_COOJA
|
2017-07-07 13:23:32 +00:00
|
|
|
is_coordinator = (node_id == 1);
|
2016-11-26 10:47:59 +00:00
|
|
|
#endif
|
|
|
|
|
2015-09-21 16:53:35 +00:00
|
|
|
if(is_coordinator) {
|
2017-07-07 13:23:32 +00:00
|
|
|
rpl_dag_root_init_dag_immediately();
|
2015-09-21 16:53:35 +00:00
|
|
|
}
|
2017-07-07 13:23:32 +00:00
|
|
|
NETSTACK_MAC.on();
|
2016-06-09 14:47:00 +00:00
|
|
|
|
2015-09-21 16:53:35 +00:00
|
|
|
#if WITH_ORCHESTRA
|
|
|
|
orchestra_init();
|
|
|
|
#endif /* WITH_ORCHESTRA */
|
2016-06-09 14:47:00 +00:00
|
|
|
|
2017-07-07 16:05:27 +00:00
|
|
|
#if WITH_PERIODIC_ROUTES_PRINT
|
|
|
|
{
|
|
|
|
static struct etimer et;
|
|
|
|
/* Print out routing tables every minute */
|
|
|
|
etimer_set(&et, CLOCK_SECOND * 60);
|
|
|
|
while(1) {
|
|
|
|
/* Used for non-regression testing */
|
|
|
|
#if RPL_WITH_STORING
|
|
|
|
PRINTF("Routing entries: %u\n", uip_ds6_route_num_routes());
|
|
|
|
#endif
|
|
|
|
#if RPL_WITH_NON_STORING
|
|
|
|
PRINTF("Routing links: %u\n", rpl_ns_num_nodes());
|
|
|
|
#endif
|
|
|
|
PROCESS_YIELD_UNTIL(etimer_expired(&et));
|
|
|
|
etimer_reset(&et);
|
|
|
|
}
|
2015-09-21 16:53:35 +00:00
|
|
|
}
|
2017-07-07 16:05:27 +00:00
|
|
|
#endif /* WITH_PERIODIC_ROUTES_PRINT */
|
2016-06-09 14:47:00 +00:00
|
|
|
|
2015-09-21 16:53:35 +00:00
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|