mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Remove redundant send/complete/finished callbacks, use Radio interface directly
This commit is contained in:
parent
362b5eb0a1
commit
00b44c4114
3 changed files with 4 additions and 36 deletions
|
|
@ -20,9 +20,6 @@ KissModem::KissModem(Stream& serial, mesh::LocalIdentity& identity, mesh::RNG& r
|
|||
_setTxPowerCallback = nullptr;
|
||||
_getCurrentRssiCallback = nullptr;
|
||||
_getStatsCallback = nullptr;
|
||||
_sendPacketCallback = nullptr;
|
||||
_isSendCompleteCallback = nullptr;
|
||||
_onSendFinishedCallback = nullptr;
|
||||
_config = {0, 0, 0, 0, 0};
|
||||
_signal_report_enabled = true;
|
||||
}
|
||||
|
|
@ -287,19 +284,14 @@ void KissModem::processTx() {
|
|||
|
||||
case TX_DELAY:
|
||||
if (millis() - _tx_timer >= (uint32_t)_txdelay * 10) {
|
||||
if (_sendPacketCallback) {
|
||||
_sendPacketCallback(_pending_tx, _pending_tx_len);
|
||||
_tx_state = TX_SENDING;
|
||||
} else {
|
||||
_has_pending_tx = false;
|
||||
_tx_state = TX_IDLE;
|
||||
}
|
||||
_radio.startSendRaw(_pending_tx, _pending_tx_len);
|
||||
_tx_state = TX_SENDING;
|
||||
}
|
||||
break;
|
||||
|
||||
case TX_SENDING:
|
||||
if (_isSendCompleteCallback && _isSendCompleteCallback()) {
|
||||
if (_onSendFinishedCallback) _onSendFinishedCallback();
|
||||
if (_radio.isSendComplete()) {
|
||||
_radio.onSendFinished();
|
||||
uint8_t result = 0x01;
|
||||
writeHardwareFrame(HW_RESP_TX_DONE, &result, 1);
|
||||
_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 float (*GetCurrentRssiCallback)();
|
||||
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 {
|
||||
uint32_t freq_hz;
|
||||
|
|
@ -151,9 +148,6 @@ class KissModem {
|
|||
SetTxPowerCallback _setTxPowerCallback;
|
||||
GetCurrentRssiCallback _getCurrentRssiCallback;
|
||||
GetStatsCallback _getStatsCallback;
|
||||
SendPacketCallback _sendPacketCallback;
|
||||
IsSendCompleteCallback _isSendCompleteCallback;
|
||||
OnSendFinishedCallback _onSendFinishedCallback;
|
||||
|
||||
RadioConfig _config;
|
||||
bool _signal_report_enabled;
|
||||
|
|
@ -204,9 +198,6 @@ public:
|
|||
void setTxPowerCallback(SetTxPowerCallback cb) { _setTxPowerCallback = cb; }
|
||||
void setGetCurrentRssiCallback(GetCurrentRssiCallback cb) { _getCurrentRssiCallback = 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);
|
||||
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();
|
||||
}
|
||||
|
||||
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() {
|
||||
board.begin();
|
||||
|
||||
|
|
@ -127,9 +115,6 @@ void setup() {
|
|||
modem->setTxPowerCallback(onSetTxPower);
|
||||
modem->setGetCurrentRssiCallback(onGetCurrentRssi);
|
||||
modem->setGetStatsCallback(onGetStats);
|
||||
modem->setSendPacketCallback(onSendPacket);
|
||||
modem->setIsSendCompleteCallback(onIsSendComplete);
|
||||
modem->setOnSendFinishedCallback(onSendFinished);
|
||||
modem->begin();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue