NullNet: move buffer variables from examples to os/net module

This commit is contained in:
Simon Duquennoy 2017-10-08 14:56:47 +02:00
parent 32e9c5067e
commit e81864e8d8
4 changed files with 11 additions and 12 deletions

View File

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

View File

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

View File

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

View File

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