Skip to content

Commit

Permalink
FHSS: Added excluded channels in channel function interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Mar 7, 2018
1 parent b9606c9 commit 3a562d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions source/Service_Libs/fhss/channel_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ int32_t dh1cf_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t n
return channel_number;
}

int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t number_of_channels)
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)
{
uint16_t nearest_prime = tr51_calc_nearest_prime_number(number_of_channels);
int32_t channel_table[nearest_prime];
Expand All @@ -207,11 +207,11 @@ int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t nu
tr51_compute_cfd(mac, &first_element, &step_size, nearest_prime);
// Not sure yet which one is the correct second parameter
// tr51_calculate_hopping_sequence(channel_table, number_of_channels, first_element, step_size, output_table, NULL, 0);
tr51_calculate_hopping_sequence(channel_table, nearest_prime, first_element, step_size, output_table, NULL, 0);
tr51_calculate_hopping_sequence(channel_table, nearest_prime, first_element, step_size, output_table, excluded_channels, number_of_excluded_channels);
return output_table[slot_number];
}

int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t number_of_channels)
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)
{
uint16_t nearest_prime = tr51_calc_nearest_prime_number(number_of_channels);
int32_t channel_table[nearest_prime];
Expand All @@ -223,6 +223,6 @@ int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t nu
tr51_compute_cfd(mac, &first_element, &step_size, nearest_prime);
// Not sure yet which one is the correct second parameter
// tr51_calculate_hopping_sequence(channel_table, number_of_channels, first_element, step_size, output_table, NULL, 0);
tr51_calculate_hopping_sequence(channel_table, nearest_prime, first_element, step_size, output_table, NULL, 0);
tr51_calculate_hopping_sequence(channel_table, nearest_prime, first_element, step_size, output_table, excluded_channels, number_of_excluded_channels);
return output_table[slot_number];
}
8 changes: 6 additions & 2 deletions source/Service_Libs/fhss/channel_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@
* @param slot_number Current slot number.
* @param mac MAC address of the node for which the index is calculated.
* @param number_of_channels Number of channels.
* @param excluded_channels Excluded channels.
* @param number_of_excluded_channels Number of excluded channels.
* @return Channel index.
*/
int32_t tr51_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t number_of_channels);
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);

/**
* @brief Compute the broadcast schedule channel index using tr51 channel function.
* @param slot_number Current slot number.
* @param bsi Broadcast schedule identifier of the node for which the index is calculated.
* @param number_of_channels Number of channels.
* @param excluded_channels Excluded channels.
* @param number_of_excluded_channels Number of excluded channels.
* @return Channel index.
*/
int32_t tr51_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t number_of_channels);
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);

/**
* @brief Compute the unicast schedule channel index using direct hash channel function.
Expand Down
6 changes: 3 additions & 3 deletions source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static int32_t fhss_ws_calc_bc_channel(fhss_structure_t *fhss_structure)
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_FIXED_CHANNEL) {

} else if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_TR51CF) {
next_channel = tr51_get_bc_channel_index(fhss_structure->ws->bc_slot, fhss_structure->ws->fhss_configuration.bsi, fhss_structure->number_of_channels);
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);
if (++fhss_structure->ws->bc_slot == fhss_structure->number_of_channels) {
fhss_structure->ws->bc_slot = 0;
}
Expand Down Expand Up @@ -204,7 +204,7 @@ static void fhss_ws_update_uc_channel_callback(fhss_structure_t *fhss_structure)
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_FIXED_CHANNEL) {
return;
} else if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_TR51CF) {
next_channel = fhss_structure->rx_channel = tr51_get_uc_channel_index(fhss_structure->ws->uc_slot, mac_address, fhss_structure->number_of_channels);
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);
if (++fhss_structure->ws->uc_slot == fhss_structure->number_of_channels) {
fhss_structure->ws->uc_slot = 0;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ static int fhss_ws_tx_handle_callback(const fhss_api_t *api, bool is_broadcast_a
//TODO: Get destination UFSI, timestamp and dwell time from neighbour table
uint16_t destination_slot = fhss_ws_calculate_destination_slot(fhss_structure, 0, 0, fhss_structure->ws->fhss_configuration.fhss_uc_dwell_interval, tx_time);
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_TR51CF) {
tx_channel = tr51_get_uc_channel_index(destination_slot, destination_address, fhss_structure->number_of_channels);
tx_channel = tr51_get_uc_channel_index(destination_slot, destination_address, fhss_structure->number_of_channels, NULL, 0);
} else if(fhss_structure->ws->fhss_configuration.ws_channel_function == WS_DH1CF) {
tx_channel = dh1cf_get_uc_channel_index(destination_slot, destination_address, fhss_structure->number_of_channels);
} else if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_VENDOR_DEF_CF) {
Expand Down

0 comments on commit 3a562d3

Please sign in to comment.