Skip to content
Open
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
23 changes: 21 additions & 2 deletions examples/kiss_modem/KissModem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ void KissModem::processFrame() {
memcpy(_pending_tx, data, data_len);
_pending_tx_len = data_len;
_has_pending_tx = true;
} else if (_has_pending_tx) {
uint8_t result = 0x00;
writeHardwareFrame(HW_RESP_TX_DONE, &result, 1);
}
break;

Expand Down Expand Up @@ -257,6 +260,7 @@ void KissModem::processTx() {
_tx_timer = millis();
_tx_state = TX_DELAY;
} else {
_tx_timer = millis();
_tx_state = TX_WAIT_CLEAR;
}
}
Expand All @@ -273,19 +277,28 @@ 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 {
_has_pending_tx = false;
_tx_state = TX_IDLE;
}
}
break;

Expand All @@ -296,6 +309,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;
}
Expand Down
1 change: 1 addition & 0 deletions examples/kiss_modem/KissModem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down