Merge pull request #2490 from tuzzmaniandevil/dev

Enhance KissModem frame processing and timeout handling
This commit is contained in:
Liam Cottle
2026-05-08 23:23:14 +12:00
committed by GitHub
2 changed files with 24 additions and 2 deletions
+22 -2
View File
@@ -129,6 +129,8 @@ void KissModem::processFrame() {
memcpy(_pending_tx, data, data_len);
_pending_tx_len = data_len;
_has_pending_tx = true;
} else if (_has_pending_tx) {
writeHardwareError(HW_ERR_TX_BUSY);
}
break;
@@ -257,6 +259,7 @@ void KissModem::processTx() {
_tx_timer = millis();
_tx_state = TX_DELAY;
} else {
_tx_timer = millis();
_tx_state = TX_WAIT_CLEAR;
}
}
@@ -273,19 +276,30 @@ void KissModem::processTx() {
_tx_timer = millis();
_tx_state = TX_SLOT_WAIT;
}
} else if (millis() - _tx_timer >= _radio.getEstAirtimeFor(KISS_MAX_PACKET_SIZE) * KISS_TX_TIMEOUT_FACTOR) {
_tx_timer = millis();
_tx_state = TX_DELAY;
}
break;
case TX_SLOT_WAIT:
if (millis() - _tx_timer >= (uint32_t)_slottime * 10) {
_tx_timer = millis();
_tx_state = TX_WAIT_CLEAR;
}
break;
case TX_DELAY:
if (millis() - _tx_timer >= (uint32_t)_txdelay * 10) {
_radio.startSendRaw(_pending_tx, _pending_tx_len);
_tx_state = TX_SENDING;
if (_radio.startSendRaw(_pending_tx, _pending_tx_len)) {
_tx_timer = millis();
_tx_state = TX_SENDING;
} else {
uint8_t result = 0x00;
writeHardwareFrame(HW_RESP_TX_DONE, &result, 1);
_has_pending_tx = false;
_tx_state = TX_IDLE;
}
}
break;
@@ -296,6 +310,12 @@ void KissModem::processTx() {
writeHardwareFrame(HW_RESP_TX_DONE, &result, 1);
_has_pending_tx = false;
_tx_state = TX_IDLE;
} else if (millis() - _tx_timer >= _radio.getEstAirtimeFor(_pending_tx_len) * KISS_TX_TIMEOUT_FACTOR) {
_radio.onSendFinished();
uint8_t result = 0x00;
writeHardwareFrame(HW_RESP_TX_DONE, &result, 1);
_has_pending_tx = false;
_tx_state = TX_IDLE;
}
break;
}
+2
View File
@@ -26,6 +26,7 @@
#define KISS_DEFAULT_TXDELAY 50
#define KISS_DEFAULT_PERSISTENCE 63
#define KISS_DEFAULT_SLOTTIME 10
#define KISS_TX_TIMEOUT_FACTOR 3/2 // 1.5x estimated airtime
#define HW_CMD_GET_IDENTITY 0x01
#define HW_CMD_GET_RANDOM 0x02
@@ -71,6 +72,7 @@
#define HW_ERR_MAC_FAILED 0x04
#define HW_ERR_UNKNOWN_CMD 0x05
#define HW_ERR_ENCRYPT_FAILED 0x06
#define HW_ERR_TX_BUSY 0x07
#define KISS_FIRMWARE_VERSION 1