Add examples for NXP JN516x using TSCH

This commit is contained in:
Theo van Daele 2015-12-17 13:29:42 +01:00
parent 654bb913f0
commit 68b2b3dd1c
15 changed files with 83 additions and 177 deletions

View file

@ -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

View file

@ -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 */

View file

@ -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

View file

@ -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) {