Add examples for NXP JN516x using TSCH
This commit is contained in:
parent
654bb913f0
commit
68b2b3dd1c
|
@ -1,8 +1,8 @@
|
|||
examples for tsch on jn516x
|
||||
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
|
||||
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
|
||||
|
||||
|
|
@ -44,15 +44,6 @@
|
|||
#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
|
||||
|
||||
|
@ -198,7 +189,7 @@
|
|||
#endif
|
||||
|
||||
#undef CONTIKI_VERSION_STRING
|
||||
#define CONTIKI_VERSION_STRING "Contiki RICH-3.x"
|
||||
#define CONTIKI_VERSION_STRING "Contiki 3.x"
|
||||
|
||||
#include "common-conf-jn516x.h"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ CONTIKI_WITH_IPV6 = 1
|
|||
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
PROJECTDIRS += .. ../../tools
|
||||
PROJECT_SOURCEFILES += rich.c
|
||||
PROJECT_SOURCEFILES += rpl-tools.c
|
||||
CFLAGS += -DWITH_COAP
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=0
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "net/mac/tsch/tsch-schedule.h"
|
||||
#include "net/ip/uip-debug.h"
|
||||
#include "lib/random.h"
|
||||
#include "rich.h"
|
||||
#include "rpl-tools.h"
|
||||
#include "node-id.h"
|
||||
#include "waveform.h"
|
||||
#include "leds.h"
|
||||
|
@ -82,7 +82,6 @@ static int selected_waveform = 0;
|
|||
|
||||
static void udp_rx_handler(void);
|
||||
static void my_sprintf(char * udp_buf, int8_t value);
|
||||
static void print_network_status(void);
|
||||
|
||||
static struct uip_udp_conn *udp_conn_rx;
|
||||
static struct uip_udp_conn *udp_conn_tx;
|
||||
|
@ -94,54 +93,6 @@ static char *post_mssg = "Trigger";
|
|||
/*******************************************************************************/
|
||||
/* Local functions */
|
||||
/*******************************************************************************/
|
||||
static void
|
||||
print_network_status(void)
|
||||
{
|
||||
int i;
|
||||
uint8_t state;
|
||||
uip_ds6_defrt_t *default_route;
|
||||
uip_ds6_route_t *route;
|
||||
|
||||
printf("--- Network status ---\n");
|
||||
|
||||
/* Our IPv6 addresses */
|
||||
printf("- 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");
|
||||
}
|
||||
}
|
||||
|
||||
/* Our default route */
|
||||
printf("- Default route:\n");
|
||||
default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose());
|
||||
if(default_route != NULL) {
|
||||
printf("-- ");
|
||||
uip_debug_ipaddr_print(&default_route->ipaddr);;
|
||||
printf(" (lifetime: %lu seconds)\n", (unsigned long)default_route->lifetime.interval);
|
||||
} else {
|
||||
printf("-- None\n");
|
||||
}
|
||||
|
||||
/* Our routing entries */
|
||||
printf("- Routing entries (%u in total):\n", uip_ds6_route_num_routes());
|
||||
route = uip_ds6_route_head();
|
||||
while(route != NULL) {
|
||||
printf("-- ");
|
||||
uip_debug_ipaddr_print(&route->ipaddr);
|
||||
printf(" via ");
|
||||
uip_debug_ipaddr_print(uip_ds6_route_nexthop(route));
|
||||
printf(" (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime);
|
||||
route = uip_ds6_route_next(route);
|
||||
}
|
||||
|
||||
printf("----------------------\n");
|
||||
}
|
||||
|
||||
static void
|
||||
udp_rx_handler(void)
|
||||
{
|
||||
|
@ -176,7 +127,7 @@ my_sprintf(char * udp_buf, int8_t value)
|
|||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(node_process, "RICH Node");
|
||||
PROCESS(node_process, "Node");
|
||||
PROCESS(led_process, "LED");
|
||||
AUTOSTART_PROCESSES(&node_process);
|
||||
|
||||
|
@ -221,9 +172,9 @@ PROCESS_THREAD(node_process, ev, data)
|
|||
if(is_coordinator) {
|
||||
uip_ipaddr_t prefix;
|
||||
uip_ip6addr(&prefix, 0xbbbb, 0, 0, 0, 0, 0, 0, 0);
|
||||
rich_init(&prefix);
|
||||
rpl_tools_init(&prefix);
|
||||
} else {
|
||||
rich_init(NULL);
|
||||
rpl_tools_init(NULL);
|
||||
}
|
||||
|
||||
/* Selected waveform depends on LS byte of MAC */
|
||||
|
|
|
@ -10,7 +10,7 @@ CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
|||
PROJECT_SOURCEFILES += slip-bridge.c slip.c
|
||||
|
||||
PROJECTDIRS += .. ../../tools
|
||||
PROJECT_SOURCEFILES += rich.c
|
||||
PROJECT_SOURCEFILES += rpl-tools.c
|
||||
|
||||
CFLAGS += -DWITH_COAP
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
|
|
|
@ -44,12 +44,9 @@
|
|||
#include "simple-udp.h"
|
||||
#include "net/mac/tsch/tsch.h"
|
||||
#include "net/mac/tsch/tsch-schedule.h"
|
||||
#include "rich.h"
|
||||
|
||||
#include "net/netstack.h"
|
||||
#include "dev/slip.h"
|
||||
|
||||
#include "rich.h"
|
||||
#include "rpl-tools.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -65,56 +62,6 @@ static uint8_t prefix_set;
|
|||
PROCESS(border_router_process, "Border router process");
|
||||
|
||||
AUTOSTART_PROCESSES(&border_router_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
print_network_status(void)
|
||||
{
|
||||
int i;
|
||||
uint8_t state;
|
||||
uip_ds6_defrt_t *default_route;
|
||||
uip_ds6_route_t *route;
|
||||
|
||||
PRINTA("--- Network status ---\n");
|
||||
|
||||
/* Our IPv6 addresses */
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/* Our default route */
|
||||
PRINTA("- Default route:\n");
|
||||
default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose());
|
||||
if(default_route != NULL) {
|
||||
PRINTA("-- ");
|
||||
uip_debug_ipaddr_print(&default_route->ipaddr);;
|
||||
PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)default_route->lifetime.interval);
|
||||
} else {
|
||||
PRINTA("-- None\n");
|
||||
}
|
||||
|
||||
/* Our routing entries */
|
||||
PRINTA("- Routing entries (%u in total):\n", uip_ds6_route_num_routes());
|
||||
route = uip_ds6_route_head();
|
||||
while(route != NULL) {
|
||||
PRINTA("-- ");
|
||||
uip_debug_ipaddr_print(&route->ipaddr);
|
||||
PRINTA(" via ");
|
||||
uip_debug_ipaddr_print(uip_ds6_route_nexthop(route));
|
||||
PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime);
|
||||
route = uip_ds6_route_next(route);
|
||||
}
|
||||
|
||||
PRINTA("----------------------\n");
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
request_prefix(void)
|
||||
|
@ -122,7 +69,6 @@ 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;
|
||||
|
@ -165,7 +111,7 @@ PROCESS_THREAD(border_router_process, ev, data)
|
|||
uip_debug_ipaddr_print(&prefix);
|
||||
PRINTF("\n");
|
||||
|
||||
rich_init(&prefix);
|
||||
rpl_tools_init(&prefix);
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND * 60);
|
||||
while(1) {
|
||||
|
|
|
@ -37,22 +37,55 @@
|
|||
#include "contiki-net.h"
|
||||
#include "net/ip/uip.h"
|
||||
#include "net/rpl/rpl.h"
|
||||
#include "net/mac/tsch/tsch.h"
|
||||
#include "net/mac/tsch/tsch-schedule.h"
|
||||
#include "node-id.h"
|
||||
#include "orchestra.h"
|
||||
#if WITH_COAP_RESOURCES
|
||||
#include "tools/plexi.h"
|
||||
#endif
|
||||
#if CONTIKI_TARGET_SKY || CONTIKI_TARGET_Z1
|
||||
#include "cc2420.h"
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
void
|
||||
print_network_status(void)
|
||||
{
|
||||
int i;
|
||||
uint8_t state;
|
||||
uip_ds6_defrt_t *default_route;
|
||||
uip_ds6_route_t *route;
|
||||
PRINTA("--- Network status ---\n");
|
||||
/* Our IPv6 addresses */
|
||||
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");
|
||||
}
|
||||
}
|
||||
/* Our default route */
|
||||
PRINTA("- Default route:\n");
|
||||
default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose());
|
||||
if(default_route != NULL) {
|
||||
PRINTA("-- ");
|
||||
uip_debug_ipaddr_print(&default_route->ipaddr);;
|
||||
PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)default_route->lifetime.interval);
|
||||
} else {
|
||||
PRINTA("-- None\n");
|
||||
}
|
||||
/* Our routing entries */
|
||||
PRINTA("- Routing entries (%u in total):\n", uip_ds6_route_num_routes());
|
||||
route = uip_ds6_route_head();
|
||||
while(route != NULL) {
|
||||
PRINTA("-- ");
|
||||
uip_debug_ipaddr_print(&route->ipaddr);
|
||||
PRINTA(" via ");
|
||||
uip_debug_ipaddr_print(uip_ds6_route_nexthop(route));
|
||||
PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime);
|
||||
route = uip_ds6_route_next(route);
|
||||
}
|
||||
PRINTA("----------------------\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
print_local_addresses(void)
|
||||
|
@ -72,11 +105,14 @@ print_local_addresses(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
rich_network_init(uip_ipaddr_t *br_prefix)
|
||||
void
|
||||
rpl_tools_init(uip_ipaddr_t *br_prefix)
|
||||
{
|
||||
uip_ipaddr_t global_ipaddr;
|
||||
|
||||
#if TSCH_CONFIG == TSCH_CONFIG_ORCHESTRA
|
||||
orchestra_init();
|
||||
#endif
|
||||
if(br_prefix) { /* We are root */
|
||||
/* If an RDC layer is used, turn it off (i.e. keep the radio on at the root). */
|
||||
NETSTACK_RDC.off(1);
|
||||
|
@ -90,22 +126,5 @@ rich_network_init(uip_ipaddr_t *br_prefix)
|
|||
|
||||
/* Start TSCH */
|
||||
NETSTACK_MAC.on();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rich_init(uip_ipaddr_t *br_prefix)
|
||||
{
|
||||
#if TSCH_CONFIG == TSCH_CONFIG_ORCHESTRA
|
||||
orchestra_init();
|
||||
#endif
|
||||
|
||||
rich_network_init(br_prefix);
|
||||
|
||||
#if WITH_COAP_RESOURCES
|
||||
plexi_init();
|
||||
#endif
|
||||
|
||||
PRINTF("App: %u starting\n", node_id);
|
||||
|
||||
print_local_addresses();
|
||||
}
|
|
@ -32,5 +32,5 @@
|
|||
* \author Simon Duquennoy <simonduq@sics.se>
|
||||
*/
|
||||
|
||||
void rich_init(uip_ipaddr_t *br_prefix);
|
||||
unsigned rich_orchestra_hash(const linkaddr_t *addr);
|
||||
void rpl_tools_init(uip_ipaddr_t *br_prefix);
|
||||
void print_network_status(void);
|
|
@ -8,7 +8,7 @@ CONTIKI_WITH_IPV6 = 1
|
|||
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
PROJECTDIRS += .. ../../tools
|
||||
PROJECT_SOURCEFILES += rich.c
|
||||
PROJECT_SOURCEFILES += rpl-tools.c
|
||||
|
||||
CFLAGS += -DWITH_COAP
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "net/netstack.h"
|
||||
#include "net/ip/uip.h"
|
||||
#include "net/linkaddr.h"
|
||||
#include "rich.h"
|
||||
#include "rpl-tools.h"
|
||||
#include "rest-engine.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -54,7 +54,7 @@ PROCESS(start_app, "START_APP");
|
|||
AUTOSTART_PROCESSES(&start_app);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*********** RICH sensor/ resource ************************************************/
|
||||
/*********** sensor/ resource ************************************************/
|
||||
RESOURCE(resource_set_tx_power,
|
||||
"title=\"Set TX Power\"",
|
||||
NULL,
|
||||
|
@ -65,7 +65,6 @@ static void
|
|||
set_tx_power_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 tx_level;
|
||||
|
||||
unsigned int accept = -1;
|
||||
|
@ -103,13 +102,13 @@ PROCESS_THREAD(start_app, ev, data)
|
|||
PROCESS_BEGIN();
|
||||
static int is_coordinator = 0;
|
||||
|
||||
/* Start RICH stack */
|
||||
/* Start network stack */
|
||||
if(is_coordinator) {
|
||||
uip_ipaddr_t prefix;
|
||||
uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
rich_init(&prefix);
|
||||
rpl_tools_init(&prefix);
|
||||
} else {
|
||||
rich_init(NULL);
|
||||
rpl_tools_init(NULL);
|
||||
}
|
||||
printf("Starting RPL node\n");
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
|||
PROJECT_SOURCEFILES += slip-bridge.c slip.c
|
||||
|
||||
PROJECTDIRS += .. ../../tools
|
||||
PROJECT_SOURCEFILES += rich.c
|
||||
PROJECT_SOURCEFILES += rpl-tools.c
|
||||
|
||||
CFLAGS += -DWITH_COAP
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "net/netstack.h"
|
||||
#include "dev/slip.h"
|
||||
#include "rest-engine.h"
|
||||
#include "rich.h"
|
||||
#include "rpl-tools.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -109,8 +109,6 @@ get_last_rssi_handler(void *request, void *response, uint8_t *buffer, uint16_t p
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
request_prefix(void)
|
||||
|
@ -159,7 +157,7 @@ PROCESS_THREAD(border_router_process, ev, data)
|
|||
uip_debug_ipaddr_print(&prefix);
|
||||
PRINTF("\n");
|
||||
|
||||
rich_init(&prefix);
|
||||
rpl_tools_init(&prefix);
|
||||
|
||||
rest_init_engine();
|
||||
rest_activate_resource(&resource_get_rssi, "Get-RSSI");
|
||||
|
|
|
@ -9,7 +9,7 @@ CONTIKI_WITH_IPV6 = 1
|
|||
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
PROJECTDIRS += .. ../tools
|
||||
PROJECT_SOURCEFILES += rich.c
|
||||
PROJECT_SOURCEFILES += rpl-tools.c
|
||||
|
||||
CFLAGS += -DWITH_COAP
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
This example is a simple TSCH node used to test uart1 functionality of a JN516x on a RICH node.
|
||||
This example is a simple TSCH node used to test uart1 functionality of a JN516x on a node.
|
||||
Note: uart0 is usually configured as serial port for flashing the JN516x and for logging and debug output.
|
||||
|
||||
The TX output of uart1 is represented as a PUT/POST resource for a Coap client.
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
#include "net/ip/uip.h"
|
||||
#include "net/linkaddr.h"
|
||||
#include "rich.h"
|
||||
#include "rpl-tools.h"
|
||||
#include "rest-engine.h"
|
||||
#include "sys/ctimer.h"
|
||||
#include "dev/uart-driver.h"
|
||||
|
@ -137,20 +137,18 @@ PROCESS_THREAD(start_app, ev, data)
|
|||
memset(rx_buf, '\0', sizeof(rx_buf));
|
||||
/* Define process that handles data */
|
||||
process_start(&rx_data_process ,NULL);
|
||||
/* Define ringbuffer control */
|
||||
// ringbufindex_init(&ringbuf,RX_BUFFER_SIZE);
|
||||
/* Initialise UART1 */
|
||||
uart1_init(UART1_BAUD_RATE);
|
||||
/* Callback received byte */
|
||||
uart1_set_input(handleRxChar);
|
||||
|
||||
/* Start RICH stack */
|
||||
/* Start network stack */
|
||||
if(is_coordinator) {
|
||||
uip_ipaddr_t prefix;
|
||||
uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
rich_init(&prefix);
|
||||
rpl_tools_init(&prefix);
|
||||
} else {
|
||||
rich_init(NULL);
|
||||
rpl_tools_init(NULL);
|
||||
}
|
||||
printf("Starting RPL node\n");
|
||||
|
||||
|
@ -200,7 +198,8 @@ PROCESS_THREAD(rx_data_process, ev, data)
|
|||
/* Local test functions */
|
||||
/*************************************************************************/
|
||||
/* TX function for UART1 */
|
||||
static void string2uart1(uint8_t *c)
|
||||
static void
|
||||
string2uart1(uint8_t *c)
|
||||
{
|
||||
while (*c!= '\0') {
|
||||
uart1_writeb(*c);
|
||||
|
@ -209,7 +208,8 @@ static void string2uart1(uint8_t *c)
|
|||
}
|
||||
|
||||
/* handleRxChar runs on uart isr */
|
||||
static int handleRxChar(uint8_t c)
|
||||
static int
|
||||
handleRxChar(uint8_t c)
|
||||
{
|
||||
if (put_ringbuf(c) == -1) {
|
||||
printf("Ringbuf full. Skip char\n");
|
||||
|
@ -223,7 +223,8 @@ static int handleRxChar(uint8_t c)
|
|||
/* Simple ringbuffer
|
||||
if tail==head, no data has been written yet on that position. So, empty buffer
|
||||
is also initial state */
|
||||
static int get_ringbuf(uint8_t *c)
|
||||
static int
|
||||
get_ringbuf(uint8_t *c)
|
||||
{
|
||||
int return_val = 0;
|
||||
|
||||
|
@ -238,7 +239,8 @@ static int get_ringbuf(uint8_t *c)
|
|||
return return_val;
|
||||
}
|
||||
|
||||
static int put_ringbuf(uint8_t c)
|
||||
static int
|
||||
put_ringbuf(uint8_t c)
|
||||
{
|
||||
int return_val = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue