Skip to content

Commit

Permalink
Wi-sun FHSS Management update
Browse files Browse the repository at this point in the history
Added validation for given dwell time that it must by min 15 when it is not 0.

Wi-sun boot is now only activated when FHSS config is changed.

Change-Id: I9462d91f8185611b16b2b899b6e195f854cc455c
  • Loading branch information
Juha Heiskanen committed Jan 27, 2020
1 parent 2ff90e6 commit a043f8d
Showing 1 changed file with 62 additions and 15 deletions.
77 changes: 62 additions & 15 deletions source/6LoWPAN/ws/ws_management_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,32 @@ int ws_management_fhss_timing_configure(
if (!cur || !ws_info(cur)) {
return -1;
}
if (fhss_uc_dwell_interval > 0) {

if (fhss_uc_dwell_interval && fhss_uc_dwell_interval < 15) {
return -2;
}

if (fhss_bc_dwell_interval && fhss_bc_dwell_interval < 15) {
return -2;
}

bool updated_configure = false;

if (fhss_uc_dwell_interval > 0 && cur->ws_info->fhss_uc_dwell_interval != fhss_uc_dwell_interval) {
cur->ws_info->fhss_uc_dwell_interval = fhss_uc_dwell_interval;
updated_configure = true;
}
if (fhss_broadcast_interval > 0) {
if (fhss_broadcast_interval > 0 && cur->ws_info->fhss_bc_interval != fhss_broadcast_interval) {
cur->ws_info->fhss_bc_interval = fhss_broadcast_interval;

updated_configure = true;
}
if (fhss_bc_dwell_interval > 0) {
if (fhss_bc_dwell_interval > 0 && cur->ws_info->fhss_bc_dwell_interval != fhss_bc_dwell_interval) {
cur->ws_info->fhss_bc_dwell_interval = fhss_bc_dwell_interval;

updated_configure = true;
}

// if settings change reset_restart for the settings needed
if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) {
if (updated_configure && (cur->lowpan_info & INTERFACE_NWK_ACTIVE)) {
// bootstrap active need to restart
ws_bootstrap_restart(interface_id);
}
Expand All @@ -259,23 +271,38 @@ int ws_management_fhss_unicast_channel_function_configure(
return -2;
}

if (dwell_interval && dwell_interval < 15) {
return -2;
}

if (channel_function == WS_FIXED_CHANNEL && fixed_channel == 0xffff) {
fixed_channel = 0;
tr_warn("Fixed channel not configured. Set to 0");
}

bool updated_config = false;

if (cur->ws_info->fhss_uc_channel_function != channel_function) {
cur->ws_info->fhss_uc_channel_function = channel_function;
updated_config = true;
}

cur->ws_info->fhss_uc_channel_function = channel_function;
if (cur->ws_info->fhss_uc_channel_function == WS_FIXED_CHANNEL) {
cur->ws_info->fhss_uc_fixed_channel = fixed_channel;
if (cur->ws_info->fhss_uc_fixed_channel != fixed_channel) {
cur->ws_info->fhss_uc_fixed_channel = fixed_channel;
updated_config = true;
}
} else {
cur->ws_info->fhss_uc_fixed_channel = 0xffff;
}

cur->ws_info->fhss_uc_dwell_interval = dwell_interval;
if (dwell_interval && cur->ws_info->fhss_uc_dwell_interval != dwell_interval) {
cur->ws_info->fhss_uc_dwell_interval = dwell_interval;
updated_config = true;
}

// if settings change reset_restart for the settings needed
if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) {
if (updated_config && (cur->lowpan_info & INTERFACE_NWK_ACTIVE)) {
// bootstrap active need to restart
ws_bootstrap_restart(interface_id);
}
Expand Down Expand Up @@ -303,23 +330,43 @@ int ws_management_fhss_broadcast_channel_function_configure(
return -2;
}

if (dwell_interval && dwell_interval < 15) {
return -2;
}

if (channel_function == WS_FIXED_CHANNEL && fixed_channel == 0xffff) {
fixed_channel = 0;
tr_warn("Fixed channel not configured. Set to 0");
}

cur->ws_info->fhss_bc_channel_function = channel_function;
bool updated_config = false;

if (cur->ws_info->fhss_bc_channel_function != channel_function) {
cur->ws_info->fhss_bc_channel_function = channel_function;
updated_config = true;
}

if (cur->ws_info->fhss_bc_channel_function == WS_FIXED_CHANNEL) {
cur->ws_info->fhss_bc_fixed_channel = fixed_channel;
if (cur->ws_info->fhss_bc_fixed_channel != fixed_channel) {
cur->ws_info->fhss_bc_fixed_channel = fixed_channel;
updated_config = true;
}
} else {
cur->ws_info->fhss_bc_fixed_channel = 0xffff;
}

cur->ws_info->fhss_bc_dwell_interval = dwell_interval;
cur->ws_info->fhss_bc_interval = broadcast_interval;
if (dwell_interval > 0 && cur->ws_info->fhss_bc_dwell_interval != dwell_interval) {
cur->ws_info->fhss_bc_dwell_interval = dwell_interval;
updated_config = true;
}

if (broadcast_interval > 0 && cur->ws_info->fhss_bc_interval != broadcast_interval) {
cur->ws_info->fhss_bc_interval = broadcast_interval;
updated_config = true;
}

// if settings change reset_restart for the settings needed
if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) {
if (updated_config && (cur->lowpan_info & INTERFACE_NWK_ACTIVE)) {
// bootstrap active need to restart
ws_bootstrap_restart(interface_id);
}
Expand Down

0 comments on commit a043f8d

Please sign in to comment.