Skip to content

Commit

Permalink
Merge pull request #3987 from karsev/thread_link_config_update
Browse files Browse the repository at this point in the history
thread link configuration bypass flag in mesh-api
  • Loading branch information
sg- authored Apr 10, 2017
2 parents a514216 + 8862ede commit c776eaa
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"6lowpan-nd-sec-level": 5,
"6lowpan-nd-device-type": "NET_6LOWPAN_ROUTER",
"thread-pskd": "\"abcdefghijklmno\"",
"thread-use-static-link-config": true,
"thread-config-channel-mask": "0x7fff800",
"thread-config-channel-page": 0,
"thread-config-channel": 22,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "net_interface.h"
#include "ip6string.h" //ip6tos
#include "nsdynmemLIB.h"
#include "include/static_config.h"
#include "include/mesh_system.h"
#include "ns_event_loop.h"
#include "mesh_interface_types.h"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
#include "randLIB.h"
#include "platform/arm_hal_timer.h"
#include "ns_hal_init.h"
#include "include/static_config.h"
#include "include/mesh_system.h"
// For tracing we need to define flag, have include and define group
#define HAVE_DEBUG 1
#include "ns_trace.h"
#define TRACE_GROUP "m6-mesh-system"

/* Heap for NanoStack */
static uint8_t app_stack_heap[MBED_MESH_API_HEAP_SIZE + 1];
static uint8_t app_stack_heap[MBED_CONF_MBED_MESH_API_HEAP_SIZE + 1];
static bool mesh_initialized = false;

/*
Expand All @@ -56,7 +55,7 @@ static void mesh_system_heap_error_handler(heap_fail_t event)
void mesh_system_init(void)
{
if (mesh_initialized == false) {
ns_hal_init(app_stack_heap, MBED_MESH_API_HEAP_SIZE,
ns_hal_init(app_stack_heap, MBED_CONF_MBED_MESH_API_HEAP_SIZE,
mesh_system_heap_error_handler, NULL);
eventOS_scheduler_mutex_wait();
net_init_core();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ip6string.h" //ip6tos
#include "nsdynmemLIB.h"
#include "include/nd_tasklet.h"
#include "include/static_config.h"
#include "include/mesh_system.h"
#include "ns_event_loop.h"

Expand Down Expand Up @@ -87,15 +86,15 @@ void nd_tasklet_trace_bootstrap_info(void);

static void initialize_channel_list(void)
{
uint32_t channel = MBED_MESH_API_6LOWPAN_ND_CHANNEL;
uint32_t channel = MBED_CONF_MBED_MESH_API_6LOWPAN_ND_CHANNEL;

const int_fast8_t word_index = channel / 32;
const int_fast8_t bit_index = channel % 32;

memset(&tasklet_data_ptr->channel_list, 0, sizeof(tasklet_data_ptr->channel_list));

tasklet_data_ptr->channel_list.channel_page = (channel_page_e)MBED_MESH_API_6LOWPAN_ND_CHANNEL_PAGE;
tasklet_data_ptr->channel_list.channel_mask[0] = MBED_MESH_API_6LOWPAN_ND_CHANNEL_MASK;
tasklet_data_ptr->channel_list.channel_page = (channel_page_e)MBED_CONF_MBED_MESH_API_6LOWPAN_ND_CHANNEL_PAGE;
tasklet_data_ptr->channel_list.channel_mask[0] = MBED_CONF_MBED_MESH_API_6LOWPAN_ND_CHANNEL_MASK;

if (channel > 0) {
memset(&tasklet_data_ptr->channel_list.channel_mask, 0, sizeof(tasklet_data_ptr->channel_list.channel_mask));
Expand Down Expand Up @@ -233,13 +232,13 @@ void nd_tasklet_configure_and_connect_to_network(void)
tasklet_data_ptr->network_interface_id, tasklet_data_ptr->mode,
NET_6LOWPAN_ND_WITH_MLE);

sec_mode = STR(MBED_MESH_API_6LOWPAN_ND_SECURITY_MODE);
sec_mode = STR(MBED_CONF_MBED_MESH_API_6LOWPAN_ND_SECURITY_MODE);

if (strcmp(sec_mode, "PSK") == 0) {
tr_debug("Using PSK security mode.");
tasklet_data_ptr->sec_mode = NET_SEC_MODE_PSK_LINK_SECURITY;
tasklet_data_ptr->psk_sec_info.key_id = MBED_MESH_API_6LOWPAN_ND_PSK_KEY_ID;
memcpy(tasklet_data_ptr->psk_sec_info.security_key, (const uint8_t[16])MBED_MESH_API_6LOWPAN_ND_PSK_KEY, 16);
tasklet_data_ptr->psk_sec_info.key_id = MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PSK_KEY_ID;
memcpy(tasklet_data_ptr->psk_sec_info.security_key, (const uint8_t[16])MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PSK_KEY, 16);
} else {
tr_debug("Link-layer security NOT enabled.");
tasklet_data_ptr->sec_mode = NET_SEC_MODE_NO_LINK_SECURITY;
Expand All @@ -249,7 +248,7 @@ void nd_tasklet_configure_and_connect_to_network(void)
arm_nwk_link_layer_security_mode(
tasklet_data_ptr->network_interface_id,
tasklet_data_ptr->sec_mode,
MBED_MESH_API_6LOWPAN_ND_SEC_LEVEL,
MBED_CONF_MBED_MESH_API_6LOWPAN_ND_SEC_LEVEL,
&tasklet_data_ptr->psk_sec_info);

// configure scan parameters
Expand All @@ -264,7 +263,7 @@ void nd_tasklet_configure_and_connect_to_network(void)

arm_nwk_6lowpan_link_panid_filter_for_nwk_scan(
tasklet_data_ptr->network_interface_id,
MBED_MESH_API_6LOWPAN_ND_PANID_FILTER);
MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PANID_FILTER);

status = arm_nwk_interface_up(tasklet_data_ptr->network_interface_id);
if (status >= 0) {
Expand Down
Loading

0 comments on commit c776eaa

Please sign in to comment.