@@ -83,6 +83,7 @@ static void fhss_event_timer_cb(int8_t timer_id, uint16_t slots);
83
83
static void fhss_ws_update_uc_channel_callback (fhss_structure_t * fhss_structure );
84
84
static void fhss_unicast_handler (const fhss_api_t * fhss_api , uint16_t delay );
85
85
static bool fhss_ws_check_tx_allowed (fhss_structure_t * fhss_structure );
86
+ static int32_t fhss_channel_index_from_mask (const uint32_t * channel_mask , int32_t channel_index , uint16_t number_of_channels );
86
87
87
88
// This function supports rounding up
88
89
static int64_t divide_integer (int64_t dividend , int32_t divisor )
@@ -235,12 +236,14 @@ static int32_t fhss_ws_calc_bc_channel(fhss_structure_t *fhss_structure)
235
236
236
237
if (fhss_structure -> ws -> fhss_configuration .ws_bc_channel_function == WS_TR51CF ) {
237
238
next_channel = tr51_get_bc_channel_index (fhss_structure -> ws -> tr51_channel_table , fhss_structure -> ws -> tr51_output_table , fhss_structure -> ws -> bc_slot , fhss_structure -> ws -> fhss_configuration .bsi , fhss_structure -> number_of_channels , NULL );
239
+ next_channel = fhss_channel_index_from_mask (fhss_structure -> ws -> fhss_configuration .channel_mask , next_channel , fhss_structure -> number_of_channels );
238
240
if (++ fhss_structure -> ws -> bc_slot == fhss_structure -> number_of_channels ) {
239
241
fhss_structure -> ws -> bc_slot = 0 ;
240
242
}
241
243
} else if (fhss_structure -> ws -> fhss_configuration .ws_bc_channel_function == WS_DH1CF ) {
242
244
fhss_structure -> ws -> bc_slot ++ ;
243
245
next_channel = dh1cf_get_bc_channel_index (fhss_structure -> ws -> bc_slot , fhss_structure -> ws -> fhss_configuration .bsi , fhss_structure -> number_of_channels );
246
+ next_channel = fhss_channel_index_from_mask (fhss_structure -> ws -> fhss_configuration .channel_mask , next_channel , fhss_structure -> number_of_channels );
244
247
} else if (fhss_structure -> ws -> fhss_configuration .ws_bc_channel_function == WS_VENDOR_DEF_CF ) {
245
248
if (fhss_structure -> ws -> fhss_configuration .vendor_defined_cf ) {
246
249
next_channel = fhss_structure -> ws -> fhss_configuration .vendor_defined_cf (fhss_structure -> fhss_api , fhss_structure -> ws -> bc_slot , NULL , fhss_structure -> ws -> fhss_configuration .bsi , fhss_structure -> number_of_channels );
@@ -264,6 +267,22 @@ static uint8_t calc_own_tx_trig_slot(uint8_t own_hop)
264
267
return (own_hop & 1 );
265
268
}
266
269
270
+ static int32_t fhss_channel_index_from_mask (const uint32_t * channel_mask , int32_t channel_index , uint16_t number_of_channels )
271
+ {
272
+ //Function will return real active channel index at list
273
+ int32_t active_channels = 0 ;
274
+ // Set channel maks outside excluded channels
275
+ for (int32_t i = 0 ; i < number_of_channels ; i ++ ) {
276
+ if (channel_mask [0 + (i / 32 )] & (1 << (i % 32 ))) {
277
+ if (channel_index == active_channels ) {
278
+ return i ;
279
+ }
280
+ active_channels ++ ;
281
+ }
282
+ }
283
+ return 0 ;
284
+ }
285
+
267
286
static void fhss_broadcast_handler (const fhss_api_t * fhss_api , uint16_t delay )
268
287
{
269
288
int32_t next_channel ;
@@ -477,12 +496,14 @@ static void fhss_ws_update_uc_channel_callback(fhss_structure_t *fhss_structure)
477
496
if (fhss_structure -> ws -> fhss_configuration .ws_uc_channel_function == WS_FIXED_CHANNEL ) {
478
497
return ;
479
498
} else if (fhss_structure -> ws -> fhss_configuration .ws_uc_channel_function == WS_TR51CF ) {
480
- next_channel = fhss_structure -> rx_channel = tr51_get_uc_channel_index (fhss_structure -> ws -> tr51_channel_table , fhss_structure -> ws -> tr51_output_table , fhss_structure -> ws -> uc_slot , mac_address , fhss_structure -> number_of_uc_channels , NULL );
499
+ next_channel = tr51_get_uc_channel_index (fhss_structure -> ws -> tr51_channel_table , fhss_structure -> ws -> tr51_output_table , fhss_structure -> ws -> uc_slot , mac_address , fhss_structure -> number_of_uc_channels , NULL );
500
+ next_channel = fhss_structure -> rx_channel = fhss_channel_index_from_mask (fhss_structure -> ws -> fhss_configuration .unicast_channel_mask , next_channel , fhss_structure -> number_of_channels );
481
501
if (++ fhss_structure -> ws -> uc_slot == fhss_structure -> number_of_uc_channels ) {
482
502
fhss_structure -> ws -> uc_slot = 0 ;
483
503
}
484
504
} else if (fhss_structure -> ws -> fhss_configuration .ws_uc_channel_function == WS_DH1CF ) {
485
- next_channel = fhss_structure -> rx_channel = dh1cf_get_uc_channel_index (fhss_structure -> ws -> uc_slot , mac_address , fhss_structure -> number_of_uc_channels );
505
+ next_channel = dh1cf_get_uc_channel_index (fhss_structure -> ws -> uc_slot , mac_address , fhss_structure -> number_of_uc_channels );
506
+ next_channel = fhss_structure -> rx_channel = fhss_channel_index_from_mask (fhss_structure -> ws -> fhss_configuration .unicast_channel_mask , next_channel , fhss_structure -> number_of_channels );
486
507
fhss_structure -> ws -> uc_slot ++ ;
487
508
} else if (fhss_structure -> ws -> fhss_configuration .ws_uc_channel_function == WS_VENDOR_DEF_CF ) {
488
509
if (fhss_structure -> ws -> fhss_configuration .vendor_defined_cf ) {
@@ -540,8 +561,10 @@ static int fhss_ws_tx_handle_callback(const fhss_api_t *api, bool is_broadcast_a
540
561
int32_t tx_channel = neighbor_timing_info -> uc_timing_info .fixed_channel ;
541
562
if (neighbor_timing_info -> uc_timing_info .unicast_channel_function == WS_TR51CF ) {
542
563
tx_channel = tr51_get_uc_channel_index (fhss_structure -> ws -> tr51_channel_table , fhss_structure -> ws -> tr51_output_table , destination_slot , destination_address , neighbor_timing_info -> uc_timing_info .unicast_number_of_channels , NULL );
564
+ tx_channel = fhss_channel_index_from_mask (neighbor_timing_info -> uc_channel_list .channel_mask , tx_channel , fhss_structure -> number_of_channels );
543
565
} else if (neighbor_timing_info -> uc_timing_info .unicast_channel_function == WS_DH1CF ) {
544
566
tx_channel = dh1cf_get_uc_channel_index (destination_slot , destination_address , neighbor_timing_info -> uc_channel_list .channel_count );
567
+ tx_channel = fhss_channel_index_from_mask (neighbor_timing_info -> uc_channel_list .channel_mask , tx_channel , fhss_structure -> number_of_channels );
545
568
} else if (neighbor_timing_info -> uc_timing_info .unicast_channel_function == WS_VENDOR_DEF_CF ) {
546
569
if (fhss_structure -> ws -> fhss_configuration .vendor_defined_cf ) {
547
570
tx_channel = fhss_structure -> ws -> fhss_configuration .vendor_defined_cf (fhss_structure -> fhss_api , fhss_structure -> ws -> bc_slot , destination_address , fhss_structure -> ws -> fhss_configuration .bsi , neighbor_timing_info -> uc_timing_info .unicast_number_of_channels );
0 commit comments