mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2025-12-06 07:42:00 +01:00
Avoid collision after TX is done.
This commit is contained in:
parent
2a1475ec72
commit
ebe78ceaad
|
|
@ -38,7 +38,9 @@ bool RadiolibTask::setup(System &system) {
|
|||
float freqMHz = (float)config.frequencyRx / 1000000;
|
||||
float BWkHz = (float)config.signalBandwidth / 1000;
|
||||
|
||||
int16_t state = radio->begin(freqMHz, BWkHz, config.spreadingFactor, config.codingRate4, RADIOLIB_SX127X_SYNC_WORD, config.power /* 2-17 */, 8, config.gainRx);
|
||||
const uint16_t preambleLength = 8;
|
||||
|
||||
int16_t state = radio->begin(freqMHz, BWkHz, config.spreadingFactor, config.codingRate4, RADIOLIB_SX127X_SYNC_WORD, config.power, preambleLength, config.gainRx);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
switch (state) {
|
||||
case RADIOLIB_ERR_INVALID_FREQUENCY:
|
||||
|
|
@ -97,6 +99,8 @@ bool RadiolibTask::setup(System &system) {
|
|||
}
|
||||
}
|
||||
|
||||
preambleDurationMilliSec = ((uint64_t)(preambleLength + 4) << (config.spreadingFactor + 10 /* to milli-sec */)) / config.signalBandwidth;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -117,6 +121,9 @@ bool RadiolibTask::loop(System &system) {
|
|||
operationDone = false;
|
||||
transmitFlag = false;
|
||||
|
||||
txWaitTimer.setTimeout(preambleDurationMilliSec * 2);
|
||||
txWaitTimer.start();
|
||||
|
||||
} else { // received.
|
||||
String str;
|
||||
int state = radio->readData(str);
|
||||
|
|
@ -147,6 +154,8 @@ bool RadiolibTask::loop(System &system) {
|
|||
|
||||
enableInterrupt = true;
|
||||
} else { // not interrupt.
|
||||
if (!txWaitTimer.check()) {
|
||||
} else {
|
||||
if (!txEnable) {
|
||||
// system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX is not enabled", timeString().c_str());
|
||||
} else {
|
||||
|
|
@ -171,6 +180,7 @@ bool RadiolibTask::loop(System &system) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ private:
|
|||
|
||||
int16_t startRX(uint8_t mode);
|
||||
int16_t startTX(String &str);
|
||||
|
||||
uint32_t preambleDurationMilliSec;
|
||||
Timer txWaitTimer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue