Added RadioLib based carrier detect

pull/25/head
sh123 2021-10-20 20:53:50 +03:00
rodzic e0b45711a7
commit eb12b0309f
5 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -26,6 +26,7 @@
#define CFG_LORA_PIN_DIO1 LORA_IRQ // not used in arduino-LoRa
#define CFG_LORA_USE_ISR false // set to true for ISR usage
#endif
#define CFG_LORA_USE_CAD false // set to true to utilize carrier detection
#define CFG_LORA_FREQ 433.775E6
#define CFG_LORA_BW 125e3

Wyświetl plik

@ -43,6 +43,7 @@ void initializeConfig(LoraPrs::Config &cfg) {
cfg.LoraPinDio0 = CFG_LORA_PIN_DIO0;
cfg.LoraPinDio1 = CFG_LORA_PIN_DIO1; // valid for radiolib only
cfg.LoraUseIsr = CFG_LORA_USE_ISR; // set to true for incoming packet ISR usage (stream mode, e.g. speech)
cfg.LoraUseCad = CFG_LORA_USE_CAD; // carrier detect
// aprs configuration
cfg.AprsHost = "rotate.aprs2.net";

Wyświetl plik

@ -24,6 +24,7 @@ struct Config
byte LoraPinDio0; // lora dio0 pin
byte LoraPinDio1; // lora dio1 pin
bool LoraUseIsr; // true to use interrupts, false for fallback polling, e.g. if Dio0 is not connected
bool LoraUseCad; // use carrier detect before transmitting
// bluetooth
String BtName; // bluetooth device name for the client, set to empty string to disable bluetooth in server mode

Wyświetl plik

@ -225,7 +225,7 @@ void Service::loop()
if (!isRigToSerialProcessed) {
long currentTime = millis();
if (currentTime > csmaSlotTimePrev_ + csmaSlotTime_ && random(0, 255) < csmaP_) {
if (!isLoraRxBusy() && currentTime > csmaSlotTimePrev_ + csmaSlotTime_ && random(0, 255) < csmaP_) {
if (aprsisConn_.available() > 0) {
onAprsisDataAvailable();
}
@ -251,6 +251,14 @@ void Service::loop()
delay(CfgPollDelayMs);
}
bool Service::isLoraRxBusy() {
#ifdef USE_RADIOLIB
return cfg_.LoraUseCad && (radio_->getModemStatus() & 0x01); // SX1278_STATUS_SIG_DETECT
#else
return false;
#endif
}
#ifdef USE_RADIOLIB
ICACHE_RAM_ATTR void Service::onLoraDataAvailableIsr() {

Wyświetl plik

@ -39,6 +39,7 @@ private:
void reconnectWifi() const;
bool reconnectAprsis();
bool isLoraRxBusy();
#ifdef USE_RADIOLIB
void onLoraDataAvailable();
static ICACHE_RAM_ATTR void onLoraDataAvailableIsr();