Skip to content

Commit 3f0e56c

Browse files
author
Jarkko Paso
committed
FHSS WS: TX poll improvement to enhance hidden node situations
1 parent 5fe7120 commit 3f0e56c

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ static int32_t fhss_ws_calc_bc_channel(fhss_structure_t *fhss_structure)
202202
return next_channel;
203203
}
204204

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+
205217
static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
206218
{
207219
int32_t next_channel;
@@ -236,13 +248,20 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
236248
// Should return to own (unicast) listening channel after broadcast channel
237249
next_channel = fhss_structure->rx_channel;
238250
/* 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.
240253
* 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.
241258
* Event timer resolution is 50us.
242259
*/
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);
243262
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);
246265
bool tx_allowed = fhss_ws_check_tx_allowed(fhss_structure);
247266
if (!tx_allowed) {
248267
uc_min_random += (txrx_slot_length_us) / 50;

0 commit comments

Comments
 (0)