diff --git a/examples/nullnet/nullnet-broadcast.c b/examples/nullnet/nullnet-broadcast.c index f40b62871..d654784eb 100644 --- a/examples/nullnet/nullnet-broadcast.c +++ b/examples/nullnet/nullnet-broadcast.c @@ -57,11 +57,6 @@ static linkaddr_t coordinator_addr = {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}; #endif /* MAC_CONF_WITH_TSCH */ -static uint32_t buffer[128]; -uint8_t *nullnet_buf = (uint8_t *)buffer; -uint16_t nullnet_len; - - /*---------------------------------------------------------------------------*/ PROCESS(nullnet_example_process, "NullNet broadcast example"); AUTOSTART_PROCESSES(&nullnet_example_process); @@ -86,6 +81,9 @@ PROCESS_THREAD(nullnet_example_process, ev, data) tsch_set_coordinator(linkaddr_cmp(&coordinator_addr, &linkaddr_node_addr)); #endif /* MAC_CONF_WITH_TSCH */ + /* Initialize NullNet */ + nullnet_buf = (uint8_t *)&count; + nullnet_len = sizeof(count); nullnet_set_input_callback(input_callback); etimer_set(&periodic_timer, SEND_INTERVAL); diff --git a/examples/nullnet/nullnet-unicast.c b/examples/nullnet/nullnet-unicast.c index 3518caea3..98866f381 100644 --- a/examples/nullnet/nullnet-unicast.c +++ b/examples/nullnet/nullnet-unicast.c @@ -59,10 +59,6 @@ static linkaddr_t dest_addr = {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0 static linkaddr_t coordinator_addr = {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}; #endif /* MAC_CONF_WITH_TSCH */ -static uint32_t buffer[128]; -uint8_t *nullnet_buf = (uint8_t *)buffer; -uint16_t nullnet_len; - /*---------------------------------------------------------------------------*/ PROCESS(nullnet_example_process, "NullNet unicast example"); AUTOSTART_PROCESSES(&nullnet_example_process); @@ -87,6 +83,9 @@ PROCESS_THREAD(nullnet_example_process, ev, data) tsch_set_coordinator(linkaddr_cmp(&coordinator_addr, &linkaddr_node_addr)); #endif /* MAC_CONF_WITH_TSCH */ + /* Initialize NullNet */ + nullnet_buf = (uint8_t *)&count; + nullnet_len = sizeof(count); nullnet_set_input_callback(input_callback); if(!linkaddr_cmp(&dest_addr, &linkaddr_node_addr)) { @@ -97,9 +96,6 @@ PROCESS_THREAD(nullnet_example_process, ev, data) LOG_INFO_LLADDR(&dest_addr); LOG_INFO_("\n"); - memcpy(nullnet_buf, &count, sizeof(count)); - nullnet_len = sizeof(count); - NETSTACK_NETWORK.output(&dest_addr); count++; etimer_reset(&periodic_timer); diff --git a/os/net/nullnet/nullnet.c b/os/net/nullnet/nullnet.c index 0841379ec..298b2e9cd 100644 --- a/os/net/nullnet/nullnet.c +++ b/os/net/nullnet/nullnet.c @@ -53,6 +53,8 @@ #define LOG_MODULE "NullNet" #define LOG_LEVEL LOG_LEVEL_NULLNET +uint8_t *nullnet_buf; +uint16_t nullnet_len; static nullnet_input_callback current_callback = NULL; /*--------------------------------------------------------------------*/ static void diff --git a/os/net/nullnet/nullnet.h b/os/net/nullnet/nullnet.h index c719b0c80..35b58effe 100644 --- a/os/net/nullnet/nullnet.h +++ b/os/net/nullnet/nullnet.h @@ -52,6 +52,9 @@ for non-IPv6 scenarios. #include "contiki.h" #include "net/linkaddr.h" +/** + * Buffer used by the output function +*/ extern uint8_t *nullnet_buf; extern uint16_t nullnet_len;