kopia lustrzana https://github.com/sh123/esp32_loraprs
Added RadioLib based carrier detect
rodzic
e0b45711a7
commit
eb12b0309f
1
config.h
1
config.h
|
@ -26,6 +26,7 @@
|
||||||
#define CFG_LORA_PIN_DIO1 LORA_IRQ // not used in arduino-LoRa
|
#define CFG_LORA_PIN_DIO1 LORA_IRQ // not used in arduino-LoRa
|
||||||
#define CFG_LORA_USE_ISR false // set to true for ISR usage
|
#define CFG_LORA_USE_ISR false // set to true for ISR usage
|
||||||
#endif
|
#endif
|
||||||
|
#define CFG_LORA_USE_CAD false // set to true to utilize carrier detection
|
||||||
|
|
||||||
#define CFG_LORA_FREQ 433.775E6
|
#define CFG_LORA_FREQ 433.775E6
|
||||||
#define CFG_LORA_BW 125e3
|
#define CFG_LORA_BW 125e3
|
||||||
|
|
|
@ -43,6 +43,7 @@ void initializeConfig(LoraPrs::Config &cfg) {
|
||||||
cfg.LoraPinDio0 = CFG_LORA_PIN_DIO0;
|
cfg.LoraPinDio0 = CFG_LORA_PIN_DIO0;
|
||||||
cfg.LoraPinDio1 = CFG_LORA_PIN_DIO1; // valid for radiolib only
|
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.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
|
// aprs configuration
|
||||||
cfg.AprsHost = "rotate.aprs2.net";
|
cfg.AprsHost = "rotate.aprs2.net";
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct Config
|
||||||
byte LoraPinDio0; // lora dio0 pin
|
byte LoraPinDio0; // lora dio0 pin
|
||||||
byte LoraPinDio1; // lora dio1 pin
|
byte LoraPinDio1; // lora dio1 pin
|
||||||
bool LoraUseIsr; // true to use interrupts, false for fallback polling, e.g. if Dio0 is not connected
|
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
|
// bluetooth
|
||||||
String BtName; // bluetooth device name for the client, set to empty string to disable bluetooth in server mode
|
String BtName; // bluetooth device name for the client, set to empty string to disable bluetooth in server mode
|
||||||
|
|
|
@ -225,7 +225,7 @@ void Service::loop()
|
||||||
if (!isRigToSerialProcessed) {
|
if (!isRigToSerialProcessed) {
|
||||||
|
|
||||||
long currentTime = millis();
|
long currentTime = millis();
|
||||||
if (currentTime > csmaSlotTimePrev_ + csmaSlotTime_ && random(0, 255) < csmaP_) {
|
if (!isLoraRxBusy() && currentTime > csmaSlotTimePrev_ + csmaSlotTime_ && random(0, 255) < csmaP_) {
|
||||||
if (aprsisConn_.available() > 0) {
|
if (aprsisConn_.available() > 0) {
|
||||||
onAprsisDataAvailable();
|
onAprsisDataAvailable();
|
||||||
}
|
}
|
||||||
|
@ -251,6 +251,14 @@ void Service::loop()
|
||||||
delay(CfgPollDelayMs);
|
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
|
#ifdef USE_RADIOLIB
|
||||||
|
|
||||||
ICACHE_RAM_ATTR void Service::onLoraDataAvailableIsr() {
|
ICACHE_RAM_ATTR void Service::onLoraDataAvailableIsr() {
|
||||||
|
|
|
@ -39,6 +39,7 @@ private:
|
||||||
void reconnectWifi() const;
|
void reconnectWifi() const;
|
||||||
bool reconnectAprsis();
|
bool reconnectAprsis();
|
||||||
|
|
||||||
|
bool isLoraRxBusy();
|
||||||
#ifdef USE_RADIOLIB
|
#ifdef USE_RADIOLIB
|
||||||
void onLoraDataAvailable();
|
void onLoraDataAvailable();
|
||||||
static ICACHE_RAM_ATTR void onLoraDataAvailableIsr();
|
static ICACHE_RAM_ATTR void onLoraDataAvailableIsr();
|
||||||
|
|
Ładowanie…
Reference in New Issue