diff --git a/source/6LoWPAN/ws/ws_bootstrap.c b/source/6LoWPAN/ws/ws_bootstrap.c index b241270cdcc..aedd1ec1077 100644 --- a/source/6LoWPAN/ws/ws_bootstrap.c +++ b/source/6LoWPAN/ws/ws_bootstrap.c @@ -451,28 +451,30 @@ static int8_t ws_fhss_enable(protocol_interface_info_entry_t *cur) */ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry *cur, llc_neighbour_req_t *neighbor_info) { - if (neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_dwell_interval == 0 || - neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_interval == 0) { - tr_debug("Parent synch fail by missing BT information"); + + fhss_ws_configuration_t fhss_configuration; + if (!neighbor_info->ws_neighbor->broadcast_timing_info_stored) { + tr_error("No BC timing info for set new parent"); return; } - - fhss_ws_configuration_t fhss_configuration; memcpy(&fhss_configuration, ns_fhss_ws_configuration_get(cur->ws_info->fhss_api), sizeof(fhss_ws_configuration_t)); ws_fhss_set_defaults(cur, &fhss_configuration); // Learning broadcast network configuration - fhss_configuration.ws_bc_channel_function = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_channel_function; - if (fhss_configuration.ws_bc_channel_function == WS_FIXED_CHANNEL) { - cur->ws_info->hopping_schdule.bc_fixed_channel = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.fixed_channel; + if (neighbor_info->ws_neighbor->broadcast_shedule_info_stored) { + fhss_configuration.ws_bc_channel_function = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_channel_function; + if (fhss_configuration.ws_bc_channel_function == WS_FIXED_CHANNEL) { + cur->ws_info->hopping_schdule.bc_fixed_channel = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.fixed_channel; + } + fhss_configuration.bsi = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_schedule_id; + fhss_configuration.fhss_bc_dwell_interval = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_dwell_interval; + fhss_configuration.fhss_broadcast_interval = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_interval; + fhss_configuration.broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel; + } - fhss_configuration.bsi = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_schedule_id; - fhss_configuration.fhss_bc_dwell_interval = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_dwell_interval; - fhss_configuration.fhss_broadcast_interval = neighbor_info->ws_neighbor->fhss_data.bc_timing_info.broadcast_interval; fhss_configuration.unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel; - fhss_configuration.broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel; ns_fhss_ws_configuration_set(cur->ws_info->fhss_api, &fhss_configuration); // We have broadcast schedule set up set the broadcast parent schedule @@ -506,11 +508,32 @@ uint16_t ws_etx_read(protocol_interface_info_entry_t *interface, addrtype_t addr ws_neighbor_class_entry_t *ws_neighbour = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, attribute_index); etx_storage_t *etx_entry = etx_storage_entry_get(interface->id, attribute_index); - if (!ws_neighbour || !etx_entry || etx_entry->etx_samples < 1 || - !ws_neighbour->candidate_parent) { - // if RSL value is not good enough candidate parent flag is removed and device not accepted as parent - //tr_debug("ws_etx_read not valid parent"); - return 0xffff; + if (interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) { + if (!ws_neighbour || !etx_entry) { + return 0xffff; + } + } else { + + if (!ws_neighbour || !etx_entry || etx_entry->etx_samples < 1 || + !ws_neighbour->candidate_parent) { + // if RSL value is not good enough candidate parent flag is removed and device not accepted as parent + //tr_debug("ws_etx_read not valid parent"); + return 0xffff; + } + + //If we are not following gbobal Broadcast synch + if (!interface->ws_info->pan_information.use_parent_bs) { + //We must know both information's here + if (!ws_neighbour->broadcast_shedule_info_stored || + !ws_neighbour->broadcast_timing_info_stored) { + return 0xffff; + } + } else { + if (!ws_neighbour->broadcast_timing_info_stored) { + //Global shedule is stored already + return 0xffff; + } + } } etx = etx_local_etx_read(interface->id,attribute_index); @@ -875,12 +898,21 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry return; } } + + } if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) { //Border router does not learn network information return; } + + //Update synch to primary parent allways to update broadcast shedule and timing + if (neighbor_info.neighbor->link_role == PRIORITY_PARENT_NEIGHBOUR) { + // RPL priority parent configuration we must update FHSS data + ws_bootstrap_primary_parent_set(cur, &neighbor_info); + } + if (cur->ws_info->configuration_learned && cur->ws_info->pan_information.pan_version == pan_version) { // No new information @@ -907,8 +939,8 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry // set neighbor as priority parent clear if there is others protocol_6lowpan_neighbor_priority_clear_all(cur->id, PRIORITY_1ST); neighbor_info.neighbor->link_role = PRIORITY_PARENT_NEIGHBOUR; - } else if (neighbor_info.neighbor->link_role == PRIORITY_PARENT_NEIGHBOUR) { - // RPL priority parent configuration we must update FHSS data + } else if (neighbor_info.neighbor->link_role != PRIORITY_PARENT_NEIGHBOUR) { + //This cuold affect serious problem if BC parameters are changed ws_bootstrap_primary_parent_set(cur, &neighbor_info); } } diff --git a/source/6LoWPAN/ws/ws_neighbor_class.c b/source/6LoWPAN/ws/ws_neighbor_class.c index 5c0b2fd36d4..232ef7650e5 100644 --- a/source/6LoWPAN/ws/ws_neighbor_class.c +++ b/source/6LoWPAN/ws/ws_neighbor_class.c @@ -104,6 +104,7 @@ void ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor_class_entry_t * void ws_neighbor_class_neighbor_broadcast_time_info_update(ws_neighbor_class_entry_t *ws_neighbor, ws_bt_ie_t *ws_bt_ie, uint32_t timestamp) { + ws_neighbor->broadcast_timing_info_stored = true; ws_neighbor->fhss_data.bc_timing_info.bt_rx_timestamp = timestamp; ws_neighbor->fhss_data.bc_timing_info.broadcast_slot = ws_bt_ie->broadcast_slot_number; ws_neighbor->fhss_data.bc_timing_info.broadcast_interval_offset = ws_bt_ie->broadcast_interval_offset; @@ -112,6 +113,7 @@ void ws_neighbor_class_neighbor_broadcast_time_info_update(ws_neighbor_class_ent void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_bs_ie_t *ws_bs_ie) { + ws_neighbor->broadcast_shedule_info_stored = true; ws_neighbor->fhss_data.bc_timing_info.broadcast_channel_function = ws_bs_ie->channel_function; if (ws_bs_ie->channel_function == WS_FIXED_CHANNEL) { ws_neighbor->fhss_data.bc_timing_info.fixed_channel = ws_bs_ie->function.zero.fixed_channel; diff --git a/source/6LoWPAN/ws/ws_neighbor_class.h b/source/6LoWPAN/ws/ws_neighbor_class.h index ed1adf89af8..0f5bbd9110c 100644 --- a/source/6LoWPAN/ws/ws_neighbor_class.h +++ b/source/6LoWPAN/ws/ws_neighbor_class.h @@ -28,6 +28,8 @@ typedef struct ws_neighbor_class_entry { uint16_t rsl_in; /*!< RSL EWMA heard from neighbour*/ uint16_t rsl_out; /*!< RSL EWMA heard by neighbour*/ bool candidate_parent:1; + bool broadcast_timing_info_stored:1; + bool broadcast_shedule_info_stored:1; } ws_neighbor_class_entry_t; /**