Skip to content

Commit 3a562d3

Browse files
author
Jarkko Paso
committed
FHSS: Added excluded channels in channel function interface
1 parent b9606c9 commit 3a562d3

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

source/Service_Libs/fhss/channel_functions.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int32_t dh1cf_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t n
196196
return channel_number;
197197
}
198198

199-
int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t number_of_channels)
199+
int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t number_of_channels, uint16_t *excluded_channels, uint16_t number_of_excluded_channels)
200200
{
201201
uint16_t nearest_prime = tr51_calc_nearest_prime_number(number_of_channels);
202202
int32_t channel_table[nearest_prime];
@@ -207,11 +207,11 @@ int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t nu
207207
tr51_compute_cfd(mac, &first_element, &step_size, nearest_prime);
208208
// Not sure yet which one is the correct second parameter
209209
// tr51_calculate_hopping_sequence(channel_table, number_of_channels, first_element, step_size, output_table, NULL, 0);
210-
tr51_calculate_hopping_sequence(channel_table, nearest_prime, first_element, step_size, output_table, NULL, 0);
210+
tr51_calculate_hopping_sequence(channel_table, nearest_prime, first_element, step_size, output_table, excluded_channels, number_of_excluded_channels);
211211
return output_table[slot_number];
212212
}
213213

214-
int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t number_of_channels)
214+
int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t number_of_channels, uint16_t *excluded_channels, uint16_t number_of_excluded_channels)
215215
{
216216
uint16_t nearest_prime = tr51_calc_nearest_prime_number(number_of_channels);
217217
int32_t channel_table[nearest_prime];
@@ -223,6 +223,6 @@ int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t nu
223223
tr51_compute_cfd(mac, &first_element, &step_size, nearest_prime);
224224
// Not sure yet which one is the correct second parameter
225225
// tr51_calculate_hopping_sequence(channel_table, number_of_channels, first_element, step_size, output_table, NULL, 0);
226-
tr51_calculate_hopping_sequence(channel_table, nearest_prime, first_element, step_size, output_table, NULL, 0);
226+
tr51_calculate_hopping_sequence(channel_table, nearest_prime, first_element, step_size, output_table, excluded_channels, number_of_excluded_channels);
227227
return output_table[slot_number];
228228
}

source/Service_Libs/fhss/channel_functions.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@
2222
* @param slot_number Current slot number.
2323
* @param mac MAC address of the node for which the index is calculated.
2424
* @param number_of_channels Number of channels.
25+
* @param excluded_channels Excluded channels.
26+
* @param number_of_excluded_channels Number of excluded channels.
2527
* @return Channel index.
2628
*/
27-
int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t number_of_channels);
29+
int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t number_of_channels, uint16_t *excluded_channels, uint16_t number_of_excluded_channels);
2830

2931
/**
3032
* @brief Compute the broadcast schedule channel index using tr51 channel function.
3133
* @param slot_number Current slot number.
3234
* @param bsi Broadcast schedule identifier of the node for which the index is calculated.
3335
* @param number_of_channels Number of channels.
36+
* @param excluded_channels Excluded channels.
37+
* @param number_of_excluded_channels Number of excluded channels.
3438
* @return Channel index.
3539
*/
36-
int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t number_of_channels);
40+
int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t number_of_channels, uint16_t *excluded_channels, uint16_t number_of_excluded_channels);
3741

3842
/**
3943
* @brief Compute the unicast schedule channel index using direct hash channel function.

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int32_t fhss_ws_calc_bc_channel(fhss_structure_t *fhss_structure)
8282
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_FIXED_CHANNEL) {
8383

8484
} else if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_TR51CF) {
85-
next_channel = tr51_get_bc_channel_index(fhss_structure->ws->bc_slot, fhss_structure->ws->fhss_configuration.bsi, fhss_structure->number_of_channels);
85+
next_channel = tr51_get_bc_channel_index(fhss_structure->ws->bc_slot, fhss_structure->ws->fhss_configuration.bsi, fhss_structure->number_of_channels, NULL, 0);
8686
if (++fhss_structure->ws->bc_slot == fhss_structure->number_of_channels) {
8787
fhss_structure->ws->bc_slot = 0;
8888
}
@@ -204,7 +204,7 @@ static void fhss_ws_update_uc_channel_callback(fhss_structure_t *fhss_structure)
204204
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_FIXED_CHANNEL) {
205205
return;
206206
} else if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_TR51CF) {
207-
next_channel = fhss_structure->rx_channel = tr51_get_uc_channel_index(fhss_structure->ws->uc_slot, mac_address, fhss_structure->number_of_channels);
207+
next_channel = fhss_structure->rx_channel = tr51_get_uc_channel_index(fhss_structure->ws->uc_slot, mac_address, fhss_structure->number_of_channels, NULL, 0);
208208
if (++fhss_structure->ws->uc_slot == fhss_structure->number_of_channels) {
209209
fhss_structure->ws->uc_slot = 0;
210210
}
@@ -245,7 +245,7 @@ static int fhss_ws_tx_handle_callback(const fhss_api_t *api, bool is_broadcast_a
245245
//TODO: Get destination UFSI, timestamp and dwell time from neighbour table
246246
uint16_t destination_slot = fhss_ws_calculate_destination_slot(fhss_structure, 0, 0, fhss_structure->ws->fhss_configuration.fhss_uc_dwell_interval, tx_time);
247247
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_TR51CF) {
248-
tx_channel = tr51_get_uc_channel_index(destination_slot, destination_address, fhss_structure->number_of_channels);
248+
tx_channel = tr51_get_uc_channel_index(destination_slot, destination_address, fhss_structure->number_of_channels, NULL, 0);
249249
} else if(fhss_structure->ws->fhss_configuration.ws_channel_function == WS_DH1CF) {
250250
tx_channel = dh1cf_get_uc_channel_index(destination_slot, destination_address, fhss_structure->number_of_channels);
251251
} else if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_VENDOR_DEF_CF) {

0 commit comments

Comments
 (0)