From 1250ceb82c714bcd54ec8ebb6cc92c0db08c66f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20Lepp=C3=A4nen?= Date: Wed, 22 Aug 2018 12:23:29 +0300 Subject: [PATCH] Corrected thread tasklet during interface disconnect/connect Added check for valid interface ID to network scan timer start so that it is not triggered after disconnect. Added variable for mac api so that it is not tried to set again after re-connecting. --- .../nanostack/mbed-mesh-api/source/thread_tasklet.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/features/nanostack/mbed-mesh-api/source/thread_tasklet.c b/features/nanostack/mbed-mesh-api/source/thread_tasklet.c index 8859c48ef3..de7a091d14 100644 --- a/features/nanostack/mbed-mesh-api/source/thread_tasklet.c +++ b/features/nanostack/mbed-mesh-api/source/thread_tasklet.c @@ -84,6 +84,7 @@ typedef struct { /* Tasklet data */ static thread_tasklet_data_str_t *thread_tasklet_data_ptr = NULL; +static mac_api_t *mac_api = NULL; static device_configuration_s device_configuration; /* private function prototypes */ @@ -216,7 +217,8 @@ void thread_tasklet_parse_network_event(arm_event_s *event) break; } - if (thread_tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY) { + if (thread_tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY && + thread_tasklet_data_ptr->nwk_if_id != INVALID_INTERFACE_ID) { // Set 5s timer for a new network scan eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP, ARM_LIB_SYSTEM_TIMER_EVENT, @@ -465,8 +467,10 @@ int8_t thread_tasklet_network_init(int8_t device_id) storage_sizes.key_description_table_size = 6; storage_sizes.key_lookup_size = 1; storage_sizes.key_usage_size = 3; - mac_api_t *api = ns_sw_mac_create(device_id, &storage_sizes); - return arm_nwk_interface_lowpan_init(api, INTERFACE_NAME); + if (!mac_api) { + mac_api = ns_sw_mac_create(device_id, &storage_sizes); + } + return arm_nwk_interface_lowpan_init(mac_api, INTERFACE_NAME); } void thread_tasklet_device_eui64_set(const uint8_t *eui64)