Skip to content

Commit b9606c9

Browse files
author
Jarkko Paso
committed
FHSS: Static channel functions added
1 parent 695e64c commit b9606c9

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

source/Service_Libs/fhss/channel_functions.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
static uint32_t global_seed = 1;
4343

4444

45-
uint16_t tr51_calc_nearest_prime_number(uint16_t start_value)
45+
static uint16_t tr51_calc_nearest_prime_number(uint16_t start_value)
4646
{
4747
if (start_value < 2) {
4848
return 0;
@@ -60,22 +60,28 @@ uint16_t tr51_calc_nearest_prime_number(uint16_t start_value)
6060
return 0;
6161
}
6262

63-
void tr51_seed_rand(uint32_t seed)
63+
static void tr51_seed_rand(uint32_t seed)
6464
{
6565
if (!seed) {
6666
seed = 1;
6767
}
6868
global_seed = seed;
6969
}
7070

71-
int32_t tr51_get_rand(void)
71+
static int32_t tr51_get_rand(void)
7272
{
7373
uint32_t random_val = ((global_seed * 1103515245) + 12345) & 0x7fffffff;
7474
global_seed = random_val;
7575
return random_val;
7676
}
7777

78-
void tr51_calculate_channel_table(uint16_t number_of_channels, uint16_t nearest_prime, int32_t *channel_table)
78+
/**
79+
* @brief Calculate channel table based on TR51 channel function.
80+
* @param number_of_channels Number of channels in table.
81+
* @param nearest_prime Nearest prime number. Must be equal to or larger than number_of_channels.
82+
* @param channel_table Output channel table. Has to be at least nearest_prime in length.
83+
*/
84+
static void tr51_calculate_channel_table(uint16_t number_of_channels, uint16_t nearest_prime, int32_t *channel_table)
7985
{
8086
int32_t i,j,k;
8187
tr51_seed_rand(1);
@@ -97,7 +103,7 @@ void tr51_calculate_channel_table(uint16_t number_of_channels, uint16_t nearest_
97103
}
98104
}
99105

100-
void tr51_compute_cfd(uint8_t *mac, uint8_t *first_element, uint8_t *step_size, uint16_t channel_table_length)
106+
static void tr51_compute_cfd(uint8_t *mac, uint8_t *first_element, uint8_t *step_size, uint16_t channel_table_length)
101107
{
102108
*first_element = (mac[5] ^ mac[6] ^ mac[7]) % channel_table_length;
103109
*step_size = (mac[7] % (channel_table_length - 1)) + 1;
@@ -116,7 +122,18 @@ static uint8_t tr51_find_excluded(int32_t channel, uint16_t *excluded_channels,
116122
return 0;
117123
}
118124

119-
uint16_t tr51_calculate_hopping_sequence(int32_t *channel_table, uint16_t channel_table_length, uint8_t first_element, uint8_t step_size, int32_t *output_table, uint16_t *excluded_channels, uint16_t number_of_excluded_channels)
125+
/**
126+
* @brief Calculate hopping sequence for a specific peer using tr51 channel function.
127+
* @param channel_table Used channel table.
128+
* @param channel_table_length Length of the used channel table.
129+
* @param first_element Start generated by CFD function.
130+
* @param step_size Step size generated by CFD function.
131+
* @param output_table Output hopping sequence table.
132+
* @param excluded_channels List of not used channels.
133+
* @param number_of_excluded_channels Number of not used channels.
134+
* @return Number of channels in sequence.
135+
*/
136+
static uint16_t tr51_calculate_hopping_sequence(int32_t *channel_table, uint16_t channel_table_length, uint8_t first_element, uint8_t step_size, int32_t *output_table, uint16_t *excluded_channels, uint16_t number_of_excluded_channels)
120137
{
121138
uint16_t cntr = channel_table_length;
122139
uint8_t index = first_element;

source/Service_Libs/fhss/channel_functions.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,6 @@
1616
*/
1717
#ifndef CHANNEL_FUNC_H_
1818
#define CHANNEL_FUNC_H_
19-
/**
20-
* @brief Calculate channel table based on TR51 channel function.
21-
* @param number_of_channels Number of channels in table.
22-
* @param nearest_prime Nearest prime number. Must be equal to or larger than number_of_channels.
23-
* @param channel_table Output channel table. Has to be at least nearest_prime in length.
24-
*/
25-
void tr51_calculate_channel_table(uint16_t number_of_channels, uint16_t nearest_prime, int32_t *channel_table);
26-
27-
/**
28-
* @brief Calculate hopping sequence for a specific peer using tr51 channel function.
29-
* @param channel_table Used channel table.
30-
* @param channel_table_length Length of the used channel table.
31-
* @param first_element Start generated by CFD function.
32-
* @param step_size Step size generated by CFD function.
33-
* @param output_table Output hopping sequence table.
34-
* @param excluded_channels List of not used channels.
35-
* @param number_of_excluded_channels Number of not used channels.
36-
* @return Number of channels in sequence.
37-
*/
38-
uint16_t tr51_calculate_hopping_sequence(int32_t *channel_table, uint16_t channel_table_length, uint8_t first_element, uint8_t step_size, int32_t *output_table, uint16_t *excluded_channels, uint16_t number_of_excluded_channels);
3919

4020
/**
4121
* @brief Compute the unicast schedule channel index using tr51 channel function.

0 commit comments

Comments
 (0)