Skip to content

Commit 928723a

Browse files
author
Jarkko Paso
authored
FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642)
1 parent 6040d70 commit 928723a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ fhss_structure_t *fhss_ws_enable(fhss_api_t *fhss_api, const fhss_ws_configurati
130130
tr_err("Invalid FHSS enable configuration");
131131
return NULL;
132132
}
133-
int channel_count = channel_list_count_channels(fhss_configuration->channel_mask);
133+
int bc_channel_count = channel_list_count_channels(fhss_configuration->channel_mask);
134134
int uc_channel_count = channel_list_count_channels(fhss_configuration->unicast_channel_mask);
135135

136-
if (channel_count <= 0) {
136+
if (bc_channel_count <= 0) {
137137
// There must be at least one configured channel in channel list
138138
return NULL;
139139
}
@@ -147,7 +147,7 @@ fhss_structure_t *fhss_ws_enable(fhss_api_t *fhss_api, const fhss_ws_configurati
147147
return NULL;
148148
}
149149
memset(fhss_struct->ws, 0, sizeof(fhss_ws_t));
150-
if (fhss_ws_manage_channel_table_allocation(fhss_struct, channel_count)) {
150+
if (fhss_ws_manage_channel_table_allocation(fhss_struct, uc_channel_count > bc_channel_count ? uc_channel_count : bc_channel_count)) {
151151
ns_dyn_mem_free(fhss_struct->ws);
152152
fhss_free_instance(fhss_api);
153153
tr_error("Failed to allocate channel tables");
@@ -161,10 +161,12 @@ fhss_structure_t *fhss_ws_enable(fhss_api_t *fhss_api, const fhss_ws_configurati
161161
for (uint8_t i = 0; i < 8; i++) {
162162
fhss_struct->ws->fhss_configuration.unicast_channel_mask[i] = fhss_configuration->channel_mask[i];
163163
}
164-
uc_channel_count = channel_count;
164+
uc_channel_count = bc_channel_count;
165165
}
166-
fhss_struct->number_of_channels = channel_count;
166+
167+
fhss_struct->number_of_channels = fhss_configuration->channel_mask_size;
167168
fhss_struct->number_of_uc_channels = uc_channel_count;
169+
fhss_struct->number_of_bc_channels = bc_channel_count;
168170
fhss_struct->optimal_packet_length = OPTIMAL_PACKET_LENGTH;
169171
fhss_ws_set_hop_count(fhss_struct, 0xff);
170172
fhss_struct->rx_channel = fhss_configuration->unicast_fixed_channel;

0 commit comments

Comments
 (0)