@@ -91,10 +91,10 @@ uint8_t fhss_add_channel_list_counter(uint8_t index, uint16_t number_of_channels
91
91
static void fhss_generate_broadcast_start_superframe (fhss_structure_t * fhss_structure )
92
92
{
93
93
// If the number of superframes is low, allow broadcast on any superframe
94
- if (fhss_structure -> synch_configuration .fhss_number_of_superframes < 8 ) {
95
- fhss_structure -> broadcast_start_superframe = 0 ;
94
+ if (fhss_structure -> bs -> synch_configuration .fhss_number_of_superframes < 8 ) {
95
+ fhss_structure -> bs -> broadcast_start_superframe = 0 ;
96
96
} else {
97
- fhss_structure -> broadcast_start_superframe = randLIB_get_random_in_range (0 , NUMBER_OF_BC_START_SUPERFRAMES - 1 );
97
+ fhss_structure -> bs -> broadcast_start_superframe = randLIB_get_random_in_range (0 , NUMBER_OF_BC_START_SUPERFRAMES - 1 );
98
98
}
99
99
}
100
100
@@ -113,7 +113,7 @@ bool fhss_change_to_next_channel(fhss_structure_t *fhss_structure)
113
113
bool broadcast_channel = false;
114
114
115
115
uint16_t number_of_channels = fhss_structure -> number_of_channels ;
116
- uint8_t number_of_broadcast_channels = fhss_structure -> synch_configuration .fhss_number_of_bc_channels ;
116
+ uint8_t number_of_broadcast_channels = fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels ;
117
117
uint8_t unicast_channel_index = fhss_structure -> bs -> uc_channel_index ;
118
118
uint8_t channel_index_tmp ;
119
119
@@ -124,18 +124,18 @@ bool fhss_change_to_next_channel(fhss_structure_t *fhss_structure)
124
124
*/
125
125
/* Get broadcast channel */
126
126
if (fhss_is_current_channel_broadcast (fhss_structure ) == true) {
127
- channel_index_tmp = fhss_calc_channel_shuffle ((number_of_channels - number_of_broadcast_channels ) + fhss_get_bc_index (fhss_structure ), fhss_structure -> number_of_channels , fhss_structure -> synch_configuration .fhss_number_of_bc_channels );
127
+ channel_index_tmp = fhss_calc_channel_shuffle ((number_of_channels - number_of_broadcast_channels ) + fhss_get_bc_index (fhss_structure ), fhss_structure -> number_of_channels , fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels );
128
128
fhss_generate_broadcast_start_superframe (fhss_structure );
129
129
broadcast_channel = true;
130
130
} else { /* Get unicast channel */
131
- channel_index_tmp = fhss_calc_channel_shuffle (unicast_channel_index , fhss_structure -> number_of_channels , fhss_structure -> synch_configuration .fhss_number_of_bc_channels );
131
+ channel_index_tmp = fhss_calc_channel_shuffle (unicast_channel_index , fhss_structure -> number_of_channels , fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels );
132
132
if (++ fhss_structure -> bs -> uc_channel_index >= number_of_channels - number_of_broadcast_channels ) {
133
133
fhss_structure -> bs -> uc_channel_index = 0 ;
134
134
}
135
135
}
136
136
// Reset Beacon received flag when channel has changed
137
- fhss_structure -> beacon_received_on_this_bc_channel = false;
138
- channel_index_tmp = fhss_add_channel_list_counter (channel_index_tmp , fhss_structure -> number_of_channels , fhss_structure -> bs -> channel_list_counter , fhss_structure -> fhss_scramble_table );
137
+ fhss_structure -> bs -> beacon_received_on_this_bc_channel = false;
138
+ channel_index_tmp = fhss_add_channel_list_counter (channel_index_tmp , fhss_structure -> number_of_channels , fhss_structure -> bs -> channel_list_counter , fhss_structure -> bs -> fhss_scramble_table );
139
139
next_channel = channel_list_get_channel (fhss_structure -> bs -> fhss_configuration .channel_mask , channel_index_tmp );
140
140
141
141
fhss_structure -> rx_channel = next_channel ;
@@ -153,8 +153,8 @@ bool fhss_change_to_next_channel(fhss_structure_t *fhss_structure)
153
153
static uint8_t fhss_get_bc_index (const fhss_structure_t * fhss_structure )
154
154
{
155
155
uint16_t number_of_channels = fhss_structure -> number_of_channels ;
156
- uint8_t number_of_bc_channels = fhss_structure -> synch_configuration .fhss_number_of_bc_channels ;
157
- uint8_t cur_channel_index = fhss_structure -> current_channel_index ;
156
+ uint8_t number_of_bc_channels = fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels ;
157
+ uint8_t cur_channel_index = fhss_structure -> bs -> current_channel_index ;
158
158
159
159
return cur_channel_index / (number_of_channels /number_of_bc_channels );
160
160
}
@@ -164,7 +164,7 @@ uint8_t fhss_get_offset(fhss_structure_t *fhss_structure, const uint8_t *ptr)
164
164
uint8_t i ;
165
165
uint8_t index = * ptr ++ ;
166
166
167
- if (fhss_structure -> number_of_channels == fhss_structure -> synch_configuration .fhss_number_of_bc_channels ) {
167
+ if (fhss_structure -> number_of_channels == fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels ) {
168
168
// If all channels are defined as broadcast channels then return 0 to avoid division by 0.
169
169
// This could happen e.g. in OTA case when fast download is needed.
170
170
return 0 ;
@@ -176,7 +176,7 @@ uint8_t fhss_get_offset(fhss_structure_t *fhss_structure, const uint8_t *ptr)
176
176
index ^= * ptr ++ ;
177
177
}
178
178
// Offset must be < number of unicast channels
179
- index %= (fhss_structure -> number_of_channels - fhss_structure -> synch_configuration .fhss_number_of_bc_channels );
179
+ index %= (fhss_structure -> number_of_channels - fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels );
180
180
181
181
return index ;
182
182
}
@@ -189,13 +189,13 @@ bool fhss_is_current_channel_broadcast(fhss_structure_t *fhss_structure)
189
189
}
190
190
191
191
// Should always have broadcast channels with FHSS
192
- if (!fhss_structure -> synch_configuration .fhss_number_of_bc_channels ) {
192
+ if (!fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels ) {
193
193
return true;
194
194
}
195
195
196
- uint8_t channel_index = fhss_structure -> current_channel_index ;
196
+ uint8_t channel_index = fhss_structure -> bs -> current_channel_index ;
197
197
uint16_t number_of_channels = fhss_structure -> number_of_channels ;
198
- uint8_t number_of_broadcast_channels = fhss_structure -> synch_configuration .fhss_number_of_bc_channels ;
198
+ uint8_t number_of_broadcast_channels = fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels ;
199
199
200
200
if (!(channel_index % (number_of_channels / number_of_broadcast_channels ))) {
201
201
return true;
@@ -211,14 +211,14 @@ static uint8_t fhss_get_destination_channel(fhss_structure_t *fhss_structure, ui
211
211
if (fhss_structure ) {
212
212
if (fhss_is_current_channel_broadcast (fhss_structure ) == false) {
213
213
destination_offset = fhss_get_offset (fhss_structure , destination_address );
214
- uc_index = fhss_calculate_uc_index (fhss_structure -> current_channel_index , fhss_structure -> number_of_channels ,
215
- fhss_structure -> synch_configuration .fhss_number_of_bc_channels ) + destination_offset ;
216
- if (uc_index >= (fhss_structure -> number_of_channels - fhss_structure -> synch_configuration .fhss_number_of_bc_channels )) {
217
- uc_index -= (fhss_structure -> number_of_channels - fhss_structure -> synch_configuration .fhss_number_of_bc_channels );
214
+ uc_index = fhss_calculate_uc_index (fhss_structure -> bs -> current_channel_index , fhss_structure -> number_of_channels ,
215
+ fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels ) + destination_offset ;
216
+ if (uc_index >= (fhss_structure -> number_of_channels - fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels )) {
217
+ uc_index -= (fhss_structure -> number_of_channels - fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels );
218
218
}
219
219
220
- uc_index = fhss_calc_channel_shuffle (uc_index , fhss_structure -> number_of_channels , fhss_structure -> synch_configuration .fhss_number_of_bc_channels );
221
- uc_index = fhss_add_channel_list_counter (uc_index , fhss_structure -> number_of_channels , fhss_structure -> bs -> channel_list_counter , fhss_structure -> fhss_scramble_table );
220
+ uc_index = fhss_calc_channel_shuffle (uc_index , fhss_structure -> number_of_channels , fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels );
221
+ uc_index = fhss_add_channel_list_counter (uc_index , fhss_structure -> number_of_channels , fhss_structure -> bs -> channel_list_counter , fhss_structure -> bs -> fhss_scramble_table );
222
222
return channel_list_get_channel (fhss_structure -> bs -> fhss_configuration .channel_mask , uc_index );
223
223
}
224
224
return fhss_structure -> rx_channel ;
@@ -246,21 +246,21 @@ int fhss_change_to_parent_channel(fhss_structure_t *fhss_structure)
246
246
uint8_t destination_channel ;
247
247
uint8_t destination_offset ;
248
248
if (fhss_structure ) {
249
- if (fhss_structure -> number_of_channels != fhss_structure -> synch_configuration .fhss_number_of_bc_channels ) {
249
+ if (fhss_structure -> number_of_channels != fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels ) {
250
250
uint8_t parent_address [8 ];
251
251
if (fhss_get_parent_address (fhss_structure , parent_address )) {
252
252
return -1 ;
253
253
}
254
254
255
255
destination_offset = fhss_get_offset (fhss_structure , parent_address );
256
256
257
- uc_index = fhss_calculate_uc_index (fhss_structure -> current_channel_index , fhss_structure -> number_of_channels ,
258
- fhss_structure -> synch_configuration .fhss_number_of_bc_channels ) + destination_offset ;
259
- if (uc_index >= (fhss_structure -> number_of_channels - fhss_structure -> synch_configuration .fhss_number_of_bc_channels )) {
260
- uc_index -= (fhss_structure -> number_of_channels - fhss_structure -> synch_configuration .fhss_number_of_bc_channels );
257
+ uc_index = fhss_calculate_uc_index (fhss_structure -> bs -> current_channel_index , fhss_structure -> number_of_channels ,
258
+ fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels ) + destination_offset ;
259
+ if (uc_index >= (fhss_structure -> number_of_channels - fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels )) {
260
+ uc_index -= (fhss_structure -> number_of_channels - fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels );
261
261
}
262
- uc_index = fhss_calc_channel_shuffle (uc_index , fhss_structure -> number_of_channels , fhss_structure -> synch_configuration .fhss_number_of_bc_channels );
263
- uc_index = fhss_add_channel_list_counter (uc_index , fhss_structure -> number_of_channels , fhss_structure -> bs -> channel_list_counter , fhss_structure -> fhss_scramble_table );
262
+ uc_index = fhss_calc_channel_shuffle (uc_index , fhss_structure -> number_of_channels , fhss_structure -> bs -> synch_configuration .fhss_number_of_bc_channels );
263
+ uc_index = fhss_add_channel_list_counter (uc_index , fhss_structure -> number_of_channels , fhss_structure -> bs -> channel_list_counter , fhss_structure -> bs -> fhss_scramble_table );
264
264
destination_channel = channel_list_get_channel (fhss_structure -> bs -> fhss_configuration .channel_mask , uc_index );
265
265
fhss_structure -> callbacks .change_channel (fhss_structure -> fhss_api , destination_channel );
266
266
#ifdef FHSS_CHANNEL_DEBUG
0 commit comments