Added NXP JN516x examples

This commit is contained in:
Simon Duquennoy 2015-09-21 11:00:32 +02:00
parent 11f9b780c8
commit 0780e1a051
34 changed files with 2313 additions and 0 deletions

View File

@ -0,0 +1,5 @@
Examples for the JN516x platform.
* dr1175: simple Contiki application for the DR1175 evaluation board. Prints out sensor values periodically.
* rime: simple Rime example. Works with ContikiMAC (default) or NullRDC
* RPL: RPL examples, including border router, simple node, and coap resources. More information under rpl/README.md

View File

@ -0,0 +1,12 @@
CONTIKI=../../..
CONTIKI_PROJECT = node
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
TARGET ?= jn516x
JN516x_WITH_DR1175 = 1
CONTIKI_WITH_RIME = 1
all: $(CONTIKI_PROJECT)
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,2 @@
Sensor test for DR1175 evaluation board (light + temp/humidity).
Reads and prints out various sensor samples every second.

View File

@ -0,0 +1,88 @@
/*
* 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.
*
*/
/**
* \author Atis Elsts <atis.elsts@sics.se>
* \file
* Sensor test for DR1175 evaluation board (light + temp/humidity).
*/
#include "contiki.h"
#include "light-sensor.h"
#include "ht-sensor.h"
#include "leds.h"
/*---------------------------------------------------------------------------*/
PROCESS(test_process, "Sensor test process");
AUTOSTART_PROCESSES(&test_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_process, ev, data)
{
static struct etimer et;
static uint8_t led_status;
uint8_t r, g, b;
int val;
PROCESS_BEGIN();
puts("initializing sensors...");
/* Make sensor active for measuring */
SENSORS_ACTIVATE(light_sensor);
SENSORS_ACTIVATE(ht_sensor);
/* Set level for LEDSs */
leds_set_level(255, LEDS_RED | LEDS_GREEN | LEDS_BLUE | LEDS_WHITE);
while(1) {
etimer_set(&et, CLOCK_SECOND * 1);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
puts("reading sensors...");
val = ht_sensor.value(HT_SENSOR_HUM);
printf("humidity: %d\n", val);
val = ht_sensor.value(HT_SENSOR_TEMP);
printf("temperature: %d\n", val);
led_status++;
r = ((led_status & 0x1) ? LEDS_RED : 0);
g = ((led_status & 0x2) ? LEDS_GREEN : 0);
b = ((led_status & 0x4) ? LEDS_BLUE : 0);
leds_toggle((leds_get() ^ (r | g | b)) | LEDS_WHITE);
puts("");
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,47 @@
/*
* 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.
*
*/
/**
* \author Atis Elsts <atis.elsts@sics.se>
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#undef NETSTACK_CONF_RDC
#undef NETSTACK_CONF_FRAMER
#undef NETSTACK_CONF_MAC
#undef NETSTACK_CONF_NETWORK
#define NETSTACK_CONF_RDC nullrdc_driver
#define NETSTACK_CONF_FRAMER framer_802154
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_NETWORK rime_driver
#endif /* __PROJECT_CONF_H__ */

View File

@ -0,0 +1,11 @@
CONTIKI=../../..
CONTIKI_PROJECT = node
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
TARGET ?= jn516x
CONTIKI_WITH_RIME = 1
all: $(CONTIKI_PROJECT)
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1 @@
A simple Rime + ContikiMAC code example.

124
examples/jn516x/rime/node.c Normal file
View File

@ -0,0 +1,124 @@
/*
* 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.
*
*/
/**
* \author Atis Elsts <atis.elsts@sics.se>
* \file
* ContikiMAC + Rime stack test for JN516x platform.
*/
#include "contiki-conf.h"
#include "net/rime/rime.h"
#if 0
#define RX_ADDR1 140
#define RX_ADDR2 228
#else
#define RX_ADDR1 7
#define RX_ADDR2 0
#endif
#define MAX_RETRANSMISSIONS 4
/*---------------------------------------------------------------------------*/
PROCESS(unicast_test_process, "ContikiMAC Node");
AUTOSTART_PROCESSES(&unicast_test_process);
static void
recv_runicast(struct runicast_conn *c, const linkaddr_t *from, uint8_t seqno)
{
printf("runicast message received from %d.%d, seqno %d, len %d: '%s'\n",
from->u8[0], from->u8[1], seqno, packetbuf_datalen(), (char *)packetbuf_dataptr());
}
static void
sent_runicast(struct runicast_conn *c, const linkaddr_t *to, uint8_t retransmissions)
{
printf("runicast message sent to %d.%d, retransmissions %d\n",
to->u8[0], to->u8[1], retransmissions);
}
static void
timedout_runicast(struct runicast_conn *c, const linkaddr_t *to, uint8_t retransmissions)
{
printf("runicast message timed out when sending to %d.%d, retransmissions %d\n",
to->u8[0], to->u8[1], retransmissions);
}
static const struct runicast_callbacks runicast_callbacks = { recv_runicast,
sent_runicast,
timedout_runicast };
static struct runicast_conn runicast;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(unicast_test_process, ev, data)
{
PROCESS_BEGIN();
puts("unicast test start");
runicast_open(&runicast, 144, &runicast_callbacks);
/* Receiver node: do nothing */
if(linkaddr_node_addr.u8[0] == RX_ADDR1 &&
linkaddr_node_addr.u8[1] == RX_ADDR2) {
puts("wait forever");
}
while(1) {
static struct etimer et;
static int seqno;
etimer_set(&et, CLOCK_SECOND * 5);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
if(linkaddr_node_addr.u8[0] == RX_ADDR1 &&
linkaddr_node_addr.u8[1] == RX_ADDR2) {
puts("tick...");
continue;
}
if(!runicast_is_transmitting(&runicast)) {
linkaddr_t recv = { 0 };
static char buffer[100] = "hello";
packetbuf_copyfrom(buffer, sizeof(buffer));
recv.u8[0] = RX_ADDR1;
recv.u8[1] = RX_ADDR2;
printf("%u.%u: sending runicast to address %u.%u\n",
linkaddr_node_addr.u8[0],
linkaddr_node_addr.u8[1],
recv.u8[0],
recv.u8[1]);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, ++seqno);
runicast_send(&runicast, &recv, MAX_RETRANSMISSIONS);
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,68 @@
/*
* 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.
*
*/
/**
* \author Atis Elsts <atis.elsts@sics.se>
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#undef NETSTACK_CONF_RDC
#undef NETSTACK_CONF_FRAMER
#undef NETSTACK_CONF_MAC
#undef NETSTACK_CONF_NETWORK
#if 1
#define NETSTACK_CONF_RDC contikimac_driver
#define NETSTACK_CONF_FRAMER contikimac_framer
#else
#define NETSTACK_CONF_RDC nullrdc_driver
#define NETSTACK_CONF_FRAMER framer_802154
#endif
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_NETWORK rime_driver
#undef UIP_CONF_IPV6
#define UIP_CONF_IPV6 0
#undef RF_CHANNEL
#define RF_CHANNEL 25
#undef MICROMAC_CONF_CHANNEL
#define MICROMAC_CONF_CHANNEL RF_CHANNEL
#undef CC2420_CONF_CHANNEL
#define CC2420_CONF_CHANNEL RF_CHANNEL
#undef MICROMAC_CONF_AUTOACK
#define MICROMAC_CONF_AUTOACK 1
#endif /* __PROJECT_CONF_H__ */

View File

@ -0,0 +1,43 @@
# HOWTO - Setting up the RPL Border router and other nodes
In this folder we have a fully functional demonstrator with the components:
1. **RPL border router**: to start the wireless network and connect it to other networks.
2. and a **wireless node** that acts as a basic RPL node by default (but can optionally be used configured as DAG Root)
## RICH RPL Border Router
Setup the UART flow-control mode for the router from border-router/project-conf.h
* Enable either **HW flow control**
```C
#define UART_HW_FLOW_CTRL 1
#define UART_XONXOFF_FLOW_CTRL 0
```
* or **SW flow control**
```C
#define UART_HW_FLOW_CTRL 0
#define UART_XONXOFF_FLOW_CTRL 1
```
* You can disable both, but it is not recommended.
Compile and flash a node with the rpl-border-router.jn516x.bin image. Either a USB dongle or a dev-board would work.
From a Linux terminal, go to `contiki/examples/jn516x/rpl/border-router` and do either
`make connect-router-hw` if you have **HW flow control**
or `make connect-router-sw` if you have **SW flow control**
This will start a tunnel interface (tun0) on the host machine.
All traffic towards our network (prefix aaaa::1/64) will now be routed to the border router.
## RPL Node
The directory contiki-private/examples/jn516x/rpl/node contains a basic RICH node running TSCH and RPL.
You can compile and program more NXP nodes to run this, forming a larger network.
You should be able to ping the nodes (you can obtain their IPv6 address either directly from their log output
or by enabling DEBUG output in rpl-icmp6.c and looking at DAO prefixes being added.
## RPL+CoAP Nodes
coap-*-node are example nodes that expose their sensors as CoAP resources. See README.md files from the sub-directories
for more details.

View File

@ -0,0 +1,31 @@
CONTIKI_PROJECT = border-router
all: $(CONTIKI_PROJECT)
TARGET ?= jn516x
CONTIKI=../../../..
CONTIKI_WITH_IPV6 = 1
PROJECTDIRS += .. ../tools
PROJECT_SOURCEFILES += rpl-tools.c
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
PROJECT_SOURCEFILES += slip-bridge.c slip.c
ifeq ($(PREFIX),)
PREFIX = aaaa::1/64
endif
include $(CONTIKI)/Makefile.include
#using XON/XOFF flow control
connect-router-sw: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -X -B 1000000 $(PREFIX)
#using hw flow control
connect-router-hw: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -H -B 1000000 $(PREFIX)
#using no flow control
connect-router-no: $(CONTIKI)/tools/tunslip6
sudo $(CONTIKI)/tools/tunslip6 -B 1000000 $(PREFIX)

View File

@ -0,0 +1,10 @@
A RPL border router.
To indicate the hardware target for the border router, add one of the following
options in the command line:
If rpl-border-router runs on dongle:
JN516x_WITH_DONGLE=1
If rpl-border-router runs on DR1174:
JN516x_WITH_DR1174=1
If building for a new platform, first execute : make clean
See ../README.md for more.

View File

@ -0,0 +1,97 @@
/*
* 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.
*
*/
#include "contiki.h"
#include "net/rpl/rpl.h"
#include "tools/rpl-tools.h"
#define DEBUG DEBUG_PRINT
#include "net/ip/uip-debug.h"
static uip_ipaddr_t prefix;
static uint8_t prefix_set;
PROCESS(border_router_process, "Border router process");
AUTOSTART_PROCESSES(&border_router_process);
/*---------------------------------------------------------------------------*/
void
request_prefix(void)
{
/* mess up uip_buf with a dirty request... */
uip_buf[0] = '?';
uip_buf[1] = 'P';
/* uip_buf[2] = '\n'; */
uip_len = 2;
slip_send();
uip_len = 0;
}
/*---------------------------------------------------------------------------*/
void
set_prefix_64(uip_ipaddr_t *prefix_64)
{
memcpy(&prefix, prefix_64, 16);
prefix_set = 1;
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
/* While waiting for the prefix to be sent through the SLIP connection, the future
* border router can join an existing DAG as a parent or child, or acquire a default
* router that will later take precedence over the SLIP fallback interface.
* Prevent that by turning the radio off until we are initialized as a DAG root.
*/
prefix_set = 0;
PROCESS_PAUSE();
PRINTF("RPL-Border router started\n");
/* Request prefix until it has been received */
while(!prefix_set) {
etimer_set(&et, CLOCK_SECOND);
request_prefix();
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
PRINTF("Waiting for prefix\n");
}
PRINTF("Obtained prefix: ");
uip_debug_ipaddr_print(&prefix);
PRINTF("\n");
rpl_tools_init(&prefix);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,48 @@
/*
* 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.
*
*/
/**
* \author Simon Duquennoy <simonduq@sics.se>
*/
#ifndef BR_PROJECT_CONF_H_
#define BR_PROJECT_CONF_H_
#ifndef UIP_FALLBACK_INTERFACE
#define UIP_FALLBACK_INTERFACE rpl_interface
#endif
/* Needed for slip-bridge */
#undef SLIP_BRIDGE_CONF_NO_PUTCHAR
#define SLIP_BRIDGE_CONF_NO_PUTCHAR 0
#include "../common-conf.h"
#endif /* PROJECT_CONF_H_ */

View File

@ -0,0 +1,161 @@
/*
* Copyright (c) 2010, 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
* Slip fallback interface
* \author
* Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se>
* Joel Hoglund <joel@sics.se>
* Nicolas Tsiftes <nvt@sics.se>
*/
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "dev/slip.h"
#if CONTIKI_TARGET_JN516X
#include "dev/uart0.h"
#else
#include "dev/uart1.h"
#endif
#include <string.h>
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
#ifndef BAUD2UBR
#define BAUD2UBR(X) (X)
#endif
void set_prefix_64(uip_ipaddr_t *);
static uip_ipaddr_t last_sender;
/*---------------------------------------------------------------------------*/
static void
slip_input_callback(void)
{
PRINTF("SIN: %u\n", uip_len);
if(uip_buf[0] == '!') {
PRINTF("Got configuration message of type %c\n", uip_buf[1]);
uip_len = 0;
if(uip_buf[1] == 'P') {
uip_ipaddr_t prefix;
/* Here we set a prefix !!! */
memset(&prefix, 0, 16);
memcpy(&prefix, &uip_buf[2], 8);
PRINTF("Setting prefix ");
PRINT6ADDR(&prefix);
PRINTF("\n");
set_prefix_64(&prefix);
}
} else if(uip_buf[0] == '?') {
PRINTF("Got request message of type %c\n", uip_buf[1]);
if(uip_buf[1] == 'M') {
char *hexchar = "0123456789abcdef";
int j;
/* this is just a test so far... just to see if it works */
uip_buf[0] = '!';
for(j = 0; j < 8; j++) {
uip_buf[2 + j * 2] = hexchar[uip_lladdr.addr[j] >> 4];
uip_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15];
}
uip_len = 18;
slip_send();
}
uip_len = 0;
}
/* Save the last sender received over SLIP to avoid bouncing the
packet back if no route is found */
uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr);
}
/*---------------------------------------------------------------------------*/
static void
init(void)
{
slip_arch_init(BAUD2UBR(115200));
process_start(&slip_process, NULL);
slip_set_input_callback(slip_input_callback);
}
/*---------------------------------------------------------------------------*/
static void
output(void)
{
if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) {
/* Do not bounce packets back over SLIP if the packet was received
over SLIP */
PRINTF("slip-bridge: Destination off-link but no route src=");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" dst=");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
} else {
PRINTF("SUT: %u\n", uip_len);
slip_send();
printf("\n");
}
}
/*---------------------------------------------------------------------------*/
#if !SLIP_BRIDGE_CONF_NO_PUTCHAR
#undef putchar
int
putchar(int c)
{
#define SLIP_END 0300
static char debug_frame = 0;
if(!debug_frame) { /* Start of debug output */
slip_arch_writeb(SLIP_END);
slip_arch_writeb('\r'); /* Type debug line == '\r' */
debug_frame = 1;
}
/* Need to also print '\n' because for example COOJA will not show
any output before line end */
slip_arch_writeb((char)c);
/*
* Line buffered output, a newline marks the end of debug output and
* implicitly flushes debug output.
*/
if(c == '\n') {
slip_arch_writeb(SLIP_END);
debug_frame = 0;
}
return c;
}
#endif
/*---------------------------------------------------------------------------*/
const struct uip_fallback_interface rpl_interface = {
init, output
};
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,21 @@
CONTIKI_PROJECT = dongle-node
all: $(CONTIKI_PROJECT)
TARGET ?= jn516x
JN516x_WITH_DONGLE = 1
CONTIKI=../../../..
CONTIKI_WITH_IPV6 = 1
PROJECTDIRS += .. ../tools
PROJECT_SOURCEFILES += rpl-tools.c
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
CFLAGS += -DWITH_COAP
CFLAGS += -DUIP_CONF_TCP=0
APPS = json
APPS += er-coap
APPS += rest-engine
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,16 @@
dongle-node is an example of a RICH node containing a JN516x microcontroller on a USB dongle.
The dongle is part of the NXP JN516x Evaluation Kit (see http://www.nxp.com/documents/leaflet/75017368.pdf)
The dongle-node connects to the network in the same way as described in `examples\jn5168/rpl/README.md`
The dongle contains 2 LEDs that are available as a CoAP resource. They can be accessed via a CoAP client at the IPv6 interface
of the border router (e.g. via Copper plug-in on Firefox).
The following list gives an overview of the resources:
URI Description
--- -----------
Dongle\LED-toggle When doing a PUT/POST method on this resource (no payload needed), the LEDs will run through
the following states with wrap-around:
- GREEN LED on
- RED LED on
- All LEDs off
- RED and GREEN LED alternatively on with 1 sec period time

View File

@ -0,0 +1,145 @@
/*
* Copyright (c) 2015 NXP B.V.
* 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 NXP B.V. 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 NXP B.V. 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 NXP B.V. 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.
*
* Author: Theo van Daele <theo.van.daele@nxp.com>
*
*/
#include "contiki.h"
#include "net/ip/uip.h"
#include "tools/rpl-tools.h"
#include "rest-engine.h"
#include "sys/ctimer.h"
#include <stdio.h>
#include "dev/leds.h"
static void ct_callback(void *ptr);
static void put_post_led_toggle_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static char content[REST_MAX_CHUNK_SIZE];
static int content_len = 0;
static struct ctimer ct;
#define CONTENT_PRINTF(...) { if(content_len < sizeof(content)) { content_len += snprintf(content + content_len, sizeof(content) - content_len, __VA_ARGS__); } }
/* On dongle, LEDs are connected anti-parallel to DIO pins. */
#define TOGGLE_TIME CLOCK_SECOND
/*---------------------------------------------------------------------------*/
PROCESS(start_app, "START_APP");
AUTOSTART_PROCESSES(&start_app);
/*---------------------------------------------------------------------------*/
/* Call back for led toggle timer to toggle leds */
static void
ct_callback(void *ptr)
{
static uint8 toggle_status = 0;
if(toggle_status) {
leds_set(LEDS_RED);
} else {
leds_set(LEDS_GREEN);
} ctimer_restart(&ct);
toggle_status ^= 0x01;
}
/*********** CoAP sensor/ resource ************************************************/
RESOURCE(resource_led_toggle,
"title=\"Led_toggle\"",
NULL,
put_post_led_toggle_handler,
put_post_led_toggle_handler,
NULL);
static void
put_post_led_toggle_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
static int led_state = 0;
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
/* Given the way the LEDs are connected to the DIO ports, the LEDs are controlled via direct DIO access. */
content_len = 0;
switch(led_state) {
case (0):
ctimer_stop(&ct);
leds_set(LEDS_GREEN); /* Only LEDS_GREEN on */
CONTENT_PRINTF("Message from resource: Green LED on");
led_state = 1;
break;
case (1):
leds_set(LEDS_RED); /* Only LEDS_RED on */
CONTENT_PRINTF("Message from resource: Red LED on");
led_state = 2;
break;
case (2):
leds_set(0); /* All LEDS off */
CONTENT_PRINTF("Message from resource: All LEDs off");
led_state = 3;
break;
case 3:
/* Both leds toggle */
CONTENT_PRINTF("Message from resource: LEDs toggle");
ctimer_restart(&ct);
led_state = 0;
default:
break;
}
/* Return message */
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(start_app, ev, data)
{
PROCESS_BEGIN();
static int is_coordinator = 0;
/* Switch off dongle leds */
/* Initialise ct timer, but don't let it run yet */
ctimer_set(&ct, TOGGLE_TIME, ct_callback, NULL);
ctimer_stop(&ct);
/* Start net stack */
if(is_coordinator) {
uip_ipaddr_t prefix;
uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
rpl_tools_init(&prefix);
} else {
rpl_tools_init(NULL);
} printf("Starting RPL node\n");
rest_init_engine();
rest_activate_resource(&resource_led_toggle, "Dongle/LED-toggle");
PROCESS_END();
}

View File

@ -0,0 +1,39 @@
/*
* 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.
*
*/
/**
* \author Simon Duquennoy <simonduq@sics.se>
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#include "../common-conf.h"
#endif /* __PROJECT_CONF_H__ */

View File

@ -0,0 +1,21 @@
CONTIKI_PROJECT = dr1175-node
all: $(CONTIKI_PROJECT)
TARGET ?= jn516x
JN516x_WITH_DR1175 = 1
CONTIKI=../../../..
CONTIKI_WITH_IPV6 = 1
PROJECTDIRS += .. ../tools
PROJECT_SOURCEFILES += rpl-tools.c
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
CFLAGS += -DWITH_COAP
CFLAGS += -DUIP_CONF_TCP=0
APPS = json
APPS += er-coap
APPS += rest-engine
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,24 @@
dr1175-node is an example of a RICH node containing a JN516x microcontroller on a DR1174 baseboard.
A DR1175 shield is mounted on the baseboard.
The boards are part of the NXP JN516x Evaluation Kit (see http://www.nxp.com/documents/leaflet/75017368.pdf)
The dr1175-node connects to the network in the same way as described in `examples\jn5168/rpl/README.md`
The resources on the DR1175 are available as CoAP resources. They can be accessed via a CoAP client at the IPv6 interface
of the border router (e.g. via Copper plug-in on Firefox).
The following list gives an overview of the resources:
URI Description
--- -----------
DR1175\AllSensors This is an observable resource that shows the status of the humidity, light and temperature sensor.
The resource is automatically updated when a change in the value of the sensor data occurs.
DR1175\ColorLED\RGBValue With this resource, the level and color of the RGB LED can be set.
The output is set as 3 numbers (R, G and B) from 0..255, separated with a space
DR1175\Humidity\Unit This resource will return the unit of the humidity sensor
DR1175\Humidity\Value This resource will return the value of the humidity sensor
DR1175\LightSensor\Unit This resource will return the unit of the light sensor
DR1175\LightSensor\Value This resource will return the value of the light sensor
DR1175\Temperature\Unit This resource will return the unit of the temperature sensor
DR1175\Temperature\Value This resource will return the value of the temperature sensor
DR1175\WhiteLED This resource will set the level of 3 white power LEDs. Level is from 0..255
DR1174\D3On1174 This resource control LED D3 on the base board
DR1174\D6On1174 This resource control LED D6 on the base board

View File

@ -0,0 +1,395 @@
/*
* Copyright (c) 2015 NXP B.V.
* 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 NXP B.V. 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 NXP B.V. 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 NXP B.V. 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.
*
* Author: Theo van Daele <theo.van.daele@nxp.com>
*
*/
#include "contiki.h"
#include "net/ip/uip.h"
#include "tools/rpl-tools.h"
#include "rest-engine.h"
#include "light-sensor.h"
#include "ht-sensor.h"
#include "dev/leds.h"
#include "sys/etimer.h"
#include <stdio.h>
static void event_sensors_dr1175_handler(void);
static void get_sensors_dr1175_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_light_sensor_value_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_light_sensor_unit_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_temperature_value_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_temperature_unit_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_humidity_value_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_humidity_unit_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_white_led_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_rgb_led_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d3_1174_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d6_1174_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static char content[REST_MAX_CHUNK_SIZE];
static int content_len = 0;
#define CONTENT_PRINTF(...) { if(content_len < sizeof(content)) { content_len += snprintf(content + content_len, sizeof(content) - content_len, __VA_ARGS__); } }
#define CLIP(value, level) if(value > level) { \
value = level; \
}
#define SET_LED(LED) if(atoi((const char *)request_content) != 0) { \
leds_on(LED); \
} else { \
leds_off(LED); \
}
/*---------------------------------------------------------------------------*/
PROCESS(start_app, "START_APP");
AUTOSTART_PROCESSES(&start_app, &sensors_process);
/*---------------------------------------------------------------------------*/
/*********** CoAP sensor/ resource *************************************************/
/*******************************************************************/
/* Observable resource and event handler to obtain all sensor data */
/*******************************************************************/
EVENT_RESOURCE(resource_sensors_dr1175, /* name */
"obs;title=\"All_DR1175_sensors\"", /* attributes */
get_sensors_dr1175_handler, /* GET handler */
NULL, /* POST handler */
NULL, /* PUT handler */
NULL, /* DELETE handler */
event_sensors_dr1175_handler); /* event handler */
static void
get_sensors_dr1175_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.APPLICATION_JSON) {
content_len = 0;
CONTENT_PRINTF("{\"DR1175\":[");
CONTENT_PRINTF("{\"Humidity\":\"%d\"},", ht_sensor.value(HT_SENSOR_HUM));
CONTENT_PRINTF("{\"Light\":\"%d\"},", light_sensor.value(0));
CONTENT_PRINTF("{\"Temp\":\"%d\"}", ht_sensor.value(HT_SENSOR_TEMP));
CONTENT_PRINTF("]}");
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
static void
event_sensors_dr1175_handler()
{
/* Registered observers are notified and will trigger the GET handler to create the response. */
REST.notify_subscribers(&resource_sensors_dr1175);
}
/*****************************************************/
/* Resource and handler to obtain light sensor value */
/*****************************************************/
RESOURCE(resource_light_sensor_value,
"title=\"light sensor value\"",
get_light_sensor_value_handler,
NULL,
NULL,
NULL);
static void
get_light_sensor_value_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
content_len = 0;
CONTENT_PRINTF("%d", light_sensor.value(0));
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/***************************************************/
/* Resource and handler to obtain light unit value */
/***************************************************/
RESOURCE(resource_light_sensor_unit,
"title=\"light sensor unit\"",
get_light_sensor_unit_handler,
NULL,
NULL,
NULL);
static void
get_light_sensor_unit_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
content_len = 0;
CONTENT_PRINTF("Lux");
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/***********************************************************/
/* Resource and handler to obtain temperature sensor value */
/***********************************************************/
RESOURCE(resource_temperature_value,
"title=\"temperature value\"",
get_temperature_value_handler,
NULL,
NULL,
NULL);
static void
get_temperature_value_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
content_len = 0;
CONTENT_PRINTF("%d", ht_sensor.value(HT_SENSOR_TEMP));
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/*********************************************************/
/* Resource and handler to obtain temperature unit value */
/*********************************************************/
RESOURCE(resource_temperature_unit,
"title=\"temperature unit\"",
get_temperature_unit_handler,
NULL,
NULL,
NULL);
static void
get_temperature_unit_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
content_len = 0;
CONTENT_PRINTF("degrees C");
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/********************************************************/
/* Resource and handler to obtain humidity sensor value */
/********************************************************/
RESOURCE(resource_humidity_value,
"title=\"humidity value\"",
get_humidity_value_handler,
NULL,
NULL,
NULL);
static void
get_humidity_value_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
content_len = 0;
CONTENT_PRINTF("%d", ht_sensor.value(HT_SENSOR_HUM));
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/******************************************************/
/* Resource and handler to obtain humidity unit value */
/******************************************************/
RESOURCE(resource_humidity_unit,
"title=\"humidity unit\"",
get_humidity_unit_handler,
NULL,
NULL,
NULL);
static void
get_humidity_unit_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
content_len = 0;
CONTENT_PRINTF("relative %%");
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/***************************************************/
/* Resource and handler to control White LED level */
/***************************************************/
RESOURCE(resource_white_led,
"title=\"WhiteLED <[0..255]>\"",
NULL,
put_post_white_led_handler,
put_post_white_led_handler,
NULL);
static void
put_post_white_led_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content = NULL;
int request_content_len;
int level;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
level = atoi((const char *)request_content);
CLIP(level, 255)
leds_set_level(level, LEDS_WHITE);
}
}
/*************************************************/
/* Resource and handler to control RGB LED level */
/*************************************************/
RESOURCE(resource_rgb_led,
"title=\"RGB LED <[0..255] [0..255] [0..255]>\"",
NULL,
put_post_rgb_led_handler,
put_post_rgb_led_handler,
NULL);
static void
put_post_rgb_led_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content = NULL;
int request_content_len;
char *pch;
int RGB[] = { 0, 0, 0 };
int index = 0;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
pch = strtok((char *)request_content, " ");
while((pch != NULL) && (index != sizeof(RGB) / sizeof(int))) {
/* Convert token to int */
RGB[index] = atoi(pch);
CLIP(RGB[index], 255)
index++;
/* Get next token */
pch = strtok(NULL, " ");
}
leds_set_level(RGB[0], LEDS_RED);
leds_set_level(RGB[1], LEDS_GREEN);
leds_set_level(RGB[2], LEDS_BLUE);
}
}
/************************************************/
/* Resource and handler to control D3 on DR1174 */
/************************************************/
RESOURCE(resource_led_d3_1174,
"title=\"LED D3 1174<[0,1]>\"",
NULL,
put_post_led_d3_1174_handler,
put_post_led_d3_1174_handler,
NULL);
static void
put_post_led_d3_1174_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
SET_LED(LEDS_GP0);
}
}
/************************************************/
/* Resource and handler to control D6 on DR1174 */
/************************************************/
RESOURCE(resource_led_d6_1174,
"title=\"LED D6 1174<[0,1]>\"",
NULL,
put_post_led_d6_1174_handler,
put_post_led_d6_1174_handler,
NULL);
static void
put_post_led_d6_1174_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
SET_LED(LEDS_GP1);
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(start_app, ev, data)
{
PROCESS_BEGIN();
static int is_coordinator = 0;
static struct etimer et;
/* Make sensor active for measuring */
SENSORS_ACTIVATE(light_sensor);
SENSORS_ACTIVATE(ht_sensor);
/* Start net stack */
if(is_coordinator) {
uip_ipaddr_t prefix;
uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
rpl_tools_init(&prefix);
} else {
rpl_tools_init(NULL);
} printf("Starting RPL node\n");
rest_init_engine();
rest_activate_resource(&resource_light_sensor_value, "DR1175/LightSensor/Value");
rest_activate_resource(&resource_light_sensor_unit, "DR1175/LightSensor/Unit");
rest_activate_resource(&resource_temperature_unit, "DR1175/Temperature/Unit");
rest_activate_resource(&resource_temperature_value, "DR1175/Temperature/Value");
rest_activate_resource(&resource_humidity_unit, "DR1175/Humidity/Unit");
rest_activate_resource(&resource_humidity_value, "DR1175/Humidity/Value");
rest_activate_resource(&resource_white_led, "DR1175/WhiteLED");
rest_activate_resource(&resource_rgb_led, "DR1175/ColorLED/RGBValue");
rest_activate_resource(&resource_led_d3_1174, "DR1175/LED/D3On1174");
rest_activate_resource(&resource_led_d6_1174, "DR1175/LED/D6On1174");
rest_activate_resource(&resource_sensors_dr1175, "DR1175/AllSensors");
/* Level of LEDS=0, so no light after start-up */
leds_on(LEDS_WHITE | LEDS_RED | LEDS_GREEN | LEDS_BLUE);
/* contiki-jn516x-main switches all leds off after process start-up.
Switch on required leds after rescheduling, otherwise level change needs to be
accompanied with leds_on() at least once in resource handler. */
etimer_set(&et, CLOCK_SECOND / 10);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
/* Level of LEDS=0, so no light after start-up. However, they are enabled
A level change will directly be visible. */
leds_on(LEDS_WHITE | LEDS_RED | LEDS_GREEN | LEDS_BLUE);
/* If sensor process generates an event, call event_handler of resource.
This will make this resource observable by the client */
while(1) {
PROCESS_WAIT_EVENT_UNTIL((ev == sensors_event) &&
((data == &light_sensor) || (data == &ht_sensor)));
event_sensors_dr1175_handler();
}
PROCESS_END();
}

