Skip to content

Commit

Permalink
Parent select and pan config handler update
Browse files Browse the repository at this point in the history
We will check that we have know minimal BC timing info for select parent.
If own BC shedules is possible we must know shedule before check parent.

Pan config is now update primary parent even version number is same.
Pan config new version also synch FHSS temporary to latest sended Pan config.

Change-Id: I57172319a7d20eadb405bdc78087c03e9ee219f0
  • Loading branch information
Juha Heiskanen committed Sep 19, 2018
1 parent a2ef56a commit 02fce65
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 19 deletions.
70 changes: 51 additions & 19 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}
Expand Down
2 changes: 2 additions & 0 deletions source/6LoWPAN/ws/ws_neighbor_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions source/6LoWPAN/ws/ws_neighbor_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down

0 comments on commit 02fce65

Please sign in to comment.