Merge pull request #7878 from mikaleppanen/mesh_conn_corr

Corrected mbed-mesh-api thread/6lowpan tasklets interface disconnect/connect
pull/7909/head
Martin Kojtal 2018-08-28 11:55:30 +02:00 committed by GitHub
commit 665f10e1be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View File

@ -64,7 +64,6 @@ typedef struct {
net_6lowpan_mode_e mode; net_6lowpan_mode_e mode;
net_6lowpan_link_layer_sec_mode_e sec_mode; net_6lowpan_link_layer_sec_mode_e sec_mode;
net_link_layer_psk_security_info_s psk_sec_info; net_link_layer_psk_security_info_s psk_sec_info;
int8_t node_main_tasklet_id;
int8_t network_interface_id; int8_t network_interface_id;
int8_t tasklet; int8_t tasklet;
} tasklet_data_str_t; } tasklet_data_str_t;
@ -133,13 +132,12 @@ void nd_tasklet_main(arm_event_s *event)
* The event is delivered when the NanoStack OS is running fine. * The event is delivered when the NanoStack OS is running fine.
* This event should be delivered ONLY ONCE. * 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); mesh_system_send_connect_event(tasklet_data_ptr->tasklet);
break; break;
case ARM_LIB_SYSTEM_TIMER_EVENT: case ARM_LIB_SYSTEM_TIMER_EVENT:
eventOS_event_timer_cancel(event->event_id, 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) { if (event->event_id == TIMER_EVENT_START_BOOTSTRAP) {
tr_debug("Restart bootstrap"); tr_debug("Restart bootstrap");
@ -215,12 +213,14 @@ void nd_tasklet_parse_network_event(arm_event_s *event)
break; 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 // Set 5s timer for new network scan
eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP, eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP,
ARM_LIB_SYSTEM_TIMER_EVENT, ARM_LIB_SYSTEM_TIMER_EVENT,
tasklet_data_ptr->node_main_tasklet_id, tasklet_data_ptr->tasklet,
5000); 5000);
} }
} }
@ -386,7 +386,10 @@ int8_t nd_tasklet_connect(mesh_interface_cb callback, int8_t nwk_interface_id)
} }
} else { } else {
tasklet_data_ptr->tasklet = tasklet_id; 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; return tasklet_data_ptr->tasklet;

View File

@ -84,6 +84,7 @@ typedef struct {
/* Tasklet data */ /* Tasklet data */
static thread_tasklet_data_str_t *thread_tasklet_data_ptr = NULL; static thread_tasklet_data_str_t *thread_tasklet_data_ptr = NULL;
static mac_api_t *mac_api = NULL;
static device_configuration_s device_configuration; static device_configuration_s device_configuration;
/* private function prototypes */ /* private function prototypes */
@ -216,7 +217,8 @@ void thread_tasklet_parse_network_event(arm_event_s *event)
break; 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 // Set 5s timer for a new network scan
eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP, eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP,
ARM_LIB_SYSTEM_TIMER_EVENT, 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_description_table_size = 6;
storage_sizes.key_lookup_size = 1; storage_sizes.key_lookup_size = 1;
storage_sizes.key_usage_size = 3; storage_sizes.key_usage_size = 3;
mac_api_t *api = ns_sw_mac_create(device_id, &storage_sizes); if (!mac_api) {
return arm_nwk_interface_lowpan_init(api, INTERFACE_NAME); 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) void thread_tasklet_device_eui64_set(const uint8_t *eui64)