Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ uint32_t Dispatcher::getCADFailMaxDuration() const {
return 4000; // 4 seconds
}

uint32_t Dispatcher::getMaxTxAirtimeMs() const {
if (_radio->isAS923_1_JP()) return 4000; // ARIB STD-T108: single transmission must be <=4s
return UINT32_MAX; // no limit for other regions
}

void Dispatcher::loop() {
if (millisHasNowPassed(next_floor_calib_time)) {
_radio->triggerNoiseFloorCalibrate(getInterferenceThreshold());
Expand Down Expand Up @@ -325,6 +330,16 @@ void Dispatcher::checkSend() {
} else {
memcpy(&raw[len], outbound->payload, outbound->payload_len); len += outbound->payload_len;

uint32_t send_airtime = _radio->getEstAirtimeFor(len);
if (send_airtime > getMaxTxAirtimeMs()) {
MESH_DEBUG_PRINTLN("%s Dispatcher::checkSend(): DROPPED, airtime %dms exceeds limit", getLogDateTime(), send_airtime);
n_tx_dropped_airtime++;
logTxFail(outbound, len);
releasePacket(outbound);
outbound = NULL;
return;
}

uint32_t max_airtime = _radio->getEstAirtimeFor(len)*3/2;
outbound_start = _ms->getMillis();
bool success = _radio->startSendRaw(raw, len);
Expand Down Expand Up @@ -388,4 +403,4 @@ unsigned long Dispatcher::futureMillis(int millis_from_now) const {
return _ms->getMillis() + millis_from_now;
}

}
}
5 changes: 5 additions & 0 deletions src/Dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class Dispatcher {
bool prev_isrecv_mode;
uint32_t n_sent_flood, n_sent_direct;
uint32_t n_recv_flood, n_recv_direct;
uint32_t n_tx_dropped_airtime; // packets dropped: would exceed getMaxTxAirtimeMs()
unsigned long tx_budget_ms;
unsigned long last_budget_update;
unsigned long duty_cycle_window_ms;
Expand Down Expand Up @@ -157,6 +158,7 @@ class Dispatcher {
tx_budget_ms = 0;
last_budget_update = 0;
duty_cycle_window_ms = 3600000;
n_tx_dropped_airtime = 0;
}

virtual DispatcherAction onRecvPacket(Packet* pkt) = 0;
Expand All @@ -172,6 +174,7 @@ class Dispatcher {
virtual int calcRxDelay(float score, uint32_t air_time) const;
virtual uint32_t getCADFailRetryDelay() const;
virtual uint32_t getCADFailMaxDuration() const;
virtual uint32_t getMaxTxAirtimeMs() const; // single-transmission airtime cap (JP: 4000ms per ARIB STD-T108)
virtual int getInterferenceThreshold() const { return 0; } // disabled by default
virtual bool getCADEnabled() const { return false; } // hardware CAD disabled by default
virtual int getAGCResetInterval() const { return 0; } // disabled by default
Expand All @@ -192,8 +195,10 @@ class Dispatcher {
uint32_t getNumSentDirect() const { return n_sent_direct; }
uint32_t getNumRecvFlood() const { return n_recv_flood; }
uint32_t getNumRecvDirect() const { return n_recv_direct; }
uint32_t getNumTxDroppedAirtime() const { return n_tx_dropped_airtime; }
void resetStats() {
n_sent_flood = n_sent_direct = n_recv_flood = n_recv_direct = 0;
n_tx_dropped_airtime = 0;
_err_flags = 0;
}

Expand Down
Loading