View File

@ -0,0 +1,39 @@
/*
* 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.
*
*/
/**
* \author Simon Duquennoy <simonduq@sics.se>
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#include "../common-conf.h"
#endif /* __PROJECT_CONF_H__ */

View File

@ -0,0 +1,21 @@
CONTIKI_PROJECT = dr1199-node
all: $(CONTIKI_PROJECT)
TARGET ?= jn516x
JN516x_WITH_DR1199 = 1
CONTIKI=../../../..
CONTIKI_WITH_IPV6 = 1
PROJECTDIRS += .. ../tools
PROJECT_SOURCEFILES += rpl-tools.c
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
CFLAGS += -DWITH_COAP
CFLAGS += -DUIP_CONF_TCP=0
APPS = json
APPS += er-coap
APPS += rest-engine
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,33 @@
dr1199-node is an example of a RICH node containing a JN516x microcontroller on a DR1174 baseboard.
A DR1199 shield is mounted on the baseboard.
The boards are part of the NXP JN516x Evaluation Kit (see http://www.nxp.com/documents/leaflet/75017368.pdf)
The dr1199-node connects to the network in the same way as described in `examples\jn5168/rpl/README.md`
The resources on the DR1199 are available as CoAP resources. They can be accessed via a CoAP client at the IPv6 interface
of the border router (e.g. via Copper plug-in on Firefox).
The following list gives an overview of the resources:
URI Description
--- -----------
DR1199\AllSensors This is an observable resource that shows the status of all switches and the potentiometer on the board
The resource is automatically updated when a change of the status/value of the switches and potentiometer
takes place.
DR1199\LED\All When writing a '1', LEDs D1..D3 will switch ON
When writing a '0', LEDs D1..D3 will switch OFF
DR1199\LED\D1 When writing a '1', LED D1 will switch ON
When writing a '0', LED D1 will switch OFF
DR1199\LED\D2 When writing a '1', LED D2 will switch ON
When writing a '0', LED D2 will switch OFF
DR1199\LED\D3 When writing a '1', LED D3 will switch ON
When writing a '0', LED D3 will switch OFF
DR1199\D3On1174 This resource control LED D3 on the base board
DR1199\D6On1174 This resource control LED D6 on the base board
DR1199\Potentiometer The resource will show the value of the potentiometer
DR1199\Switch\DIO8 This resource shows the status of the DIO8 switch (on DR1174)
DR1199\Switch\SW1 This resource shows the status of the SW1 switch
DR1199\Switch\SW2 This resource shows the status of the SW2 switch
DR1199\Switch\SW3 This resource shows the status of the SW3 switch
DR1199\Switch\SW4 This resource shows the status of the SW4 switch

View File

@ -0,0 +1,389 @@
/*
* Copyright (c) 2015 NXP B.V.
* 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 NXP B.V. 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 NXP B.V. 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 NXP B.V. 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.
*
* Author: Theo van Daele <theo.van.daele@nxp.com>
*
*/
#include "contiki.h"
#include "net/ip/uip.h"
#include "tools/rpl-tools.h"
#include "rest-engine.h"
#include "dev/leds.h"
#include "button-sensor.h"
#include "pot-sensor.h"
#include <stdio.h>
static char content[REST_MAX_CHUNK_SIZE];
static int content_len = 0;
static void event_sensors_dr1199_handler();
static void get_sensors_dr1199_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_sw1_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_sw2_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_sw3_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_sw4_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_switch_dio8_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void get_pot_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d1_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d2_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d3_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d3_1174_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_d6_1174_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
static void put_post_led_all_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
#define CONTENT_PRINTF(...) { if(content_len < sizeof(content)) { content_len += snprintf(content + content_len, sizeof(content) - content_len, __VA_ARGS__); } }
#define PARSE_SWITCH(POSITION) if(button_sensor.value(0) & (1 << POSITION)) { \
CONTENT_PRINTF("PRESSED"); \
} else { \
CONTENT_PRINTF("RELEASED"); \
}
#define SET_LED(LED) if(atoi((const char *)request_content) != 0) { \
leds_on(LED); \
} else { \
leds_off(LED); \
}
/*---------------------------------------------------------------------------*/
PROCESS(start_app, "START_APP");
AUTOSTART_PROCESSES(&sensors_process, &start_app);
/*---------------------------------------------------------------------------*/
/*********** CoAP sensor/ resource *************************************************/
/*******************************************************************/
/* Observable resource and event handler to obtain all sensor data */
/*******************************************************************/
EVENT_RESOURCE(resource_sensors_dr1199, /* name */
"obs;title=\"All_DR1199_sensors\"", /* attributes */
get_sensors_dr1199_handler, /* GET handler */
NULL, /* POST handler */
NULL, /* PUT handler */
NULL, /* DELETE handler */
event_sensors_dr1199_handler); /* event handler */
static void
get_sensors_dr1199_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.APPLICATION_JSON) {
content_len = 0;
CONTENT_PRINTF("{\"DR1199\":[");
CONTENT_PRINTF("{\"Switch\":\"0x%X\"},", button_sensor.value(0));
CONTENT_PRINTF("{\"Pot\":\"%d\"}", pot_sensor.value(0));
CONTENT_PRINTF("]}");
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
static void
event_sensors_dr1199_handler()
{
/* Registered observers are notified and will trigger the GET handler to create the response. */
REST.notify_subscribers(&resource_sensors_dr1199);
}
/***********************************************/
/* Resource and handler to obtain switch value */
/***********************************************/
RESOURCE(resource_switch_sw1,
"title=\"SW1\"",
get_switch_sw1_handler,
NULL,
NULL,
NULL);
static void
get_switch_sw1_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
content_len = 0;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
PARSE_SWITCH(1)
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
RESOURCE(resource_switch_sw2,
"title=\"SW2\"",
get_switch_sw2_handler,
NULL,
NULL,
NULL);
static void
get_switch_sw2_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
content_len = 0;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
PARSE_SWITCH(2)
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
RESOURCE(resource_switch_sw3,
"title=\"SW3\"",
get_switch_sw3_handler,
NULL,
NULL,
NULL);
static void
get_switch_sw3_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
content_len = 0;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
PARSE_SWITCH(3)
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
RESOURCE(resource_switch_sw4,
"title=\"SW4\"",
get_switch_sw4_handler,
NULL,
NULL,
NULL);
static void
get_switch_sw4_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
content_len = 0;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
PARSE_SWITCH(4)
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
RESOURCE(resource_switch_dio8,
"title=\"DIO8\"",
get_switch_dio8_handler,
NULL,
NULL,
NULL);
static void
get_switch_dio8_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
content_len = 0;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
PARSE_SWITCH(0)
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/*******************************************************/
/* Resource and handler to obtain potentiometer value */
/*******************************************************/
RESOURCE(resource_pot,
"title=\"Potentiometer\"",
get_pot_handler,
NULL,
NULL,
NULL);
static void
get_pot_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
content_len = 0;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
CONTENT_PRINTF("%d", pot_sensor.value(0));
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
REST.set_response_payload(response, (uint8_t *)content, content_len);
}
}
/************************************/
/* Resource and handler to set leds */
/************************************/
RESOURCE(resource_led_d1,
"title=\"LED D1 <[0,1]>\"",
NULL,
put_post_led_d1_handler,
put_post_led_d1_handler,
NULL);
static void
put_post_led_d1_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
SET_LED(LEDS_GREEN)
}
}
RESOURCE(resource_led_d2,
"title=\"LED D2 <[0,1]>\"",
NULL,
put_post_led_d2_handler,
put_post_led_d2_handler,
NULL);
static void
put_post_led_d2_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
SET_LED(LEDS_BLUE)
}
}
RESOURCE(resource_led_d3,
"title=\"LED D3 <[0,1]>\"",
NULL,
put_post_led_d3_handler,
put_post_led_d3_handler,
NULL);
static void
put_post_led_d3_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
SET_LED(LEDS_RED)
}
}
RESOURCE(resource_led_d3_1174,
"title=\"LED D3 1174<[0,1]>\"",
NULL,
put_post_led_d3_1174_handler,
put_post_led_d3_1174_handler,
NULL);
static void
put_post_led_d3_1174_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
SET_LED(LEDS_GP0);
}
}
RESOURCE(resource_led_d6_1174,
"title=\"LED D6 1174<[0,1]>\"",
NULL,
put_post_led_d6_1174_handler,
put_post_led_d6_1174_handler,
NULL);
static void
put_post_led_d6_1174_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
SET_LED(LEDS_GP1);
}
}
RESOURCE(resource_led_all,
"title=\"LED All <[0,1]>\"",
NULL,
put_post_led_all_handler,
put_post_led_all_handler,
NULL);
static void
put_post_led_all_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const uint8_t *request_content;
int request_content_len;
unsigned int accept = -1;
REST.get_header_accept(request, &accept);
if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
request_content_len = REST.get_request_payload(request, &request_content);
if(atoi((const char *)request_content) != 0) {
leds_on(LEDS_ALL);
} else {
leds_off(LEDS_ALL);
}
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(start_app, ev, data)
{
PROCESS_BEGIN();
static int is_coordinator = 0;
/* is_coordinator = node_id == 1; */
/* Make sensor active for measuring */
SENSORS_ACTIVATE(button_sensor);
SENSORS_ACTIVATE(pot_sensor);
/* Start net stack */
if(is_coordinator) {
uip_ipaddr_t prefix;
uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
rpl_tools_init(&prefix);
} else {
rpl_tools_init(NULL);
} printf("Starting RPL node\n");
rest_init_engine();
rest_activate_resource(&resource_switch_sw1, "DR1199/Switch/SW1");
rest_activate_resource(&resource_switch_sw2, "DR1199/Switch/SW2");
rest_activate_resource(&resource_switch_sw3, "DR1199/Switch/SW3");
rest_activate_resource(&resource_switch_sw4, "DR1199/Switch/SW4");
rest_activate_resource(&resource_switch_dio8, "DR1199/Switch/DIO8");
rest_activate_resource(&resource_pot, "DR1199/Potentiometer");
rest_activate_resource(&resource_led_d1, "DR1199/LED/D1");
rest_activate_resource(&resource_led_d2, "DR1199/LED/D2");
rest_activate_resource(&resource_led_d3, "DR1199/LED/D3");
rest_activate_resource(&resource_led_d3_1174, "DR1199/LED/D3On1174");
rest_activate_resource(&resource_led_d6_1174, "DR1199/LED/D6On1174");
rest_activate_resource(&resource_led_all, "DR1199/LED/All");
rest_activate_resource(&resource_sensors_dr1199, "DR1199/AllSensors");
/* If sensor process generates an event, call event_handler of resource.
This will make this resource observable by the client */
while(1) {
PROCESS_WAIT_EVENT_UNTIL((ev == sensors_event) &&
((data == &button_sensor) || (data == &pot_sensor)));
event_sensors_dr1199_handler();
}
PROCESS_END();
}

View File

@ -0,0 +1,39 @@
/*
* 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.
*
*/
/**
* \author Simon Duquennoy <simonduq@sics.se>
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#include "../common-conf.h"
#endif /* __PROJECT_CONF_H__ */

View File

@ -0,0 +1,85 @@
/*
* 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.
*
*/
/**
* \author Simon Duquennoy <simonduq@sics.se>
*/
#ifndef __COMMON_CONF_H__
#define __COMMON_CONF_H__
#define MAC_CONFIG_NULLRDC 0
#define MAC_CONFIG_CONTIKIMAC 1
/* Select a MAC configuration */
#define MAC_CONFIG MAC_CONFIG_NULLRDC
#undef NETSTACK_CONF_MAC
#undef NETSTACK_CONF_RDC
#undef NETSTACK_CONF_FRAMER
#if MAC_CONFIG == MAC_CONFIG_NULLRDC
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_RDC nullrdc_driver
#define NETSTACK_CONF_FRAMER framer_802154
#elif MAC_CONFIG == MAC_CONFIG_CONTIKIMAC
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_RDC contikimac_driver
#define NETSTACK_CONF_FRAMER contikimac_framer
#undef MICROMAC_CONF_AUTOACK
#define MICROMAC_CONF_AUTOACK 1
#else
#error Unsupported MAC configuration
#endif /* MAC_CONFIG */
/* IEEE802.15.4 PANID and channel */
#undef IEEE802154_CONF_PANID
#define IEEE802154_CONF_PANID 0xabcd
#undef RF_CHANNEL
#define RF_CHANNEL 26
/* UART Configuration */
#undef UART_HW_FLOW_CTRL
#define UART_HW_FLOW_CTRL 0
#undef UART_XONXOFF_FLOW_CTRL
#define UART_XONXOFF_FLOW_CTRL 1
#undef UART_BAUD_RATE
#define UART_BAUD_RATE UART_RATE_1000000
#endif /* __COMMON_CONF_H__ */

