Skip to content

Commit

Permalink
Added channel mask size to FHSS configuration (ARMmbed#2536)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso authored Jan 8, 2021
1 parent 20e79e0 commit 944f934
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* MAC layer send ACK even buffer allocation fails.

### Bugfix
*
* Use all allowed channels with Brazil domain

## Release v12.7.0 (14-12-2020)

Expand Down
3 changes: 3 additions & 0 deletions nanostack/fhss_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ typedef struct fhss_ws_configuration {
/** Wi-SUN specific unicast channel mask */
uint32_t unicast_channel_mask[8];

/** Channel mask size */
uint16_t channel_mask_size;

/** Vendor defined channel function. */
fhss_vendor_defined_cf *vendor_defined_cf;

Expand Down
1 change: 1 addition & 0 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ static uint8_t ws_generate_exluded_channel_list_from_active_channels(ws_excluded

static void ws_fhss_configure_channel_masks(protocol_interface_info_entry_t *cur, fhss_ws_configuration_t *fhss_configuration)
{
fhss_configuration->channel_mask_size = cur->ws_info->hopping_schdule.number_of_channels;
ws_generate_channel_list(fhss_configuration->channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain, cur->ws_info->hopping_schdule.operating_class, cur->ws_info->hopping_schdule.channel_plan_id);
ws_generate_channel_list(fhss_configuration->unicast_channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain, cur->ws_info->hopping_schdule.operating_class, cur->ws_info->hopping_schdule.channel_plan_id);
// using bitwise AND operation for user set channel mask to remove channels not allowed in this device
Expand Down
1 change: 1 addition & 0 deletions source/Service_Libs/fhss/fhss_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct fhss_structure {
uint8_t active_fhss_events;
uint16_t number_of_channels;
uint16_t number_of_uc_channels;
uint16_t number_of_bc_channels;
uint16_t optimal_packet_length;
fhss_states fhss_state;
uint32_t fhss_timeout;
Expand Down
23 changes: 12 additions & 11 deletions source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ static int32_t fhss_ws_calc_bc_channel(fhss_structure_t *fhss_structure)
int32_t next_channel = fhss_structure->ws->fhss_configuration.broadcast_fixed_channel;

if (fhss_structure->ws->fhss_configuration.ws_bc_channel_function == WS_TR51CF) {
next_channel = tr51_get_bc_channel_index(fhss_structure->ws->tr51_channel_table, fhss_structure->ws->tr51_output_table, fhss_structure->ws->bc_slot, fhss_structure->ws->fhss_configuration.bsi, fhss_structure->number_of_channels, NULL);
next_channel = tr51_get_bc_channel_index(fhss_structure->ws->tr51_channel_table, fhss_structure->ws->tr51_output_table, fhss_structure->ws->bc_slot, fhss_structure->ws->fhss_configuration.bsi, fhss_structure->number_of_bc_channels, NULL);
next_channel = fhss_channel_index_from_mask(fhss_structure->ws->fhss_configuration.channel_mask, next_channel, fhss_structure->number_of_channels);
if (++fhss_structure->ws->bc_slot == fhss_structure->number_of_channels) {
if (++fhss_structure->ws->bc_slot == fhss_structure->number_of_bc_channels) {
fhss_structure->ws->bc_slot = 0;
}
} else if (fhss_structure->ws->fhss_configuration.ws_bc_channel_function == WS_DH1CF) {
fhss_structure->ws->bc_slot++;
next_channel = dh1cf_get_bc_channel_index(fhss_structure->ws->bc_slot, fhss_structure->ws->fhss_configuration.bsi, fhss_structure->number_of_channels);
next_channel = dh1cf_get_bc_channel_index(fhss_structure->ws->bc_slot, fhss_structure->ws->fhss_configuration.bsi, fhss_structure->number_of_bc_channels);
next_channel = fhss_channel_index_from_mask(fhss_structure->ws->fhss_configuration.channel_mask, next_channel, fhss_structure->number_of_channels);
} else if (fhss_structure->ws->fhss_configuration.ws_bc_channel_function == WS_VENDOR_DEF_CF) {
if (fhss_structure->ws->fhss_configuration.vendor_defined_cf) {
Expand Down Expand Up @@ -343,7 +343,7 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
}

if (fhss_structure->ws->fhss_configuration.ws_bc_channel_function == WS_TR51CF) {
fhss_structure->ws->bc_slot %= fhss_structure->number_of_channels;
fhss_structure->ws->bc_slot %= fhss_structure->number_of_bc_channels;
}

if (fhss_structure->ws->is_on_bc_channel == false) {
Expand Down Expand Up @@ -1086,21 +1086,21 @@ int fhss_ws_remove_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[

int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_configuration_t *fhss_configuration)
{
int channel_count = channel_list_count_channels(fhss_configuration->channel_mask);
int channel_count_bc = channel_list_count_channels(fhss_configuration->channel_mask);
int channel_count_uc = channel_list_count_channels(fhss_configuration->unicast_channel_mask);
if (channel_count <= 0) {
if (channel_count_bc <= 0 || fhss_configuration->channel_mask_size == 0) {
return -1;
}

if (fhss_structure->number_of_channels < channel_count ||
if (fhss_structure->number_of_bc_channels < channel_count_bc ||
(channel_count_uc && fhss_structure->number_of_uc_channels < channel_count_uc)) {
// Channel amount changed to largeneed to reallocate channel table
ns_dyn_mem_free(fhss_structure->ws->tr51_channel_table);
fhss_structure->ws->tr51_channel_table = NULL;
ns_dyn_mem_free(fhss_structure->ws->tr51_output_table);
fhss_structure->ws->tr51_output_table = NULL;

if (fhss_ws_manage_channel_table_allocation(fhss_structure, channel_count_uc > channel_count ? channel_count_uc : channel_count)) {
if (fhss_ws_manage_channel_table_allocation(fhss_structure, channel_count_uc > channel_count_bc ? channel_count_uc : channel_count_bc)) {
return -1;
}
}
Expand All @@ -1123,10 +1123,11 @@ int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_co
for (uint8_t i = 0; i < 8; i++) {
fhss_structure->ws->fhss_configuration.unicast_channel_mask[i] = fhss_configuration->channel_mask[i];
}
channel_count_uc = channel_count;
channel_count_uc = channel_count_bc;
}

fhss_structure->number_of_channels = channel_count;
fhss_structure->number_of_channels = fhss_configuration->channel_mask_size;
fhss_structure->number_of_bc_channels = channel_count_bc;
fhss_structure->number_of_uc_channels = channel_count_uc;
if (fhss_configuration->ws_uc_channel_function == WS_FIXED_CHANNEL) {
fhss_structure->rx_channel = fhss_configuration->unicast_fixed_channel;
Expand All @@ -1137,7 +1138,7 @@ int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_co
fhss_structure->ws->fhss_configuration.broadcast_fixed_channel,
fhss_structure->ws->fhss_configuration.ws_uc_channel_function,
fhss_structure->ws->fhss_configuration.ws_bc_channel_function,
fhss_structure->number_of_channels,
fhss_structure->number_of_bc_channels,
fhss_structure->number_of_uc_channels,
fhss_structure->ws->fhss_configuration.fhss_uc_dwell_interval,
fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval,
Expand Down

0 comments on commit 944f934

Please sign in to comment.