2016-10-21 10:53:08 +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
|
|
|
|
* To test 6P transaction on a RPL+TSCH network
|
|
|
|
*
|
|
|
|
* \author
|
|
|
|
* Simon Duquennoy <simonduq@sics.se>
|
2016-11-02 13:12:07 +00:00
|
|
|
* Shalu R <shalur@cdac.in>
|
2016-10-21 10:53:08 +00:00
|
|
|
* Lijo Thomas <lijo@cdac.in>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "contiki.h"
|
2018-05-16 18:25:14 +00:00
|
|
|
#include "sys/node-id.h"
|
2017-10-30 16:32:33 +00:00
|
|
|
#include "sys/log.h"
|
2016-10-21 10:53:08 +00:00
|
|
|
#include "net/ipv6/uip-ds6-route.h"
|
|
|
|
#include "net/mac/tsch/tsch.h"
|
2016-11-02 13:12:07 +00:00
|
|
|
#include "net/mac/tsch/sixtop/sixtop.h"
|
2017-12-09 08:53:48 +00:00
|
|
|
#include "net/routing/routing.h"
|
2016-11-02 13:12:07 +00:00
|
|
|
|
|
|
|
#include "sf-simple.h"
|
2016-10-21 10:53:08 +00:00
|
|
|
|
2017-10-30 16:32:33 +00:00
|
|
|
#define DEBUG DEBUG_PRINT
|
|
|
|
#include "net/ipv6/uip-debug.h"
|
|
|
|
|
2016-10-21 10:53:08 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS(node_process, "RPL Node");
|
|
|
|
AUTOSTART_PROCESSES(&node_process);
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(node_process, ev, data)
|
|
|
|
{
|
2017-11-05 02:30:44 +00:00
|
|
|
static int is_coordinator;
|
2017-10-30 16:32:33 +00:00
|
|
|
static int added_num_of_links = 0;
|
2016-10-21 10:53:08 +00:00
|
|
|
static struct etimer et;
|
2016-11-02 13:12:07 +00:00
|
|
|
struct tsch_neighbor *n;
|
|
|
|
|
2016-10-21 10:53:08 +00:00
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
2017-10-30 16:32:33 +00:00
|
|
|
is_coordinator = 0;
|
2016-10-21 10:53:08 +00:00
|
|
|
|
2017-10-30 16:32:33 +00:00
|
|
|
#if CONTIKI_TARGET_COOJA
|
|
|
|
is_coordinator = (node_id == 1);
|
2016-10-21 10:53:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if(is_coordinator) {
|
2017-12-09 13:23:35 +00:00
|
|
|
NETSTACK_ROUTING.root_start();
|
2016-10-21 10:53:08 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 16:32:33 +00:00
|
|
|
NETSTACK_MAC.on();
|
|
|
|
sixtop_add_sf(&sf_simple_driver);
|
|
|
|
|
2016-10-21 10:53:08 +00:00
|
|
|
etimer_set(&et, CLOCK_SECOND * 30);
|
|
|
|
while(1) {
|
|
|
|
PROCESS_YIELD_UNTIL(etimer_expired(&et));
|
|
|
|
etimer_reset(&et);
|
|
|
|
|
2016-11-02 13:12:07 +00:00
|
|
|
/* Get time-source neighbor */
|
|
|
|
n = tsch_queue_get_time_source();
|
|
|
|
|
2017-10-31 13:17:50 +00:00
|
|
|
if(!is_coordinator) {
|
2016-10-21 10:53:08 +00:00
|
|
|
if((added_num_of_links == 1) || (added_num_of_links == 3)) {
|
|
|
|
printf("App : Add a link\n");
|
2016-11-02 13:12:07 +00:00
|
|
|
sf_simple_add_links(&n->addr, 1);
|
2016-10-21 10:53:08 +00:00
|
|
|
} else if(added_num_of_links == 5) {
|
|
|
|
printf("App : Delete a link\n");
|
2016-11-02 13:12:07 +00:00
|
|
|
sf_simple_remove_links(&n->addr);
|
2016-10-21 10:53:08 +00:00
|
|
|
}
|
|
|
|
added_num_of_links++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|