@@ -352,44 +352,51 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
352352 fhss_ws_start_timer (fhss_structure , MS_TO_US (fhss_structure -> ws -> fhss_configuration .fhss_bc_dwell_interval ) - ((int64_t ) delay_us * fhss_structure -> platform_functions .fhss_resolution_divider ), fhss_broadcast_handler );
353353 fhss_structure -> ws -> is_on_bc_channel = true;
354354 next_channel = fhss_structure -> ws -> bc_channel = fhss_ws_calc_bc_channel (fhss_structure );
355-
356- /* Start timer with random timeout to trigger broadcast TX queue poll event.
357- * Min random is 1/50 of the channel dwell interval.
358- * Max random is 3/4 of the channel dwell interval.
359- * Event timer resolution is 50us.
360- */
361- uint32_t bc_dwell_us = MS_TO_US (fhss_structure -> ws -> fhss_configuration .fhss_bc_dwell_interval );
362- uint16_t bc_min_random = (bc_dwell_us / 50 ) / 50 ;
363- uint16_t bc_max_random = (bc_dwell_us - (bc_dwell_us / 4 )) / 50 ;
364- eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , randLIB_get_random_in_range (bc_min_random , bc_max_random ));
355+ if (fhss_structure -> ws -> expedited_forwarding_enabled_us ) {
356+ eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , EXPEDITED_FORWARDING_POLL_PERIOD );
357+ } else {
358+ /* Start timer with random timeout to trigger broadcast TX queue poll event.
359+ * Min random is 1/50 of the channel dwell interval.
360+ * Max random is 3/4 of the channel dwell interval.
361+ * Event timer resolution is 50us.
362+ */
363+ uint32_t bc_dwell_us = MS_TO_US (fhss_structure -> ws -> fhss_configuration .fhss_bc_dwell_interval );
364+ uint16_t bc_min_random = (bc_dwell_us / 50 ) / 50 ;
365+ uint16_t bc_max_random = (bc_dwell_us - (bc_dwell_us / 4 )) / 50 ;
366+ eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , randLIB_get_random_in_range (bc_min_random , bc_max_random ));
367+ }
365368 } else {
366369 fhss_structure -> ws -> unicast_start_time_us = fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api );
367370 uint32_t timeout = MS_TO_US (fhss_structure -> ws -> fhss_configuration .fhss_broadcast_interval - fhss_structure -> ws -> fhss_configuration .fhss_bc_dwell_interval );
368371 fhss_ws_start_timer (fhss_structure , timeout - (delay_us * fhss_structure -> platform_functions .fhss_resolution_divider ), fhss_broadcast_handler );
369372 fhss_structure -> ws -> is_on_bc_channel = false;
370373 // Should return to own (unicast) listening channel after broadcast channel
371374 next_channel = fhss_structure -> rx_channel ;
372- /* Start timer with random timeout to trigger unicast TX queue poll event.
373- * For hops 0,1,4,5,8,9,...
374- * Min random is 1/100 of the TX slot length.
375- * Max random is 1/5 of the TX slot length.
376- *
377- * For hops 2,3,6,7,10,11,...
378- * Min random is 1/100 of the TX slot length plus 0.5*TX slot length.
379- * Max random is 1/10 of the TX slot length plus 0.5*TX slot length.
380- * Event timer resolution is 50us.
381- */
382- // returns 1 if polling of TX queue is done on latter half of the TX slot
383- uint8_t own_tx_trig_slot = calc_own_tx_trig_slot (fhss_structure -> own_hop );
384- uint32_t txrx_slot_length_us = MS_TO_US (fhss_structure -> ws -> txrx_slot_length_ms );
385- uint16_t uc_min_random = (((txrx_slot_length_us / 2 ) * own_tx_trig_slot ) / 50 ) + ((txrx_slot_length_us / 100 ) / 50 );
386- uint16_t uc_max_random = (((txrx_slot_length_us / 2 ) * own_tx_trig_slot ) / 50 ) + ((txrx_slot_length_us / 5 ) / 50 );
387- bool tx_allowed = fhss_ws_check_tx_allowed (fhss_structure );
388- if (!tx_allowed ) {
389- uc_min_random += (txrx_slot_length_us ) / 50 ;
390- uc_max_random += (txrx_slot_length_us ) / 50 ;
375+ if (fhss_structure -> ws -> expedited_forwarding_enabled_us ) {
376+ eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , EXPEDITED_FORWARDING_POLL_PERIOD );
377+ } else {
378+ /* Start timer with random timeout to trigger unicast TX queue poll event.
379+ * For hops 0,1,4,5,8,9,...
380+ * Min random is 1/100 of the TX slot length.
381+ * Max random is 1/5 of the TX slot length.
382+ *
383+ * For hops 2,3,6,7,10,11,...
384+ * Min random is 1/100 of the TX slot length plus 0.5*TX slot length.
385+ * Max random is 1/10 of the TX slot length plus 0.5*TX slot length.
386+ * Event timer resolution is 50us.
387+ */
388+ // returns 1 if polling of TX queue is done on latter half of the TX slot
389+ uint8_t own_tx_trig_slot = calc_own_tx_trig_slot (fhss_structure -> own_hop );
390+ uint32_t txrx_slot_length_us = MS_TO_US (fhss_structure -> ws -> txrx_slot_length_ms );
391+ uint16_t uc_min_random = (((txrx_slot_length_us / 2 ) * own_tx_trig_slot ) / 50 ) + ((txrx_slot_length_us / 100 ) / 50 );
392+ uint16_t uc_max_random = (((txrx_slot_length_us / 2 ) * own_tx_trig_slot ) / 50 ) + ((txrx_slot_length_us / 5 ) / 50 );
393+ bool tx_allowed = fhss_ws_check_tx_allowed (fhss_structure );
394+ if (!tx_allowed ) {
395+ uc_min_random += (txrx_slot_length_us ) / 50 ;
396+ uc_max_random += (txrx_slot_length_us ) / 50 ;
397+ }
398+ eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , randLIB_get_random_in_range (uc_min_random , uc_max_random ));
391399 }
392- eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , randLIB_get_random_in_range (uc_min_random , uc_max_random ));
393400
394401#ifdef FHSS_CHANNEL_DEBUG
395402 tr_info ("%" PRIu32 " UC %u" , fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api ), fhss_structure -> rx_channel );
@@ -438,9 +445,19 @@ static void fhss_event_timer_cb(int8_t timer_id, uint16_t slots)
438445 return ;
439446 }
440447
441- // No one would poll TX queue if schedule timers were not started. Start poll timer with 10ms (200*50us) interval.
442- if ((fhss_structure -> ws -> unicast_timer_running == false) && (fhss_structure -> ws -> broadcast_timer_running == false)) {
443- eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , 200 );
448+ if (fhss_structure -> ws -> expedited_forwarding_enabled_us ) {
449+ if ((fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api ) - fhss_structure -> ws -> expedited_forwarding_enabled_us ) > S_TO_US (EXPEDITED_FORWARDING_PERIOD )) {
450+ fhss_structure -> ws -> expedited_forwarding_enabled_us = 0 ;
451+ }
452+ eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , EXPEDITED_FORWARDING_POLL_PERIOD );
453+ if (fhss_structure -> ws -> is_on_bc_channel == true) {
454+ queue_size = fhss_structure -> callbacks .read_tx_queue_size (fhss_structure -> fhss_api , true);
455+ } else {
456+ queue_size = fhss_structure -> callbacks .read_tx_queue_size (fhss_structure -> fhss_api , false);
457+ }
458+ } else if ((fhss_structure -> ws -> unicast_timer_running == false) && (fhss_structure -> ws -> broadcast_timer_running == false)) {
459+ // No one would poll TX queue if schedule timers were not started. Start poll timer with default interval.
460+ eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , DEFAULT_POLL_PERIOD );
444461 queue_size = fhss_structure -> callbacks .read_tx_queue_size (fhss_structure -> fhss_api , false);
445462 } else {
446463 if (fhss_structure -> ws -> is_on_bc_channel == true) {
@@ -535,6 +552,16 @@ static int16_t fhss_ws_synch_state_set_callback(const fhss_api_t *api, fhss_stat
535552 if (!fhss_structure ) {
536553 return -1 ;
537554 }
555+ if (fhss_state == FHSS_EXPEDITED_FORWARDING ) {
556+ if (!fhss_structure -> ws -> expedited_forwarding_enabled_us ) {
557+ eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , EXPEDITED_FORWARDING_POLL_PERIOD );
558+ }
559+ fhss_structure -> ws -> expedited_forwarding_enabled_us = fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api );
560+ if (!fhss_structure -> ws -> expedited_forwarding_enabled_us ) {
561+ fhss_structure -> ws -> expedited_forwarding_enabled_us ++ ;
562+ }
563+ return 0 ;
564+ }
538565 if (fhss_state == FHSS_SYNCHRONIZED ) {
539566 uint32_t fhss_broadcast_interval = fhss_structure -> ws -> fhss_configuration .fhss_broadcast_interval ;
540567 uint8_t fhss_bc_dwell_interval = fhss_structure -> ws -> fhss_configuration .fhss_bc_dwell_interval ;
@@ -1139,9 +1166,9 @@ int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_co
11391166 channel_count_uc = channel_count_bc ;
11401167 }
11411168
1142- // No one would poll TX queue if schedule timers were not started. Start poll timer with 10ms (200*50us) interval.
1169+ // No one would poll TX queue if schedule timers were not started. Start poll timer with default interval.
11431170 if ((fhss_structure -> ws -> unicast_timer_running == false) && (fhss_structure -> ws -> broadcast_timer_running == false)) {
1144- eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , 200 );
1171+ eventOS_callback_timer_start (fhss_structure -> fhss_event_timer , DEFAULT_POLL_PERIOD );
11451172 }
11461173
11471174 fhss_structure -> number_of_channels = fhss_configuration -> channel_mask_size ;
0 commit comments