Remove redundant send/complete/finished callbacks, use Radio interface directly
This commit is contained in:
@@ -20,9 +20,6 @@ KissModem::KissModem(Stream& serial, mesh::LocalIdentity& identity, mesh::RNG& r
|
|||||||
_setTxPowerCallback = nullptr;
|
_setTxPowerCallback = nullptr;
|
||||||
_getCurrentRssiCallback = nullptr;
|
_getCurrentRssiCallback = nullptr;
|
||||||
_getStatsCallback = nullptr;
|
_getStatsCallback = nullptr;
|
||||||
_sendPacketCallback = nullptr;
|
|
||||||
_isSendCompleteCallback = nullptr;
|
|
||||||
_onSendFinishedCallback = nullptr;
|
|
||||||
_config = {0, 0, 0, 0, 0};
|
_config = {0, 0, 0, 0, 0};
|
||||||
_signal_report_enabled = true;
|
_signal_report_enabled = true;
|
||||||
}
|
}
|
||||||
@@ -287,19 +284,14 @@ void KissModem::processTx() {
|
|||||||
|
|
||||||
case TX_DELAY:
|
case TX_DELAY:
|
||||||
if (millis() - _tx_timer >= (uint32_t)_txdelay * 10) {
|
if (millis() - _tx_timer >= (uint32_t)_txdelay * 10) {
|
||||||
if (_sendPacketCallback) {
|
_radio.startSendRaw(_pending_tx, _pending_tx_len);
|
||||||
_sendPacketCallback(_pending_tx, _pending_tx_len);
|
_tx_state = TX_SENDING;
|
||||||
_tx_state = TX_SENDING;
|
|
||||||
} else {
|
|
||||||
_has_pending_tx = false;
|
|
||||||
_tx_state = TX_IDLE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TX_SENDING:
|
case TX_SENDING:
|
||||||
if (_isSendCompleteCallback && _isSendCompleteCallback()) {
|
if (_radio.isSendComplete()) {
|
||||||
if (_onSendFinishedCallback) _onSendFinishedCallback();
|
_radio.onSendFinished();
|
||||||
uint8_t result = 0x01;
|
uint8_t result = 0x01;
|
||||||
writeHardwareFrame(HW_RESP_TX_DONE, &result, 1);
|
writeHardwareFrame(HW_RESP_TX_DONE, &result, 1);
|
||||||
_has_pending_tx = false;
|
_has_pending_tx = false;
|
||||||
|
|||||||
@@ -101,9 +101,6 @@ typedef void (*SetRadioCallback)(float freq, float bw, uint8_t sf, uint8_t cr);
|
|||||||
typedef void (*SetTxPowerCallback)(uint8_t power);
|
typedef void (*SetTxPowerCallback)(uint8_t power);
|
||||||
typedef float (*GetCurrentRssiCallback)();
|
typedef float (*GetCurrentRssiCallback)();
|
||||||
typedef void (*GetStatsCallback)(uint32_t* rx, uint32_t* tx, uint32_t* errors);
|
typedef void (*GetStatsCallback)(uint32_t* rx, uint32_t* tx, uint32_t* errors);
|
||||||
typedef void (*SendPacketCallback)(const uint8_t* data, uint16_t len);
|
|
||||||
typedef bool (*IsSendCompleteCallback)();
|
|
||||||
typedef void (*OnSendFinishedCallback)();
|
|
||||||
|
|
||||||
struct RadioConfig {
|
struct RadioConfig {
|
||||||
uint32_t freq_hz;
|
uint32_t freq_hz;
|
||||||
@@ -151,9 +148,6 @@ class KissModem {
|
|||||||
SetTxPowerCallback _setTxPowerCallback;
|
SetTxPowerCallback _setTxPowerCallback;
|
||||||
GetCurrentRssiCallback _getCurrentRssiCallback;
|
GetCurrentRssiCallback _getCurrentRssiCallback;
|
||||||
GetStatsCallback _getStatsCallback;
|
GetStatsCallback _getStatsCallback;
|
||||||
SendPacketCallback _sendPacketCallback;
|
|
||||||
IsSendCompleteCallback _isSendCompleteCallback;
|
|
||||||
OnSendFinishedCallback _onSendFinishedCallback;
|
|
||||||
|
|
||||||
RadioConfig _config;
|
RadioConfig _config;
|
||||||
bool _signal_report_enabled;
|
bool _signal_report_enabled;
|
||||||
@@ -204,9 +198,6 @@ public:
|
|||||||
void setTxPowerCallback(SetTxPowerCallback cb) { _setTxPowerCallback = cb; }
|
void setTxPowerCallback(SetTxPowerCallback cb) { _setTxPowerCallback = cb; }
|
||||||
void setGetCurrentRssiCallback(GetCurrentRssiCallback cb) { _getCurrentRssiCallback = cb; }
|
void setGetCurrentRssiCallback(GetCurrentRssiCallback cb) { _getCurrentRssiCallback = cb; }
|
||||||
void setGetStatsCallback(GetStatsCallback cb) { _getStatsCallback = cb; }
|
void setGetStatsCallback(GetStatsCallback cb) { _getStatsCallback = cb; }
|
||||||
void setSendPacketCallback(SendPacketCallback cb) { _sendPacketCallback = cb; }
|
|
||||||
void setIsSendCompleteCallback(IsSendCompleteCallback cb) { _isSendCompleteCallback = cb; }
|
|
||||||
void setOnSendFinishedCallback(OnSendFinishedCallback cb) { _onSendFinishedCallback = cb; }
|
|
||||||
|
|
||||||
void onPacketReceived(int8_t snr, int8_t rssi, const uint8_t* packet, uint16_t len);
|
void onPacketReceived(int8_t snr, int8_t rssi, const uint8_t* packet, uint16_t len);
|
||||||
bool isTxBusy() const { return _tx_state != TX_IDLE; }
|
bool isTxBusy() const { return _tx_state != TX_IDLE; }
|
||||||
|
|||||||
@@ -70,18 +70,6 @@ void onGetStats(uint32_t* rx, uint32_t* tx, uint32_t* errors) {
|
|||||||
*errors = radio_driver.getPacketsRecvErrors();
|
*errors = radio_driver.getPacketsRecvErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onSendPacket(const uint8_t* data, uint16_t len) {
|
|
||||||
radio_driver.startSendRaw(data, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool onIsSendComplete() {
|
|
||||||
return radio_driver.isSendComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onSendFinished() {
|
|
||||||
radio_driver.onSendFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
board.begin();
|
board.begin();
|
||||||
|
|
||||||
@@ -127,9 +115,6 @@ void setup() {
|
|||||||
modem->setTxPowerCallback(onSetTxPower);
|
modem->setTxPowerCallback(onSetTxPower);
|
||||||
modem->setGetCurrentRssiCallback(onGetCurrentRssi);
|
modem->setGetCurrentRssiCallback(onGetCurrentRssi);
|
||||||
modem->setGetStatsCallback(onGetStats);
|
modem->setGetStatsCallback(onGetStats);
|
||||||
modem->setSendPacketCallback(onSendPacket);
|
|
||||||
modem->setIsSendCompleteCallback(onIsSendComplete);
|
|
||||||
modem->setOnSendFinishedCallback(onSendFinished);
|
|
||||||
modem->begin();
|
modem->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user