Skip to content

Commit 00b44c4

Browse files
Remove redundant send/complete/finished callbacks, use Radio interface directly
1 parent 362b5eb commit 00b44c4

3 files changed

Lines changed: 4 additions & 36 deletions

File tree

examples/kiss_modem/KissModem.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ KissModem::KissModem(Stream& serial, mesh::LocalIdentity& identity, mesh::RNG& r
2020
_setTxPowerCallback = nullptr;
2121
_getCurrentRssiCallback = nullptr;
2222
_getStatsCallback = nullptr;
23-
_sendPacketCallback = nullptr;
24-
_isSendCompleteCallback = nullptr;
25-
_onSendFinishedCallback = nullptr;
2623
_config = {0, 0, 0, 0, 0};
2724
_signal_report_enabled = true;
2825
}
@@ -287,19 +284,14 @@ void KissModem::processTx() {
287284

288285
case TX_DELAY:
289286
if (millis() - _tx_timer >= (uint32_t)_txdelay * 10) {
290-
if (_sendPacketCallback) {
291-
_sendPacketCallback(_pending_tx, _pending_tx_len);
292-
_tx_state = TX_SENDING;
293-
} else {
294-
_has_pending_tx = false;
295-
_tx_state = TX_IDLE;
296-
}
287+
_radio.startSendRaw(_pending_tx, _pending_tx_len);
288+
_tx_state = TX_SENDING;
297289
}
298290
break;
299291

300292
case TX_SENDING:
301-
if (_isSendCompleteCallback && _isSendCompleteCallback()) {
302-
if (_onSendFinishedCallback) _onSendFinishedCallback();
293+
if (_radio.isSendComplete()) {
294+
_radio.onSendFinished();
303295
uint8_t result = 0x01;
304296
writeHardwareFrame(HW_RESP_TX_DONE, &result, 1);
305297
_has_pending_tx = false;

examples/kiss_modem/KissModem.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ typedef void (*SetRadioCallback)(float freq, float bw, uint8_t sf, uint8_t cr);
101101
typedef void (*SetTxPowerCallback)(uint8_t power);
102102
typedef float (*GetCurrentRssiCallback)();
103103
typedef void (*GetStatsCallback)(uint32_t* rx, uint32_t* tx, uint32_t* errors);
104-
typedef void (*SendPacketCallback)(const uint8_t* data, uint16_t len);
105-
typedef bool (*IsSendCompleteCallback)();
106-
typedef void (*OnSendFinishedCallback)();
107104

108105
struct RadioConfig {
109106
uint32_t freq_hz;
@@ -151,9 +148,6 @@ class KissModem {
151148
SetTxPowerCallback _setTxPowerCallback;
152149
GetCurrentRssiCallback _getCurrentRssiCallback;
153150
GetStatsCallback _getStatsCallback;
154-
SendPacketCallback _sendPacketCallback;
155-
IsSendCompleteCallback _isSendCompleteCallback;
156-
OnSendFinishedCallback _onSendFinishedCallback;
157151

158152
RadioConfig _config;
159153
bool _signal_report_enabled;
@@ -204,9 +198,6 @@ class KissModem {
204198
void setTxPowerCallback(SetTxPowerCallback cb) { _setTxPowerCallback = cb; }
205199
void setGetCurrentRssiCallback(GetCurrentRssiCallback cb) { _getCurrentRssiCallback = cb; }
206200
void setGetStatsCallback(GetStatsCallback cb) { _getStatsCallback = cb; }
207-
void setSendPacketCallback(SendPacketCallback cb) { _sendPacketCallback = cb; }
208-
void setIsSendCompleteCallback(IsSendCompleteCallback cb) { _isSendCompleteCallback = cb; }
209-
void setOnSendFinishedCallback(OnSendFinishedCallback cb) { _onSendFinishedCallback = cb; }
210201

211202
void onPacketReceived(int8_t snr, int8_t rssi, const uint8_t* packet, uint16_t len);
212203
bool isTxBusy() const { return _tx_state != TX_IDLE; }

examples/kiss_modem/main.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,6 @@ void onGetStats(uint32_t* rx, uint32_t* tx, uint32_t* errors) {
7070
*errors = radio_driver.getPacketsRecvErrors();
7171
}
7272

73-
void onSendPacket(const uint8_t* data, uint16_t len) {
74-
radio_driver.startSendRaw(data, len);
75-
}
76-
77-
bool onIsSendComplete() {
78-
return radio_driver.isSendComplete();
79-
}
80-
81-
void onSendFinished() {
82-
radio_driver.onSendFinished();
83-
}
84-
8573
void setup() {
8674
board.begin();
8775

@@ -127,9 +115,6 @@ void setup() {
127115
modem->setTxPowerCallback(onSetTxPower);
128116
modem->setGetCurrentRssiCallback(onGetCurrentRssi);
129117
modem->setGetStatsCallback(onGetStats);
130-
modem->setSendPacketCallback(onSendPacket);
131-
modem->setIsSendCompleteCallback(onIsSendComplete);
132-
modem->setOnSendFinishedCallback(onSendFinished);
133118
modem->begin();
134119
}
135120

0 commit comments

Comments
 (0)