Skip to content

Corrected mbed-mesh-api thread/6lowpan tasklets interface disconnect/connect #7878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions features/nanostack/mbed-mesh-api/source/nd_tasklet.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ typedef struct {
net_6lowpan_mode_e mode;
net_6lowpan_link_layer_sec_mode_e sec_mode;
net_link_layer_psk_security_info_s psk_sec_info;
int8_t node_main_tasklet_id;
int8_t network_interface_id;
int8_t tasklet;
} tasklet_data_str_t;
Expand Down Expand Up @@ -133,13 +132,12 @@ void nd_tasklet_main(arm_event_s *event)
* The event is delivered when the NanoStack OS is running fine.
* This event should be delivered ONLY ONCE.
*/
tasklet_data_ptr->node_main_tasklet_id = event->receiver;
mesh_system_send_connect_event(tasklet_data_ptr->tasklet);
break;

case ARM_LIB_SYSTEM_TIMER_EVENT:
eventOS_event_timer_cancel(event->event_id,
tasklet_data_ptr->node_main_tasklet_id);
tasklet_data_ptr->tasklet);

if (event->event_id == TIMER_EVENT_START_BOOTSTRAP) {
tr_debug("Restart bootstrap");
Expand Down Expand Up @@ -215,12 +213,14 @@ void nd_tasklet_parse_network_event(arm_event_s *event)
break;
}

if (tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY) {
if (tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY &&
tasklet_data_ptr->network_interface_id != INVALID_INTERFACE_ID) {
// Set 5s timer for new network scan
eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP,
ARM_LIB_SYSTEM_TIMER_EVENT,
tasklet_data_ptr->node_main_tasklet_id,
tasklet_data_ptr->tasklet,
5000);

}
}

Expand Down Expand Up @@ -386,7 +386,10 @@ int8_t nd_tasklet_connect(mesh_interface_cb callback, int8_t nwk_interface_id)
}
} else {
tasklet_data_ptr->tasklet = tasklet_id;
mesh_system_send_connect_event(tasklet_data_ptr->tasklet);
eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP,
ARM_LIB_SYSTEM_TIMER_EVENT,
tasklet_data_ptr->tasklet,
500);
}

return tasklet_data_ptr->tasklet;
Expand Down
10 changes: 7 additions & 3 deletions features/nanostack/mbed-mesh-api/source/thread_tasklet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down