42
42
static uint32_t global_seed = 1 ;
43
43
44
44
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 )
46
46
{
47
47
if (start_value < 2 ) {
48
48
return 0 ;
@@ -60,22 +60,28 @@ uint16_t tr51_calc_nearest_prime_number(uint16_t start_value)
60
60
return 0 ;
61
61
}
62
62
63
- void tr51_seed_rand (uint32_t seed )
63
+ static void tr51_seed_rand (uint32_t seed )
64
64
{
65
65
if (!seed ) {
66
66
seed = 1 ;
67
67
}
68
68
global_seed = seed ;
69
69
}
70
70
71
- int32_t tr51_get_rand (void )
71
+ static int32_t tr51_get_rand (void )
72
72
{
73
73
uint32_t random_val = ((global_seed * 1103515245 ) + 12345 ) & 0x7fffffff ;
74
74
global_seed = random_val ;
75
75
return random_val ;
76
76
}
77
77
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 )
79
85
{
80
86
int32_t i ,j ,k ;
81
87
tr51_seed_rand (1 );
@@ -97,7 +103,7 @@ void tr51_calculate_channel_table(uint16_t number_of_channels, uint16_t nearest_
97
103
}
98
104
}
99
105
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 )
101
107
{
102
108
* first_element = (mac [5 ] ^ mac [6 ] ^ mac [7 ]) % channel_table_length ;
103
109
* 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,
116
122
return 0 ;
117
123
}
118
124
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 )
120
137
{
121
138
uint16_t cntr = channel_table_length ;
122
139
uint8_t index = first_element ;
0 commit comments