diff --git a/examples/jn516x/tsch/README.md b/examples/jn516x/tsch/README.md index 17b0c5ede..2bfcc036a 100644 --- a/examples/jn516x/tsch/README.md +++ b/examples/jn516x/tsch/README.md @@ -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 \ No newline at end of file diff --git a/examples/jn516x/tsch/common-conf.h b/examples/jn516x/tsch/common-conf.h index 5458dbf95..3fbd8ad4b 100644 --- a/examples/jn516x/tsch/common-conf.h +++ b/examples/jn516x/tsch/common-conf.h @@ -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" diff --git a/examples/jn516x/tsch/simple-sensor-network/node/Makefile b/examples/jn516x/tsch/simple-sensor-network/node/Makefile index 41d2e26bd..2df54d578 100644 --- a/examples/jn516x/tsch/simple-sensor-network/node/Makefile +++ b/examples/jn516x/tsch/simple-sensor-network/node/Makefile @@ -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 diff --git a/examples/jn516x/tsch/simple-sensor-network/node/node.c b/examples/jn516x/tsch/simple-sensor-network/node/node.c index 7fa4c7f26..48b7c4ff5 100644 --- a/examples/jn516x/tsch/simple-sensor-network/node/node.c +++ b/examples/jn516x/tsch/simple-sensor-network/node/node.c @@ -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 */ diff --git a/examples/jn516x/tsch/simple-sensor-network/rpl-border-router/Makefile b/examples/jn516x/tsch/simple-sensor-network/rpl-border-router/Makefile index 8b2f17679..1598632ef 100644 --- a/examples/jn516x/tsch/simple-sensor-network/rpl-border-router/Makefile +++ b/examples/jn516x/tsch/simple-sensor-network/rpl-border-router/Makefile @@ -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 diff --git a/examples/jn516x/tsch/simple-sensor-network/rpl-border-router/border-router.c b/examples/jn516x/tsch/simple-sensor-network/rpl-border-router/border-router.c index ad25d3b93..7657dc190 100644 --- a/examples/jn516x/tsch/simple-sensor-network/rpl-border-router/border-router.c +++ b/examples/jn516x/tsch/simple-sensor-network/rpl-border-router/border-router.c @@ -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 #include @@ -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) { diff --git a/examples/jn516x/tsch/tools/rich.c b/examples/jn516x/tsch/tools/rpl-tools.c similarity index 69% rename from examples/jn516x/tsch/tools/rich.c rename to examples/jn516x/tsch/tools/rpl-tools.c index 75850fd5a..b61c693c2 100644 --- a/examples/jn516x/tsch/tools/rich.c +++ b/examples/jn516x/tsch/tools/rpl-tools.c @@ -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 #include #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(); } diff --git a/examples/jn516x/tsch/tools/rich.h b/examples/jn516x/tsch/tools/rpl-tools.h similarity index 94% rename from examples/jn516x/tsch/tools/rich.h rename to examples/jn516x/tsch/tools/rpl-tools.h index 4d41c3a2d..b04cdb712 100644 --- a/examples/jn516x/tsch/tools/rich.h +++ b/examples/jn516x/tsch/tools/rpl-tools.h @@ -32,5 +32,5 @@ * \author Simon Duquennoy */ -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); diff --git a/examples/jn516x/tsch/tx-power-verification/node/Makefile b/examples/jn516x/tsch/tx-power-verification/node/Makefile index 71be54bf0..0cb2d4bcb 100644 --- a/examples/jn516x/tsch/tx-power-verification/node/Makefile +++ b/examples/jn516x/tsch/tx-power-verification/node/Makefile @@ -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 diff --git a/examples/jn516x/tsch/tx-power-verification/node/node.c b/examples/jn516x/tsch/tx-power-verification/node/node.c index 65bbf2052..1e77d3a2e 100644 --- a/examples/jn516x/tsch/tx-power-verification/node/node.c +++ b/examples/jn516x/tsch/tx-power-verification/node/node.c @@ -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 #include @@ -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"); diff --git a/examples/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile b/examples/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile index 41a015e8f..15c5da2a2 100644 --- a/examples/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile +++ b/examples/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile @@ -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 diff --git a/examples/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c b/examples/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c index 938c756d6..cd9e2e2a2 100644 --- a/examples/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c +++ b/examples/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c @@ -43,7 +43,7 @@ #include "net/netstack.h" #include "dev/slip.h" #include "rest-engine.h" -#include "rich.h" +#include "rpl-tools.h" #include #include @@ -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"); diff --git a/examples/jn516x/tsch/uart1-test-node/Makefile b/examples/jn516x/tsch/uart1-test-node/Makefile index 2d9e0ebe5..76a3d6252 100644 --- a/examples/jn516x/tsch/uart1-test-node/Makefile +++ b/examples/jn516x/tsch/uart1-test-node/Makefile @@ -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 diff --git a/examples/jn516x/tsch/uart1-test-node/README.md b/examples/jn516x/tsch/uart1-test-node/README.md index b144eb8f5..73eefd1ac 100644 --- a/examples/jn516x/tsch/uart1-test-node/README.md +++ b/examples/jn516x/tsch/uart1-test-node/README.md @@ -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. diff --git a/examples/jn516x/tsch/uart1-test-node/uart1-test-node.c b/examples/jn516x/tsch/uart1-test-node/uart1-test-node.c index 101d17e7a..0a4259f95 100644 --- a/examples/jn516x/tsch/uart1-test-node/uart1-test-node.c +++ b/examples/jn516x/tsch/uart1-test-node/uart1-test-node.c @@ -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;