View File

@ -0,0 +1,14 @@
CONTIKI_PROJECT = node
all: $(CONTIKI_PROJECT)
TARGET ?= jn516x
CONTIKI=../../../..
CONTIKI_WITH_IPV6 = 1
PROJECTDIRS += .. ../tools
PROJECT_SOURCEFILES += rpl-tools.c
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,18 @@
A RPL node. Will act as basic node by default, but can be configured at startup
using the user button and following instructions from the log output. Every press
of a button toggles the mode as 6ln and 6dr. After 10s with no button press,
the node starts in the last setting. The modes are:
* 6ln (default): 6lowpan node, will join a RPL network and act as router.
* 6dr: 6lowpan DAG Root, will start its own RPL network. Note this is not a
border router, i.e. it does not have a serial interface with connection to
the Internet. For a border router, see ../border-router.
To indicate the hardware target for the node, add one of the following
options in the command line:
If rpl-border-router runs on dongle:
JN516x_WITH_DONGLE=1
If rpl-border-router runs on DR1174:
JN516x_WITH_DR1174=1
If building for a new platform, first execute : make clean
For more information, see ../README.md.

View File

@ -0,0 +1,108 @@
/*
* 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 node able to act as either DAG Root (6dr) or simple node (6ln).
* Press use button at startup to configure.
*
* \author Simon Duquennoy <simonduq@sics.se>
*/
#include "contiki.h"
#include "net/rpl/rpl.h"
#include "tools/rpl-tools.h"
#define DEBUG DEBUG_PRINT
#include "net/ip/uip-debug.h"
#define CONFIG_VIA_BUTTON PLATFORM_HAS_BUTTON
#if CONFIG_VIA_BUTTON
#include "button-sensor.h"
#endif /* CONFIG_VIA_BUTTON */
/*---------------------------------------------------------------------------*/
PROCESS(node_process, "RPL Node");
#if CONFIG_VIA_BUTTON
AUTOSTART_PROCESSES(&node_process, &sensors_process);
#else /* CONFIG_VIA_BUTTON */
AUTOSTART_PROCESSES(&node_process);
#endif /* CONFIG_VIA_BUTTON */
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(node_process, ev, data)
{
PROCESS_BEGIN();
/* 3 possible roles:
* - role_6ln: simple node, will join any network, secured or not
* - role_6dg: DAG root, will advertise (unsecured) beacons
* */
static int is_coordinator = 0;
static enum { role_6ln, role_6dr } node_role;
node_role = role_6ln;
#if CONFIG_VIA_BUTTON
{
#define CONFIG_WAIT_TIME 10
static struct etimer et;
SENSORS_ACTIVATE(button_sensor);
etimer_set(&et, CLOCK_SECOND * CONFIG_WAIT_TIME);
while(!etimer_expired(&et)) {
printf("Init: current role: %s. Will start in %u seconds.\n",
node_role == role_6ln ? "6ln" : "6dr",
CONFIG_WAIT_TIME);
PROCESS_WAIT_EVENT_UNTIL(((ev == sensors_event) &&
(data == &button_sensor) && button_sensor.value(0) > 0)
|| etimer_expired(&et));
if(ev == sensors_event && data == &button_sensor && button_sensor.value(0) > 0) {
node_role = (node_role + 1) % 2;
etimer_restart(&et);
}
}
}
#endif /* CONFIG_VIA_BUTTON */
printf("Init: node starting with role %s\n",
node_role == role_6ln ? "6ln" : "6dr");
is_coordinator = node_role > role_6ln;
if(is_coordinator) {
uip_ipaddr_t prefix;
uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
rpl_tools_init(&prefix);
} else {
rpl_tools_init(NULL);
} PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,40 @@
/*
* 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.
*
*/
/**
* \author Simon Duquennoy <simonduq@sics.se>
*/
#ifndef __PROJECT_CONF_H__
#define __PROJECT_CONF_H__
#include "../common-conf.h"
#endif /* __PROJECT_CONF_H__ */

View File

@ -0,0 +1,83 @@
/*
* 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
*
* \author Simon Duquennoy <simonduq@sics.se>
*/
#include "contiki-conf.h"
#include "contiki-net.h"
#include "net/ip/uip.h"
#include "net/rpl/rpl.h"
#include <string.h>
#include <stdio.h>
#define DEBUG DEBUG_PRINT
#include "net/ip/uip-debug.h"
/*---------------------------------------------------------------------------*/
static void
print_local_addresses(void)
{
int i;
uint8_t state;
PRINTA("Server IPv6 addresses:\n");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
PRINTA(" ");
uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr);
PRINTA("\n");
}
}
}
/*---------------------------------------------------------------------------*/
void
rpl_tools_init(uip_ipaddr_t *br_prefix)
{
uip_ipaddr_t global_ipaddr;
if(br_prefix) { /* We are root */
NETSTACK_RDC.off(1);
memcpy(&global_ipaddr, br_prefix, 16);
uip_ds6_set_addr_iid(&global_ipaddr, &uip_lladdr);
uip_ds6_addr_add(&global_ipaddr, 0, ADDR_AUTOCONF);
rpl_set_root(RPL_DEFAULT_INSTANCE, &global_ipaddr);
rpl_set_prefix(rpl_get_any_dag(), br_prefix, 64);
rpl_repair_root(RPL_DEFAULT_INSTANCE);
}
NETSTACK_MAC.on();
print_local_addresses();
}

View File

@ -0,0 +1,35 @@
/*
* 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.
*
*/
/**
* \author Simon Duquennoy <simonduq@sics.se>
*/
void rpl_tools_init(uip_ipaddr_t *br_prefix);