Skip to content

Commit

Permalink
Add examples for NXP JN516x using TSCH
Browse files Browse the repository at this point in the history
  • Loading branch information
TeVeDe committed Dec 17, 2015
1 parent af35e04 commit 654bb91
Show file tree
Hide file tree
Showing 31 changed files with 2,657 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/jn516x/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ 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

* tsch: Examples of applications using TSCH
8 changes: 8 additions & 0 deletions examples/jn516x/tsch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
examples for tsch on jn516x

simple-sensor-network: This example shows a simple sensor network consisting of node(s),an rpl-border-router and a host connected to
the IPv6 network.
tx-power-verfication: Example on TX power control and RSSI reading on JN516x. Resource available on coap client
uart1-test-node: Example on exposing uart1 of JN516x node to a coap client


104 changes: 104 additions & 0 deletions examples/jn516x/tsch/common-conf-jn516x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright (c) 2014, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \author Simon Duquennoy <[email protected]>
*/

#ifndef __COMMON_CONF_JN516X_H__
#define __COMMON_CONF_JN516X_H__

/* Shall we restart after exception, or stall?
* in production code we should restart, so set this to 0 */
#undef EXCEPTION_STALLS_SYSTEM
#define EXCEPTION_STALLS_SYSTEM 1

/* CoAP */
#undef COAP_MAX_OPEN_TRANSACTIONS
#define COAP_MAX_OPEN_TRANSACTIONS 4

#undef REST_MAX_CHUNK_SIZE
#define REST_MAX_CHUNK_SIZE 256

/* Network config */
#undef SICSLOWPAN_CONF_FRAG
#define SICSLOWPAN_CONF_FRAG 1
#undef UIP_CONF_BUFFER_SIZE
//#define UIP_CONF_BUFFER_SIZE (REST_MAX_CHUNK_SIZE + UIP_LLH_LEN + UIP_IPUDPH_LEN + COAP_MAX_HEADER_SIZE)
//#define UIP_CONF_BUFFER_SIZE (REST_MAX_CHUNK_SIZE + 0 + 48 + 70)
#define UIP_CONF_BUFFER_SIZE 1280 /* ipv6 required minimum */
#undef UIP_CONF_UDP_CONNS
#define UIP_CONF_UDP_CONNS 8

/* No IPv6 reassembly */
#undef UIP_CONF_IPV6_REASSEMBLY
#define UIP_CONF_IPV6_REASSEMBLY 0

/* Timeout for packet reassembly at the 6lowpan layer (should be < 60s) */
#undef SICSLOWPAN_CONF_MAXAGE
#define SICSLOWPAN_CONF_MAXAGE 10

/* Queues */
#undef QUEUEBUF_CONF_NUM
#define QUEUEBUF_CONF_NUM 32

#undef TSCH_QUEUE_CONF_NUM_PER_NEIGHBOR
#define TSCH_QUEUE_CONF_NUM_PER_NEIGHBOR 32

#undef TSCH_CONF_DEQUEUED_ARRAY_SIZE
#define TSCH_CONF_DEQUEUED_ARRAY_SIZE 32

#undef TSCH_QUEUE_CONF_MAX_NEIGHBOR_QUEUES
#define TSCH_QUEUE_CONF_MAX_NEIGHBOR_QUEUES 8

/* The neighbor table size */
#undef NBR_TABLE_CONF_MAX_NEIGHBORS
#define NBR_TABLE_CONF_MAX_NEIGHBORS 8

/* The routing table size */
#undef UIP_CONF_MAX_ROUTES
#define UIP_CONF_MAX_ROUTES 28

/* Radio */

#undef ENABLE_COOJA_DEBUG
#define ENABLE_COOJA_DEBUG 0

/* max 3, min 0 */

#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_JN516X_H__ */
205 changes: 205 additions & 0 deletions examples/jn516x/tsch/common-conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
/*
* Copyright (c) 2014, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \author Simon Duquennoy <[email protected]>
*/

#ifndef __COMMON_CONF_H__
#define __COMMON_CONF_H__

/* Global config flags */

#define WITH_TSCH 1
#define WITH_TSCH_SECURITY 0
#define TSCH_LOG_CONF_LEVEL 2
#define WITH_COAP_RESOURCES 0

#undef ENABLE_COOJA_DEBUG
#define ENABLE_COOJA_DEBUG 0

#if WITH_COAP_RESOURCES
#define UIP_DS6_WITH_LINK_METRICS 1
#define PLEXI_CONFIG_RPL 1
#if WITH_TSCH
#define PLEXI_CONFIG_TSCH 2
#endif /* WITH_TSCH */
#define RICH_INTERFACE PLEXI_CONFIG_RPL | PLEXI_CONFIG_TSCH
#endif /* WITH_COAP_RESOURCES */

#undef IEEE802154_CONF_PANID
#define IEEE802154_CONF_PANID 0x5254

