@@ -202,6 +202,18 @@ static int32_t fhss_ws_calc_bc_channel(fhss_structure_t *fhss_structure)
202
202
return next_channel ;
203
203
}
204
204
205
+ static uint8_t calc_own_tx_trig_slot (uint8_t own_hop )
206
+ {
207
+ if (own_hop == 0xff ) {
208
+ return 0 ;
209
+ }
210
+ if (own_hop & 1 ) {
211
+ own_hop -- ;
212
+ }
213
+ own_hop /= 2 ;
214
+ return (own_hop & 1 );
215
+ }
216
+
205
217
static void fhss_broadcast_handler (const fhss_api_t * fhss_api , uint16_t delay )
206
218
{
207
219
int32_t next_channel ;
@@ -236,13 +248,20 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
236
248
// Should return to own (unicast) listening channel after broadcast channel
237
249
next_channel = fhss_structure -> rx_channel ;
238
250
/* Start timer with random timeout to trigger unicast TX queue poll event.
239
- * Min random is 1/30 of the TX slot length.
251
+ * For hops 0,1,4,5,8,9,...
252
+ * Min random is 1/100 of the TX slot length.
240
253
* Max random is 1/10 of the TX slot length.
254
+ *
255
+ * For hops 2,3,6,7,10,11,...
256
+ * Min random is 1/100 of the TX slot length plus 0.5*TX slot length.
257
+ * Max random is 1/10 of the TX slot length plus 0.5*TX slot length.
241
258
* Event timer resolution is 50us.
242
259
*/
260
+ // returns 1 if polling of TX queue is done on latter half of the TX slot
261
+ uint8_t own_tx_trig_slot = calc_own_tx_trig_slot (fhss_structure -> own_hop );
243
262
uint32_t txrx_slot_length_us = MS_TO_US (fhss_structure -> ws -> txrx_slot_length_ms );
244
- uint16_t uc_min_random = (txrx_slot_length_us / 30 ) / 50 ;
245
- uint16_t uc_max_random = (txrx_slot_length_us / 10 ) / 50 ;
263
+ uint16_t uc_min_random = ((( txrx_slot_length_us / 2 ) * own_tx_trig_slot ) / 50 ) + (( txrx_slot_length_us / 100 ) / 50 ) ;
264
+ uint16_t uc_max_random = ((( txrx_slot_length_us / 2 ) * own_tx_trig_slot ) / 50 ) + (( txrx_slot_length_us / 10 ) / 50 ) ;
246
265
bool tx_allowed = fhss_ws_check_tx_allowed (fhss_structure );
247
266
if (!tx_allowed ) {
248
267
uc_min_random += (txrx_slot_length_us ) / 50 ;
0 commit comments