Skip to content

Commit

Permalink
FHSS: Added force synch boolean in parent set
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Oct 8, 2018
1 parent 9d79ca9 commit 33afc9c
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 17 deletions.
3 changes: 2 additions & 1 deletion nanostack/fhss_ws_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ typedef fhss_ws_neighbor_timing_info_t *fhss_get_neighbor_info(const fhss_api_t
* @param fhss_api FHSS instance.
* @param eui64 EUI-64 address of parent.
* @param bc_timing_info Pointer to parent broadcast timing/hopping schedule info.
* @param force_synch If false, synchronization is done only if minimum (internal) synchronization interval is exceed.
* @return 0 on success, -1 on fail.
*/
extern int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info);
extern int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info, const bool force_synch);

/**
* @brief Remove parent which was set by ns_fhss_ws_set_parent function.
Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry
ns_fhss_ws_configuration_set(cur->ws_info->fhss_api, &fhss_configuration);

// We have broadcast schedule set up set the broadcast parent schedule
ns_fhss_ws_set_parent(cur->ws_info->fhss_api, neighbor_info->neighbor->mac64, &neighbor_info->ws_neighbor->fhss_data.bc_timing_info);
ns_fhss_ws_set_parent(cur->ws_info->fhss_api, neighbor_info->neighbor->mac64, &neighbor_info->ws_neighbor->fhss_data.bc_timing_info, true);

// Update LLC to follow updated fhss settings
ws_bootstrap_llc_hopping_update(cur,&fhss_configuration);
Expand Down
4 changes: 1 addition & 3 deletions source/6LoWPAN/ws/ws_llc_data_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,16 +520,14 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, &ws_utt, data->timestamp);
if (us_ie_inline) {
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, &us_ie);


}
//Update BT if it is part of message
ws_bt_ie_t ws_bt;
if (ws_wh_bt_read(ie_ext->headerIeList, ie_ext->headerIeListLength, &ws_bt)) {
ws_neighbor_class_neighbor_broadcast_time_info_update(neighbor_info.ws_neighbor, &ws_bt, data->timestamp);
if (neighbor_info.neighbor->link_role == PRIORITY_PARENT_NEIGHBOUR) {
// We have broadcast schedule set up set the broadcast parent schedule
ns_fhss_ws_set_parent(interface->ws_info->fhss_api, neighbor_info.neighbor->mac64, &neighbor_info.ws_neighbor->fhss_data.bc_timing_info);
ns_fhss_ws_set_parent(interface->ws_info->fhss_api, neighbor_info.neighbor->mac64, &neighbor_info.ws_neighbor->fhss_data.bc_timing_info, false);
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/Service_Libs/fhss/fhss_configuration_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ fhss_api_t *ns_fhss_ws_create(const fhss_ws_configuration_t *fhss_configuration,
return this;
}

int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info)
int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info, const bool force_synch)
{
fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api);
if (!fhss_structure || !eui64 || !bc_timing_info) {
return -1;
}
return fhss_ws_set_parent(fhss_structure, eui64, bc_timing_info);
return fhss_ws_set_parent(fhss_structure, eui64, bc_timing_info, force_synch);
}

int ns_fhss_ws_remove_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8])
Expand Down
4 changes: 2 additions & 2 deletions source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
return 0;
}

int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info)
int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info, const bool force_synch)
{
(void) eui64;
if (!fhss_structure->ws) {
Expand All @@ -667,7 +667,7 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
if (!bc_timing_info->broadcast_interval || !bc_timing_info->broadcast_dwell_interval) {
return -1;
}
if (((uint32_t)fhss_structure->ws->min_synch_interval*1000000) > (fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - fhss_structure->ws->synchronization_time)) {
if ((((uint32_t)fhss_structure->ws->min_synch_interval*1000000) > (fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - fhss_structure->ws->synchronization_time)) && !force_synch) {
return 0;
}
fhss_structure->ws->synchronization_time = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api);
Expand Down
2 changes: 1 addition & 1 deletion source/Service_Libs/fhss/fhss_ws.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct fhss_ws

fhss_structure_t *fhss_ws_enable(fhss_api_t *fhss_api, const fhss_ws_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer);
int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure);
int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info);
int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info, const bool force_synch);
int fhss_ws_remove_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8]);
int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_configuration_t *fhss_configuration);
int fhss_ws_set_hop_count(fhss_structure_t *fhss_structure, const uint8_t hop_count);
Expand Down
2 changes: 1 addition & 1 deletion source/Service_Libs/fhss/fhss_ws_empty_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
return -1;
}

int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info)
int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info, const bool force_synch)
{
(void) fhss_structure;
(void) eui64;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ bool test_ns_fhss_ws_set_parent()
broadcast_timing_info_t bc_timing_info;
// Test without api
fhss_common_stub.bool_value = false;
if (-1 != ns_fhss_ws_set_parent(NULL, dest_address, &bc_timing_info)) {
if (-1 != ns_fhss_ws_set_parent(NULL, dest_address, &bc_timing_info, false)) {
return false;
}
// Test success
fhss_common_stub.bool_value = true;
if (0 != ns_fhss_ws_set_parent(&api, dest_address, &bc_timing_info)) {
if (0 != ns_fhss_ws_set_parent(&api, dest_address, &bc_timing_info, false)) {
return false;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions test/nanostack/unittest/service_libs/fhss_ws/test_fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ bool test_fhss_ws_set_parent()
// Test without WS enabled FHSS
fhss_structure_t fake_fhss_structure;
memset(&fake_fhss_structure, 0, sizeof(fhss_structure_t));
if (-1 != fhss_ws_set_parent(&fake_fhss_structure, dest_address, &bc_timing_info)) {
if (-1 != fhss_ws_set_parent(&fake_fhss_structure, dest_address, &bc_timing_info, true)) {
return false;
}

Expand All @@ -637,7 +637,7 @@ bool test_fhss_ws_set_parent()
bc_timing_info.broadcast_schedule_id = 1;
bc_timing_info.broadcast_slot = 10;
bc_timing_info.bt_rx_timestamp = 100000;
if (0 != fhss_ws_set_parent(&fhss_common_stub.fhss_struct, dest_address, &bc_timing_info)
if (0 != fhss_ws_set_parent(&fhss_common_stub.fhss_struct, dest_address, &bc_timing_info, true)
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_channel_function != WS_TR51CF)
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_dwell_interval != 250)
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_interval != 1000)
Expand Down
2 changes: 1 addition & 1 deletion test/nanostack/unittest/stub/fhss_config_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fhss_api_t *ns_fhss_create(const fhss_configuration_t *fhss_configuration, const
return &fhss_config_stub.fhss_api_ptr;
}

int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info)
int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info, const bool force_synch)
{
return 0;
}
2 changes: 1 addition & 1 deletion test/nanostack/unittest/stub/fhss_ws_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fhss_structure_t *fhss_ws_enable(fhss_api_t *fhss_api, const fhss_ws_configurati
return &fhss_ws_stub.fhss_struct;
}

int fhss_ws_set_parent(fhss_structure_t *fhss_structure, uint8_t eui64[8], broadcast_timing_info_t *bc_timing_info)
int fhss_ws_set_parent(fhss_structure_t *fhss_structure, uint8_t eui64[8], broadcast_timing_info_t *bc_timing_info, const bool force_synch)
{
return 0;
}
Expand Down

0 comments on commit 33afc9c

Please sign in to comment.