#undef TSCH_CONF_DEFAULT_HOPPING_SEQUENCE
#define TSCH_HOPPING_SEQUENCE_MY_SEQUENCE (uint8_t[]){17, 23, 15, 25, 19, 11, 13, 21}
#define TSCH_CONF_DEFAULT_HOPPING_SEQUENCE TSCH_HOPPING_SEQUENCE_MY_SEQUENCE

#undef TSCH_CONF_JOIN_MY_PANID_ONLY
#define TSCH_CONF_JOIN_MY_PANID_ONLY 1

#undef TSCH_CONF_AUTOSTART
#define TSCH_CONF_AUTOSTART 0

#define RPL_CALLBACK_PARENT_SWITCH tsch_rpl_callback_parent_switch
#define RPL_CALLBACK_NEW_DIO_INTERVAL tsch_rpl_callback_new_dio_interval

/* RPL Trickle timer tuning */
#undef RPL_CONF_DIO_INTERVAL_MIN
#define RPL_CONF_DIO_INTERVAL_MIN 12 /* 4.096 s */

#undef RPL_CONF_DIO_INTERVAL_DOUBLINGS
#define RPL_CONF_DIO_INTERVAL_DOUBLINGS 2 /* Max factor: x4. 4.096 s * 4 = 16.384 s */

#define TSCH_CONF_EB_PERIOD (4 * CLOCK_SECOND)
#define TSCH_CONF_KEEPALIVE_TIMEOUT (24 * CLOCK_SECOND)

#define TSCH_SCHEDULE_CONF_WITH_6TISCH_MINIMAL 0
#define TSCH_CONF_WITH_LINK_SELECTOR 1
#define TSCH_CALLBACK_NEW_TIME_SOURCE orchestra_callback_new_time_source
#define TSCH_CALLBACK_PACKET_READY orchestra_callback_packet_ready
#define NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK orchestra_callback_child_added
#define NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK orchestra_callback_child_removed

/* Dimensioning */
#define ORCHESTRA_CONF_EBSF_PERIOD 41
#define ORCHESTRA_CONF_COMMON_SHARED_PERIOD 7 /* Common shared slot, 7 is a very short slotframe (high energy, high capacity). Must be prime and at least equal to number of nodes (incl. BR) */
#define ORCHESTRA_CONF_UNICAST_PERIOD 11 /* First prime greater than 10 */

/* Use sender-based slots */
#define ORCHESTRA_CONF_UNICAST_SENDER_BASED 1
/* Our "hash" is collision-free */
#define ORCHESTRA_CONF_COLLISION_FREE_HASH 1
/* Max hash value */
#define ORCHESTRA_CONF_MAX_HASH (ORCHESTRA_CONF_UNICAST_PERIOD - 1)

/* RPL probing */
#define RPL_CONF_PROBING_INTERVAL (5 * CLOCK_SECOND)
#define RPL_CONF_PROBING_EXPIRATION_TIME (2 * 60 * CLOCK_SECOND)

/* CoAP */

#undef COAP_SERVER_PORT
#define COAP_SERVER_PORT 5684

#undef COAP_OBSERVE_RETURNS_REPRESENTATION
#define COAP_OBSERVE_RETURNS_REPRESENTATION 1

/* RPL */
#undef UIP_CONF_ROUTER
#define UIP_CONF_ROUTER 1

/* RPL storing mode */
#undef RPL_CONF_MOP
#define RPL_CONF_MOP RPL_MOP_STORING_NO_MULTICAST

/* Default link metric */
#undef RPL_CONF_INIT_LINK_METRIC
#define RPL_CONF_INIT_LINK_METRIC 2 /* default 5 */

#define RPL_CONF_MAX_INSTANCES 1 /* default 1 */
#define RPL_CONF_MAX_DAG_PER_INSTANCE 1 /* default 2 */

/* No RA, No NA */
#undef UIP_CONF_ND6_SEND_NA
#define UIP_CONF_ND6_SEND_NA 0

#undef UIP_CONF_ND6_SEND_RA
#define UIP_CONF_ND6_SEND_RA 0

#undef UIP_CONF_TCP
#define UIP_CONF_TCP 0
#undef UIP_CONF_DS6_ADDR_NBU
#define UIP_CONF_DS6_ADDR_NBU 1
#undef UIP_CONF_FWCACHE_SIZE
#define UIP_CONF_FWCACHE_SIZE 1
#undef UIP_CONF_UDP_CHECKSUMS
#define UIP_CONF_UDP_CHECKSUMS 1

/* Link-layer security */

/* Even when link-layer security is needed, we do not use a LLSEC layer, as it does not
* allow to secure MAC-layer packets, nor can run encrypt/decrupt from interrupt.
* Instead, we call AES-CCM* primitives directly from TSCH */
#undef NETSTACK_CONF_LLSEC
#define NETSTACK_CONF_LLSEC nullsec_driver

