diff --git a/esp32_loraprs.ino b/esp32_loraprs.ino index 756446a..e450d2d 100644 --- a/esp32_loraprs.ino +++ b/esp32_loraprs.ino @@ -13,7 +13,7 @@ auto watchdogLedTimer = timer_create_default(); void initializeConfig() { // client/server mode switch - cfg.IsClientMode = false; + cfg.IsClientMode = true; // lora parameters cfg.LoraFreq = 433.775E6; @@ -22,6 +22,7 @@ void initializeConfig() { cfg.LoraCodingRate = 7; cfg.LoraSync = 0x34; cfg.LoraPower = 20; + cfg.LoraEnableCrc = true; // set to false for speech data // aprs configuration cfg.AprsHost = "rotate.aprs2.net"; diff --git a/loraprs_config.h b/loraprs_config.h index ee52b57..b8f5069 100644 --- a/loraprs_config.h +++ b/loraprs_config.h @@ -15,6 +15,7 @@ struct Config byte LoraCodingRate; // lora coding rate, e.g. 7 byte LoraSync; // lora sync word/packet id, 0x3f byte LoraPower; // lora power level in dbm, 20 + bool LoraEnableCrc; // lora crc check enabled int AprsPort; // aprs server port, 14580 String AprsHost; // aprs server hostname, rotate.aprs2.net diff --git a/loraprs_service.cpp b/loraprs_service.cpp index a316780..07c4773 100644 --- a/loraprs_service.cpp +++ b/loraprs_service.cpp @@ -44,7 +44,8 @@ void Service::setup(const Config &conf) enableBeacon_ = conf.EnableBeacon; // peripherals - setupLora(conf.LoraFreq, conf.LoraBw, conf.LoraSf, conf.LoraCodingRate, conf.LoraPower, conf.LoraSync); + setupLora(conf.LoraFreq, conf.LoraBw, conf.LoraSf, + conf.LoraCodingRate, conf.LoraPower, conf.LoraSync, conf.LoraEnableCrc); if (needsWifi()) { setupWifi(conf.WifiSsid, conf.WifiKey); @@ -104,7 +105,7 @@ bool Service::reconnectAprsis() return true; } -void Service::setupLora(int loraFreq, int bw, byte sf, byte cr, byte pwr, byte sync) +void Service::setupLora(int loraFreq, int bw, byte sf, byte cr, byte pwr, byte sync, bool enableCrc) { Serial.print("LoRa init..."); @@ -119,7 +120,9 @@ void Service::setupLora(int loraFreq, int bw, byte sf, byte cr, byte pwr, byte s LoRa.setSignalBandwidth(bw); LoRa.setCodingRate4(cr); LoRa.setTxPower(pwr); - LoRa.enableCrc(); + if (enableCrc) { + LoRa.enableCrc(); + } Serial.println("ok"); } diff --git a/loraprs_service.h b/loraprs_service.h index b599299..803e6ea 100644 --- a/loraprs_service.h +++ b/loraprs_service.h @@ -22,7 +22,7 @@ public: private: void setupWifi(const String &wifiName, const String &wifiKey); - void setupLora(int loraFreq, int bw, byte sf, byte cr, byte pwr, byte sync); + void setupLora(int loraFreq, int bw, byte sf, byte cr, byte pwr, byte sync, bool enableCrc); void setupBt(const String &btName); void reconnectWifi();