@@ -91,10 +91,10 @@ uint8_t fhss_add_channel_list_counter(uint8_t index, uint16_t number_of_channels
9191static void fhss_generate_broadcast_start_superframe (fhss_structure_t * fhss_structure )
9292{
9393 // 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 ;
9696 } 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 );
9898 }
9999}
100100
@@ -113,7 +113,7 @@ bool fhss_change_to_next_channel(fhss_structure_t *fhss_structure)
113113 bool broadcast_channel = false;
114114
115115 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 ;
117117 uint8_t unicast_channel_index = fhss_structure -> bs -> uc_channel_index ;
118118 uint8_t channel_index_tmp ;
119119
@@ -124,18 +124,18 @@ bool fhss_change_to_next_channel(fhss_structure_t *fhss_structure)
124124 */
125125 /* Get broadcast channel */
126126 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 );
128128 fhss_generate_broadcast_start_superframe (fhss_structure );
129129 broadcast_channel = true;
130130 } 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 );
132132 if (++ fhss_structure -> bs -> uc_channel_index >= number_of_channels - number_of_broadcast_channels ) {
133133 fhss_structure -> bs -> uc_channel_index = 0 ;
134134 }
135135 }
136136 // 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 );
139139 next_channel = channel_list_get_channel (fhss_structure -> bs -> fhss_configuration .channel_mask , channel_index_tmp );
140140
141141 fhss_structure -> rx_channel = next_channel ;
@@ -153,8 +153,8 @@ bool fhss_change_to_next_channel(fhss_structure_t *fhss_structure)
153153static uint8_t fhss_get_bc_index (const fhss_structure_t * fhss_structure )
154154{
155155 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 ;
158158
159159 return cur_channel_index / (number_of_channels /number_of_bc_channels );
160160}
@@ -164,7 +164,7 @@ uint8_t fhss_get_offset(fhss_structure_t *fhss_structure, const uint8_t *ptr)
164164 uint8_t i ;
165165 uint8_t index = * ptr ++ ;
166166
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 ) {
168168 // If all channels are defined as broadcast channels then return 0 to avoid division by 0.
169169 // This could happen e.g. in OTA case when fast download is needed.
170170 return 0 ;
@@ -176,7 +176,7 @@ uint8_t fhss_get_offset(fhss_structure_t *fhss_structure, const uint8_t *ptr)
176176 index ^= * ptr ++ ;
177177 }
178178 // 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 );
180180
181181 return index ;
182182}
@@ -189,13 +189,13 @@ bool fhss_is_current_channel_broadcast(fhss_structure_t *fhss_structure)
189189 }
190190
191191 // 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 ) {
193193 return true;
194194 }
195195
196- uint8_t channel_index = fhss_structure -> current_channel_index ;
196+ uint8_t channel_index = fhss_structure -> bs -> current_channel_index ;
197197 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 ;
199199
200200 if (!(channel_index % (number_of_channels / number_of_broadcast_channels ))) {
201201 return true;
@@ -211,14 +211,14 @@ static uint8_t fhss_get_destination_channel(fhss_structure_t *fhss_structure, ui
211211 if (fhss_structure ) {
212212 if (fhss_is_current_channel_broadcast (fhss_structure ) == false) {
213213 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 );
218218 }
219219
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 );
222222 return channel_list_get_channel (fhss_structure -> bs -> fhss_configuration .channel_mask , uc_index );
223223 }
224224 return fhss_structure -> rx_channel ;
@@ -246,21 +246,21 @@ int fhss_change_to_parent_channel(fhss_structure_t *fhss_structure)
246246 uint8_t destination_channel ;
247247 uint8_t destination_offset ;
248248 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 ) {
250250 uint8_t parent_address [8 ];
251251 if (fhss_get_parent_address (fhss_structure , parent_address )) {
252252 return -1 ;
253253 }
254254
255255 destination_offset = fhss_get_offset (fhss_structure , parent_address );
256256
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 );
261261 }
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 );
264264 destination_channel = channel_list_get_channel (fhss_structure -> bs -> fhss_configuration .channel_mask , uc_index );
265265 fhss_structure -> callbacks .change_channel (fhss_structure -> fhss_api , destination_channel );
266266#ifdef FHSS_CHANNEL_DEBUG
0 commit comments