Skip to content

Commit 1250ceb

Browse files
author
Mika Leppänen
committed
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.
1 parent 68f5739 commit 1250ceb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

features/nanostack/mbed-mesh-api/source/thread_tasklet.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ typedef struct {
8484

8585
/* Tasklet data */
8686
static thread_tasklet_data_str_t *thread_tasklet_data_ptr = NULL;
87+
static mac_api_t *mac_api = NULL;
8788
static device_configuration_s device_configuration;
8889

8990
/* private function prototypes */
@@ -216,7 +217,8 @@ void thread_tasklet_parse_network_event(arm_event_s *event)
216217
break;
217218
}
218219

219-
if (thread_tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY) {
220+
if (thread_tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY &&
221+
thread_tasklet_data_ptr->nwk_if_id != INVALID_INTERFACE_ID) {
220222
// Set 5s timer for a new network scan
221223
eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP,
222224
ARM_LIB_SYSTEM_TIMER_EVENT,
@@ -465,8 +467,10 @@ int8_t thread_tasklet_network_init(int8_t device_id)
465467
storage_sizes.key_description_table_size = 6;
466468
storage_sizes.key_lookup_size = 1;
467469
storage_sizes.key_usage_size = 3;
468-
mac_api_t *api = ns_sw_mac_create(device_id, &storage_sizes);
469-
return arm_nwk_interface_lowpan_init(api, INTERFACE_NAME);
470+
if (!mac_api) {
471+
mac_api = ns_sw_mac_create(device_id, &storage_sizes);
472+
}
473+
return arm_nwk_interface_lowpan_init(mac_api, INTERFACE_NAME);
470474
}
471475

472476
void thread_tasklet_device_eui64_set(const uint8_t *eui64)

0 commit comments

Comments
 (0)