File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -271,19 +271,21 @@ void Dispatcher::processRecvPacket(Packet* pkt) {
271271 }
272272}
273273
274- void Dispatcher::checkSend () {
275- if (_mgr->getOutboundCount (_ms->getMillis ()) == 0 ) return ;
276-
277- updateTxBudget ();
278-
279- uint32_t est_airtime = _radio->getEstAirtimeFor (MAX_TRANS_UNIT);
274+ void Dispatcher::ensureTxDutyCycle (int tx_len) {
275+ uint32_t est_airtime = _radio->getEstAirtimeFor (tx_len);
280276 if (tx_budget_ms < est_airtime / MIN_TX_BUDGET_AIRTIME_DIV) {
281277 float duty_cycle = 1 .0f / (1 .0f + getAirtimeBudgetFactor ());
282278 unsigned long needed = est_airtime / MIN_TX_BUDGET_AIRTIME_DIV - tx_budget_ms;
283279 next_tx_time = futureMillis ((unsigned long )(needed / duty_cycle));
284- return ;
285280 }
286-
281+ }
282+
283+ void Dispatcher::checkSend () {
284+ if (_mgr->getOutboundCount (_ms->getMillis ()) == 0 ) return ;
285+
286+ updateTxBudget ();
287+ ensureTxDutyCycle (MAX_TRANS_UNIT);
288+
287289 if (!millisHasNowPassed (next_tx_time)) return ;
288290 if (_radio->isReceiving ()) {
289291 if (cad_busy_start == 0 ) {
Original file line number Diff line number Diff line change @@ -195,6 +195,13 @@ class Dispatcher {
195195
196196private:
197197 bool tryParsePacket (Packet* pkt, const uint8_t * raw, int len);
198+ /* *
199+ * \brief ensure the next tx time obeys the duty cycle
200+ *
201+ * Internally this updates the next_tx_time so that the Tx
202+ * is executed by earliest the next allowed time slot.
203+ */
204+ void ensureTxDutyCycle (int tx_len);
198205 void checkRecv ();
199206 void checkSend ();
200207};
You can’t perform that action at this time.
0 commit comments