diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini
index d2311ca..efae249 100644
--- a/arch/esp32/esp32.ini
+++ b/arch/esp32/esp32.ini
@@ -4,52 +4,22 @@ extends = arduino_base
platform = platformio/espressif32 @ 6.3.2
build_src_filter =
- ${arduino_base.build_src_filter} - - - -
+ ${arduino_base.build_src_filter}
upload_speed = 921600
-debug_init_break = tbreak setup
monitor_filters = esp32_exception_decoder
;board_build.filesystem = littlefs
-# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
-# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
-# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
build_flags =
${arduino_base.build_flags}
-Wall
; -Wextra
-Isrc/platform/esp32
-std=c++2a
-; -std=c++11
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
- -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
-DAXP_DEBUG_PORT=Serial
- -DCONFIG_BT_NIMBLE_ENABLED
- -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
- -DCONFIG_BT_NIMBLE_MAX_CCCDS=20
- -DCONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=5120
- -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
- -DSERIAL_BUFFER_SIZE=4096
- ;-DDEBUG_HEAP
-;lib_deps =
-; ${arduino_base.lib_deps}
-; ${networking_base.lib_deps}
-; ${environmental_base.lib_deps}
-; h2zero/NimBLE-Arduino@^1.4.1
-; jgromes/RadioLib@^6.1.0
-; https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6
-
-;lib_ignore =
-; segger_rtt
-; ESP32 BLE Arduino
-
-; leave this commented out to avoid breaking Windows
-;upload_port = /dev/ttyUSB0
-;monitor_port = /dev/ttyUSB0
-
-; customize the partition table
-; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
-;board_build.partitions = partition-table.csv
+lib_deps =
+ ${arduino_base.lib_deps}
diff --git a/arch/esp32/esp32s3.ini b/arch/esp32/esp32s3.ini
new file mode 100644
index 0000000..377c6c0
--- /dev/null
+++ b/arch/esp32/esp32s3.ini
@@ -0,0 +1,2 @@
+[esp32s3_base]
+extends = esp32_base
diff --git a/platformio.ini b/platformio.ini
index cbc6510..95f358e 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -26,24 +26,22 @@ extra_configs =
[env]
;extra_scripts = bin/platformio-custom.py
-build_flags = -Wno-missing-field-initializers
- -Wno-format
-; -Isrc -Isrc/mesh -Isrc/mesh/generated -Isrc/gps -Isrc/buzz -Wl,-Map,.pio/build/output.map
-; -DUSE_THREAD_NAMES
-; -DTINYGPS_OPTION_NO_CUSTOM_FIELDS
-; -DPB_ENABLE_MALLOC=1
+build_flags =
+ -Wl,-Map,.pio/build/output.map
-DRADIOLIB_EXCLUDE_CC1101
-DRADIOLIB_EXCLUDE_NRF24
-DRADIOLIB_EXCLUDE_RF69
-DRADIOLIB_EXCLUDE_SX1231
-DRADIOLIB_EXCLUDE_SI443X
-DRADIOLIB_EXCLUDE_RFM2X
+ -DRADIOLIB_EXCLUDE_RFM9X
+ -DRADIOLIB_EXCLUDE_SX128X
-DRADIOLIB_EXCLUDE_AFSK
+ -DRADIOLIB_EXCLUDE_AX25
-DRADIOLIB_EXCLUDE_HELLSCHREIBER
-DRADIOLIB_EXCLUDE_MORSE
-DRADIOLIB_EXCLUDE_RTTY
-DRADIOLIB_EXCLUDE_SSTV
- -DRADIOLIB_EXCLUDE_AX25
-DRADIOLIB_EXCLUDE_DIRECT_RECEIVE
-DRADIOLIB_EXCLUDE_BELL
-DRADIOLIB_EXCLUDE_PAGER
@@ -69,26 +67,13 @@ check_flags =
--suppressions-list=suppressions.txt
--inline-suppr
-;check_flags = cppcheck: --std=c++20 --suppress=*:*.pio\* --inline-suppr --suppress=unusedFunction --suppress=shadowFunction:*TimeLib.cpp --suppress=unreadVariable:*TimeLib.cpp --suppress=badBitmaskCheck:*project_configuration.cpp
-;test_build_src = yes
+test_build_src = yes
[arduino_base]
framework = arduino
lib_deps =
${env.lib_deps}
-build_flags = ${env.build_flags} -Os -DRADIOLIB_SPI_PARANOID=0
+build_flags = ${env.build_flags} -Os
build_src_filter = ${env.build_src_filter} -
-
-;[env:lora_board]
-;board = esp32doit-devkit-v1
-;build_flags = -Werror -Wall -DUNITY_INCLUDE_PRINT_FORMATTED
-;
-;[env:lora_v3_board]
-;board = heltec_wifi_lora_32_V3
-;build_flags = -Werror -Wall -DUNITY_INCLUDE_PRINT_FORMATTED
-;
-;[env:lora_board_debug]
-;board = esp32doit-devkit-v1
-;build_flags = -Werror -Wall -DCORE_DEBUG_LEVEL=5 -DUNITY_INCLUDE_PRINT_FORMATTED
-;build_type = debug
+debug_init_break = tbreak setup
diff --git a/src/BoardFinder/BoardFinder.cpp b/src/BoardFinder/BoardFinder.cpp
deleted file mode 100644
index f4ed539..0000000
--- a/src/BoardFinder/BoardFinder.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-#include "BoardFinder.h"
-#include "PowerManagement/power_management.h"
-#include
-
-#define MODULE_NAME "BoardFinder"
-
-OledPins::OledPins(int8_t sda, int8_t scl, int8_t reset, int8_t addr) : Sda(sda), Scl(scl), Reset(reset), Addr(addr) {
-}
-
-LoraPins::LoraPins(int8_t sck, int8_t miso, int8_t mosi, int8_t cs, int8_t reset, int8_t irq, LoraModem modem) : Sck(sck), Miso(miso), Mosi(mosi), CS(cs), Reset(reset), IRQ(irq), Modem(modem) {
-}
-
-GpsPins::GpsPins(int8_t rx, int8_t tx) : Rx(rx), Tx(tx) {
-}
-
-EthernetPins::EthernetPins(int8_t mdc, int8_t mdio, int8_t nreset, int8_t addr, int8_t power, eth_clock_mode_t clk, eth_phy_type_t type) : MDC(mdc), MDIO(mdio), nReset(nreset), Addr(addr), Power(power), CLK(clk), Type(type) {
-}
-
-ButtonPins::ButtonPins(int8_t pin) : Pin(pin) {
-}
-
-BoardConfig::BoardConfig(String name, BoardType type, OledPins oled, LoraPins lora, GpsPins gps, EthernetPins ethernet, ButtonPins button, bool needcheckpowerchip, bool powercheckstatus) : Name(name), Type(type), Oled(oled), Lora(lora), Gps(gps), Ethernet(ethernet), Button(button), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) {
-}
-
-BoardFinder::BoardFinder(const std::list &boardConfigs) : _boardConfigs(boardConfigs) {
-}
-
-BoardConfig const *BoardFinder::searchBoardConfig(logging::Logger &logger) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "looking for a board config.");
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "searching for OLED...");
-
- for (BoardConfig const *boardconf : _boardConfigs) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "trying board config: %s", boardconf->Name.c_str());
- if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf, logger) == boardconf->powerCheckStatus) {
- PowerManagement powerManagement;
- Wire.begin(boardconf->Oled.Sda, boardconf->Oled.Scl);
- powerManagement.begin(Wire);
- powerManagement.activateOLED();
- Wire.end();
- } else if (boardconf->needCheckPowerChip) {
- continue;
- }
- if (checkOledConfig(boardconf, logger)) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "found a board config: %s", boardconf->Name.c_str());
- return boardconf;
- }
- }
-
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "could not find OLED, will search for the modem now...");
-
- for (BoardConfig const *boardconf : _boardConfigs) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "trying board config: %s", boardconf->Name.c_str());
- if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf, logger) == boardconf->powerCheckStatus) {
- PowerManagement powerManagement;
- Wire.begin(boardconf->Oled.Sda, boardconf->Oled.Scl);
- powerManagement.begin(Wire);
- powerManagement.activateLoRa();
- Wire.end();
- }
- if (checkModemConfig(boardconf)) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "found a board config: %s", boardconf->Name.c_str());
- return boardconf;
- }
- }
-
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "could not find a board config!");
-
- return 0;
-}
-
-BoardConfig const *BoardFinder::getBoardConfig(String name) {
- std::_List_const_iterator elem = std::find_if(_boardConfigs.begin(), _boardConfigs.end(), [&](BoardConfig const *conf) {
- return conf->Name == name;
- });
- if (elem == _boardConfigs.end()) {
- return 0;
- }
- return *elem;
-}
-
-bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig, logging::Logger &logger) {
- if (boardConfig->Oled.Reset != -1) {
- pinMode(boardConfig->Oled.Reset, OUTPUT);
- digitalWrite(boardConfig->Oled.Reset, HIGH);
- delay(1);
- digitalWrite(boardConfig->Oled.Reset, LOW);
- delay(10);
- digitalWrite(boardConfig->Oled.Reset, HIGH);
- }
- if (!Wire.begin(boardConfig->Oled.Sda, boardConfig->Oled.Scl)) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "issue with wire");
- return false;
- }
- Wire.beginTransmission(boardConfig->Oled.Addr);
- if (!Wire.endTransmission()) {
- Wire.end();
- return true;
- }
- Wire.end();
- return false;
-}
-
-bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) {
- pinMode(boardConfig->Lora.Reset, OUTPUT);
- digitalWrite(boardConfig->Lora.Reset, LOW);
- delay(10);
- digitalWrite(boardConfig->Lora.Reset, HIGH);
- delay(10);
-
- pinMode(boardConfig->Lora.CS, OUTPUT);
- digitalWrite(boardConfig->Lora.CS, HIGH);
-
- SPI.begin(boardConfig->Lora.Sck, boardConfig->Lora.Miso, boardConfig->Lora.Mosi, boardConfig->Lora.CS);
-
- digitalWrite(boardConfig->Lora.CS, LOW);
-
- SPI.beginTransaction(SPISettings(8E6, MSBFIRST, SPI_MODE0));
- SPI.transfer(0x42);
- uint8_t response = SPI.transfer(0x00);
- SPI.endTransaction();
- digitalWrite(boardConfig->Lora.CS, HIGH);
- SPI.end();
- if (response == 0x12) {
- return true;
- }
- return false;
-}
-
-bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logger &logger) {
- if (!Wire.begin(boardConfig->Oled.Sda, boardConfig->Oled.Scl)) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "issue with wire");
- return false;
- }
- Wire.beginTransmission(0x34);
- Wire.write(0x03);
- Wire.endTransmission();
-
- Wire.requestFrom(0x34, 1);
- int response = Wire.read();
- Wire.endTransmission();
- Wire.end();
-
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "wire response: %d", response);
- if (response == 0x03) {
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "power chip found!");
- return true;
- }
- logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "power chip NOT found");
- return false;
-}
-
-// clang-format off
-BoardConfig TTGO_LORA32_V1 ("TTGO_LORA32_V1", eTTGO_LORA32_V1, OledPins( 4, 15), LoraPins( 5, 19, 27, 18, 14, 26, eSX1278));
-BoardConfig TTGO_LORA32_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, OledPins(21, 22), LoraPins( 5, 19, 27, 18, 14, 26, eSX1278));
-BoardConfig TTGO_T_Beam_V0_7 ("TTGO_T_Beam_V0_7", eTTGO_T_Beam_V0_7, OledPins(21, 22), LoraPins( 5, 19, 27, 18, 14, 26, eSX1278), GpsPins(15, 12), EthernetPins(), ButtonPins(38), true);
-BoardConfig TTGO_T_Beam_V1_0 ("TTGO_T_Beam_V1_0", eTTGO_T_Beam_V1_0, OledPins(21, 22), LoraPins( 5, 19, 27, 18, 14, 26, eSX1278), GpsPins(12, 34), EthernetPins(), ButtonPins(38), true, true);
-BoardConfig LILYGO_POE_ETH_BOARD ("LILYGO_POE_ETH_BOARD", eLILYGO_POE_ETH_BOARD, OledPins(33, 32), LoraPins(14, 2, 15, 12, 4, 36, eSX1278), GpsPins(), EthernetPins(23, 18, 5, 0, -1, ETH_CLOCK_GPIO17_OUT, ETH_PHY_LAN8720));
-BoardConfig WT32_ETH_BOARD ("WT32_ETH_BOARD", eWT32_ETH_BOARD, OledPins(17, 5), LoraPins( 4, 12, 14, 15, 33, 32, eSX1278), GpsPins(), EthernetPins(23, 18, -1, 1, 16, ETH_CLOCK_GPIO0_IN, ETH_PHY_LAN8720));
-BoardConfig TRACKERD ("TRACKERD", eTRACKERD, OledPins( 5, 4), LoraPins(18, 19, 23, 16, 14, 26, eSX1278));
-BoardConfig HELTEC_WIFI_LORA_32_V1 ("HELTEC_WIFI_LORA_32_V1", eHELTEC_WIFI_LORA_32_V1, OledPins( 4, 15, 16), LoraPins( 5, 19, 27, 18, 14, 26, eSX1278));
-BoardConfig HELTEC_WIFI_LORA_32_V2 ("HELTEC_WIFI_LORA_32_V2", eHELTEC_WIFI_LORA_32_V2, OledPins( 4, 15, 16), LoraPins( 5, 19, 27, 18, 14, 26, eSX1278));
-BoardConfig HELTEC_WIFI_LORA_32_V3 ("HELTEC_WIFI_LORA_32_V3", eHELTEC_WIFI_LORA_32_V3, OledPins(17, 18, 21), LoraPins( 9, 11, 10, 8, 12, 14, eSX1268));
-BoardConfig GUALTHERIUS_LORAHAM_v100("GUALTHERIUS_LORAHAM_v100", eGUALTHERIUS_LORAHAM_v100, OledPins(17, 16), LoraPins(18, 19, 23, 5, 13, 35, eSX1278));
-BoardConfig GUALTHERIUS_LORAHAM_v106("GUALTHERIUS_LORAHAM_v106", eGUALTHERIUS_LORAHAM_v106, OledPins(17, 16), LoraPins(18, 19, 23, 2, 13, 35, eSX1278));
-// clang-format on
diff --git a/src/BoardFinder/BoardFinder.h b/src/BoardFinder/BoardFinder.h
deleted file mode 100644
index 09d4f2d..0000000
--- a/src/BoardFinder/BoardFinder.h
+++ /dev/null
@@ -1,139 +0,0 @@
-#ifndef BOARD_FINDER_H_
-#define BOARD_FINDER_H_
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-
-class OledPins {
-public:
- explicit OledPins(int8_t sda, int8_t scl, int8_t reset = -1, int8_t addr = 0x3C);
-
- int8_t Sda;
- int8_t Scl;
- int8_t Reset;
- int8_t Addr;
-};
-
-enum LoraModem {
- eSX1278,
- eSX1268,
-};
-
-class LoraPins {
-public:
- explicit LoraPins(int8_t sck, int8_t miso, int8_t mosi, int8_t cs, int8_t reset, int8_t irq, LoraModem modem);
-
- int8_t Sck;
- int8_t Miso;
- int8_t Mosi;
- int8_t CS;
- int8_t Reset;
- int8_t IRQ;
- LoraModem Modem;
-};
-
-class GpsPins {
-public:
- explicit GpsPins(int8_t rx = -1, int8_t tx = -1);
-
- int8_t Rx;
- int8_t Tx;
-};
-
-class EthernetPins {
-public:
- explicit EthernetPins(int8_t mdc = -1, int8_t mdio = -1, int8_t nreset = -1, int8_t addr = 0, int8_t power = -1, eth_clock_mode_t clk = ETH_CLOCK_GPIO17_OUT, eth_phy_type_t type = ETH_PHY_LAN8720);
-
- int8_t MDC;
- int8_t MDIO;
- int8_t nReset;
- int8_t Addr;
- int8_t Power;
-
- eth_clock_mode_t CLK;
- eth_phy_type_t Type;
-
- bool isEthernetBoard() const {
- return MDC != -1;
- }
-};
-
-class ButtonPins {
-public:
- explicit ButtonPins(int8_t pin = -1);
-
- int8_t Pin;
-};
-
-enum BoardType {
- eHELTEC_WIFI_LORA_32_V1,
- eHELTEC_WIFI_LORA_32_V2,
- eHELTEC_WIFI_LORA_32_V3,
- eTTGO_LORA32_V1,
- eTTGO_LORA32_V2,
- eTTGO_T_Beam_V0_7,
- eTTGO_T_Beam_V1_0,
- eLILYGO_POE_ETH_BOARD,
- eWT32_ETH_BOARD,
- eTRACKERD,
- eGUALTHERIUS_LORAHAM_v100,
- eGUALTHERIUS_LORAHAM_v106
-};
-
-class BoardConfig {
-public:
- explicit BoardConfig(String name, BoardType type, OledPins oled, LoraPins lora, GpsPins gps = GpsPins(), EthernetPins ethernet = EthernetPins(), ButtonPins button = ButtonPins(), bool needcheckpowerchip = false, bool powercheckstatus = false);
-
- String Name;
- BoardType Type;
-
- OledPins Oled;
- LoraPins Lora;
- GpsPins Gps;
- EthernetPins Ethernet;
-
- ButtonPins Button;
-
- bool needCheckPowerChip;
- bool powerCheckStatus;
-};
-
-class BoardFinder {
-public:
- explicit BoardFinder(const std::list &boardConfigs);
-
- BoardConfig const *searchBoardConfig(logging::Logger &logger);
-
- BoardConfig const *getBoardConfig(String name);
-
-#ifndef UNIT_TEST
-private:
-#endif
- const std::list &_boardConfigs;
-
- bool checkOledConfig(BoardConfig const *boardConfig, logging::Logger &logger);
- bool checkModemConfig(BoardConfig const *boardConfig);
- bool checkPowerConfig(BoardConfig const *boardConfig, logging::Logger &logger);
-};
-
-extern BoardConfig TTGO_LORA32_V1;
-extern BoardConfig TTGO_LORA32_V2;
-extern BoardConfig TTGO_T_Beam_V0_7;
-extern BoardConfig TTGO_T_Beam_V1_0;
-extern BoardConfig LILYGO_POE_ETH_BOARD;
-extern BoardConfig WT32_ETH_BOARD;
-extern BoardConfig TRACKERD;
-extern BoardConfig HELTEC_WIFI_LORA_32_V1;
-extern BoardConfig HELTEC_WIFI_LORA_32_V2;
-extern BoardConfig HELTEC_WIFI_LORA_32_V3;
-extern BoardConfig GUALTHERIUS_LORAHAM_v100;
-extern BoardConfig GUALTHERIUS_LORAHAM_v106;
-
-#endif
diff --git a/src/Display/Display.cpp b/src/Display/Display.cpp
index 5ae5212..844d756 100644
--- a/src/Display/Display.cpp
+++ b/src/Display/Display.cpp
@@ -8,18 +8,26 @@ Display::Display() : _disp(0), _statusFrame(0), _displaySaveMode(false) {
Display::~Display() {
}
-void Display::setup(BoardConfig const *const boardConfig) {
- if (boardConfig->Oled.Reset != -1) {
- pinMode(boardConfig->Oled.Reset, OUTPUT);
- digitalWrite(boardConfig->Oled.Reset, HIGH);
- delay(1);
- digitalWrite(boardConfig->Oled.Reset, LOW);
- delay(10);
- digitalWrite(boardConfig->Oled.Reset, HIGH);
- }
- Wire.begin(boardConfig->Oled.Sda, boardConfig->Oled.Scl);
- _disp = new SSD1306(&Wire, boardConfig->Oled.Addr);
+void Display::setup() {
+ Serial.println("oled reset");
+#ifdef RESET_OLED
+ pinMode(RESET_OLED, OUTPUT);
+ digitalWrite(RESET_OLED, HIGH);
+ delay(1);
+ digitalWrite(RESET_OLED, LOW);
+ delay(10);
+ digitalWrite(RESET_OLED, HIGH);
+#endif
+ Serial.println("Wire begin");
+#if defined(OLED_SDA) && defined(OLED_SCL)
+ Wire.begin(OLED_SDA, OLED_SCL);
+#else
+ Wire.begin(SDA, SCL);
+#endif
+ Serial.println("SSD1306 init");
+ _disp = new SSD1306(&Wire, 0x3C);
+ Serial.println("SSD1306 setup");
Bitmap bitmap(_disp->getWidth(), _disp->getHeight());
_disp->display(&bitmap);
diff --git a/src/Display/Display.h b/src/Display/Display.h
index d1b6b76..54d6ddf 100644
--- a/src/Display/Display.h
+++ b/src/Display/Display.h
@@ -1,7 +1,6 @@
#ifndef DISPLAY_H_
#define DISPLAY_H_
-#include "BoardFinder/BoardFinder.h"
#include "Display/SSD1306.h"
#include "System/Timer.h"
#include
@@ -27,7 +26,7 @@ public:
Display();
~Display();
- void setup(BoardConfig const *const boardConfig);
+ void setup();
// setup functions
void showSpashScreen(String firmwareTitle, String version);
void setStatusFrame(std::shared_ptr frame);
diff --git a/src/LoRaModem.cpp b/src/LoRaModem.cpp
index 57e4f99..5889a7c 100644
--- a/src/LoRaModem.cpp
+++ b/src/LoRaModem.cpp
@@ -1,15 +1,21 @@
#include "LoRaModem.h"
// SX1278
+#ifdef USE_SX1278
Modem_SX1278::Modem_SX1278() : _radio(0) {
}
-int16_t Modem_SX1278::begin(const LoraPins &lora_pins, const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) {
+int16_t Modem_SX1278::begin(const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) {
float _frequencyRx = (float)lora_config.frequencyRx / 1000000;
float BWkHz = (float)lora_config.signalBandwidth / 1000;
- SPI.begin(lora_pins.Sck, lora_pins.Miso, lora_pins.Mosi, lora_pins.CS);
- _module = new Module(lora_pins.CS, lora_pins.IRQ, lora_pins.Reset);
+#if defined(LORA_SCK) && defined(LORA_MISO) && defined(LORA_MOSI) && defined(LORA_CS)
+ SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
+ _module = new Module(LORA_CS, LORA_IRQ, LORA_RST);
+#else
+ SPI.begin(SCK, MISO, MOSI, SS);
+ _module = new Module(SS, DIO0, RST_LoRa);
+#endif
_radio = new SX1278(_module);
int16_t state = _radio->begin(_frequencyRx, BWkHz, lora_config.spreadingFactor, lora_config.codingRate4, RADIOLIB_SX127X_SYNC_WORD, lora_config.power, preambleLength, lora_config.gainRx);
@@ -67,15 +73,21 @@ uint8_t Modem_SX1278::getModemStatus() {
}
// SX1262
+#elif defined(USE_SX1268)
Modem_SX1268::Modem_SX1268() : _radio(0) {
}
-int16_t Modem_SX1268::begin(const LoraPins &lora_pins, const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) {
+int16_t Modem_SX1268::begin(const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) {
float _frequencyRx = (float)lora_config.frequencyRx / 1000000;
float BWkHz = (float)lora_config.signalBandwidth / 1000;
- SPI.begin(lora_pins.Sck, lora_pins.Miso, lora_pins.Mosi, lora_pins.CS);
- _module = new Module(lora_pins.CS, lora_pins.IRQ, lora_pins.Reset, 13);
+#if defined(LORA_SCK) && defined(LORA_MISO) && defined(LORA_MOSI) && defined(LORA_CS)
+ SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
+ _module = new Module(LORA_CS, LORA_IRQ, LORA_RST, BUSY_LoRa);
+#else
+ SPI.begin(SCK, MISO, MOSI, SS);
+ _module = new Module(SS, DIO0, RST_LoRa, BUSY_LoRa);
+#endif
_radio = new SX1262(_module);
int16_t state = _radio->begin(_frequencyRx, BWkHz, lora_config.spreadingFactor, lora_config.codingRate4, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, lora_config.power, preambleLength);
@@ -131,3 +143,4 @@ float Modem_SX1268::getFrequencyError() {
uint8_t Modem_SX1268::getModemStatus() {
return 0;
}
+#endif
diff --git a/src/LoRaModem.h b/src/LoRaModem.h
index 28a514b..fac6c17 100644
--- a/src/LoRaModem.h
+++ b/src/LoRaModem.h
@@ -3,7 +3,6 @@
#include
-#include "BoardFinder/BoardFinder.h"
#include "project_configuration.h"
class LoRaModem {
@@ -14,7 +13,7 @@ public:
virtual ~LoRaModem() {
}
- virtual int16_t begin(const LoraPins &lora_pins, const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) = 0;
+ virtual int16_t begin(const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) = 0;
virtual int16_t readData(String &str) = 0;
@@ -33,11 +32,12 @@ protected:
Module *_module;
};
+#ifdef USE_SX1278
class Modem_SX1278 : public LoRaModem {
public:
Modem_SX1278();
- int16_t begin(const LoraPins &lora_pins, const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) override;
+ int16_t begin(const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) override;
int16_t readData(String &str) override;
@@ -56,11 +56,12 @@ private:
SX1278 *_radio;
};
+#elif defined(USE_SX1268)
class Modem_SX1268 : public LoRaModem {
public:
Modem_SX1268();
- int16_t begin(const LoraPins &lora_pins, const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) override;
+ int16_t begin(const Configuration::LoRa &lora_config, const uint16_t preambleLength, void (*setFlag)()) override;
int16_t readData(String &str) override;
@@ -78,5 +79,6 @@ public:
private:
SX1262 *_radio;
};
+#endif
#endif
diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp
index a22e9b8..06a4555 100644
--- a/src/LoRa_APRS_iGate.cpp
+++ b/src/LoRa_APRS_iGate.cpp
@@ -2,7 +2,6 @@
#include