#if WITH_TSCH_SECURITY
/* Set security level to the maximum, even if unused, to all crypto code */
#define LLSEC802154_CONF_SECURITY_LEVEL 7
/* Attempt to associate from both secured and non-secured EBs */
#define TSCH_CONF_JOIN_SECURED_ONLY 0
/* We need explicit keys to identify k1 and k2 */
#undef LLSEC802154_CONF_USES_EXPLICIT_KEYS
#define LLSEC802154_CONF_USES_EXPLICIT_KEYS 1
/* TSCH uses the ASN to construct the Nonce */
#undef LLSEC802154_CONF_USES_FRAME_COUNTER
#define LLSEC802154_CONF_USES_FRAME_COUNTER 0
#endif /* WITH_TSCH_SECURITY */

#if WITH_TSCH

#undef FRAME802154_CONF_VERSION
#define FRAME802154_CONF_VERSION FRAME802154_IEEE802154E_2012

/* Contiki netstack: MAC */
#undef NETSTACK_CONF_MAC
#define NETSTACK_CONF_MAC tschmac_driver

/* Contiki netstack: RDC */
#undef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC nordc_driver

#else /* No TSCH, use Csma+NullRDC with ACK */

/* Contiki netstack: MAC */
#undef NETSTACK_CONF_MAC
#define NETSTACK_CONF_MAC csma_driver

/* Contiki netstack: RDC */
#undef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC nullrdc_driver

#undef RF_CHANNEL
#define RF_CHANNEL 26

#undef MICROMAC_CONF_AUTOACK
#define MICROMAC_CONF_AUTOACK 1

/* increase internal radio buffering */
#undef MIRCOMAC_CONF_BUF_NUM
#define MIRCOMAC_CONF_BUF_NUM 4

#endif

#undef CONTIKI_VERSION_STRING
#define CONTIKI_VERSION_STRING "Contiki RICH-3.x"

#include "common-conf-jn516x.h"

#endif /* __COMMON_CONF_H__ */
25 changes: 25 additions & 0 deletions examples/jn516x/tsch/simple-sensor-network/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
This example shows a simple sensor network consisting of node(s),an rpl-border-router and a host connected to
the IPv6 network. The nodes (see also node/README.md) regularly transmit simulated sensor data to the host.
The host visualises the received data.

The Python script tools/Output-Visualisation.py visualises the received data from the nodes.
The script runs on Python27 and uses gnuplot for visualisation.
The following installations are needed (tested with Win32 versions:
- Python 27 (https://www.python.org/download/releases/2.7/)
- gnuplot (http://sourceforge.net/projects/gnuplot/files/gnuplot/)
- gnuplot.py (http://gnuplot-py.sourceforge.net/)
- numpy.py (e.g. http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy)
Manual modification:
Python27\Lib\site-packages\Gnuplot\gp_win32.py
Modify gnuplot_command as in example below
gnuplot_command = r'"C:\Program Files (x86)\gnuplot\bin\gnuplot.exe"'

- The IPv6 addresses of nodes need to be entered in the dictionary "node_data" of tools/Output-Visualisation.py
A user name for the node can be entered in this table as well.
- The script will send a ping message to the next node in the list every 5 seconds. The nodes will obtain
the IPv6 address from this message and start sending "sensor" data to the host.
- Received sensor data is plotted. When no data has been received for more than 30seconds, the plot line
will be dashed.
- Plots are updated once per second.


25 changes: 25 additions & 0 deletions examples/jn516x/tsch/simple-sensor-network/node/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CONTIKI_PROJECT = node

TARGET ?= jn516x
JN516x_WITH_DONGLE = 1

CONTIKI=../../../../..

CONTIKI_WITH_IPV6 = 1

CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
PROJECTDIRS += .. ../../tools
PROJECT_SOURCEFILES += rich.c
CFLAGS += -DWITH_COAP
CFLAGS += -DREST=coap_rest_implementation
CFLAGS += -DUIP_CONF_TCP=0
APPS += orchestra
APPS += json
APPS += er-coap
APPS += rest-engine

MODULES += core/net/mac/tsch

all: $(CONTIKI_PROJECT)

include $(CONTIKI)/Makefile.include
10 changes: 10 additions & 0 deletions examples/jn516x/tsch/simple-sensor-network/node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Node is part of Simple-Sensor-Network
When node is connected to border-router (TSCH), it will wait to be addressed by a host
on port 8185.
When addressed, IPv6 address of host is acquired. Node will start to transmit samples of
a waveform ("simulated" sensor data) to the host on port 8186 at a rate of once per
10 seconds. Type of waveform and phase depend on mac address of node in order to better
distinguish the waveforms at the host side.
LED is flashed every time a sample is transmitted.
Nodes are tested with configuration JN516x_WITH_DONGLE=1

Loading

0 comments on commit 654bb91

Please sign in to comment.