kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_iGate
Collision avoidance.
rodzic
e0f9f1f5a9
commit
f31781cf75
|
@ -18,6 +18,7 @@
|
||||||
#define REG_FIFO_RX_CURRENT_ADDR 0x10
|
#define REG_FIFO_RX_CURRENT_ADDR 0x10
|
||||||
#define REG_IRQ_FLAGS 0x12
|
#define REG_IRQ_FLAGS 0x12
|
||||||
#define REG_RX_NB_BYTES 0x13
|
#define REG_RX_NB_BYTES 0x13
|
||||||
|
#define REG_MODEM_STAT 0x18
|
||||||
#define REG_PKT_SNR_VALUE 0x19
|
#define REG_PKT_SNR_VALUE 0x19
|
||||||
#define REG_PKT_RSSI_VALUE 0x1a
|
#define REG_PKT_RSSI_VALUE 0x1a
|
||||||
#define REG_RSSI_VALUE 0x1b
|
#define REG_RSSI_VALUE 0x1b
|
||||||
|
@ -251,6 +252,10 @@ float LoRaClass::packetSnr() {
|
||||||
return ((int8_t)readRegister(REG_PKT_SNR_VALUE)) * 0.25;
|
return ((int8_t)readRegister(REG_PKT_SNR_VALUE)) * 0.25;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LoRaClass::rxSignalDetected() {
|
||||||
|
return (readRegister(REG_MODEM_STAT) & 0x01) == 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
long LoRaClass::packetFrequencyError() {
|
long LoRaClass::packetFrequencyError() {
|
||||||
int32_t freqError = 0;
|
int32_t freqError = 0;
|
||||||
freqError = static_cast<int32_t>(readRegister(REG_FREQ_ERROR_MSB) & B111);
|
freqError = static_cast<int32_t>(readRegister(REG_FREQ_ERROR_MSB) & B111);
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
int packetRssi();
|
int packetRssi();
|
||||||
float packetSnr();
|
float packetSnr();
|
||||||
long packetFrequencyError();
|
long packetFrequencyError();
|
||||||
|
bool rxSignalDetected();
|
||||||
|
|
||||||
int rssi();
|
int rssi();
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,10 @@ bool ModemTask::loop(System &system) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_toModem.empty()) {
|
if (!_toModem.empty()) {
|
||||||
|
if (_lora_aprs.rxSignalDetected()) {
|
||||||
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] RX signal detected. Waiting TX", timeString().c_str());
|
||||||
|
delay(1000);
|
||||||
|
} else {
|
||||||
std::shared_ptr<APRSMessage> msg = _toModem.getElement();
|
std::shared_ptr<APRSMessage> msg = _toModem.getElement();
|
||||||
if (system.getUserConfig()->lora.tx_enable) {
|
if (system.getUserConfig()->lora.tx_enable) {
|
||||||
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str());
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str());
|
||||||
|
@ -54,6 +58,7 @@ bool ModemTask::loop(System &system) {
|
||||||
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] NOT transmitting packet as TX is not enabled '%s'", timeString().c_str(), msg->toString().c_str());
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] NOT transmitting packet as TX is not enabled '%s'", timeString().c_str(), msg->toString().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue