* BIG refactor: 'board' and 'radio' objects now defined in 'target.h/.cpp'

* mesh::RTCClock class moved to MeshCore.h
This commit is contained in:
Scott Powell
2025-03-21 18:57:12 +11:00
parent 0a5a115875
commit bfb4b1c496
48 changed files with 726 additions and 407 deletions

View File

@@ -16,6 +16,7 @@
#include <helpers/IdentityStore.h> #include <helpers/IdentityStore.h>
#include <helpers/BaseSerialInterface.h> #include <helpers/BaseSerialInterface.h>
#include <RTClib.h> #include <RTClib.h>
#include <target.h>
/* ---------------------------------- CONFIGURATION ------------------------------------- */ /* ---------------------------------- CONFIGURATION ------------------------------------- */
@@ -59,59 +60,6 @@
#define PUBLIC_GROUP_PSK "izOH6cXN6mrJ5e26oRXNcg==" #define PUBLIC_GROUP_PSK "izOH6cXN6mrJ5e26oRXNcg=="
#if defined(HELTEC_LORA_V3)
#include <helpers/HeltecV3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static HeltecV3Board board;
#elif defined(HELTEC_LORA_V2)
#include <helpers/HeltecV2Board.h>
#include <helpers/CustomSX1276Wrapper.h>
static HeltecV2Board board;
#elif defined(ARDUINO_XIAO_ESP32C3)
#include <helpers/XiaoC3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
static XiaoC3Board board;
#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3)
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static ESP32Board board;
#elif defined(LILYGO_TLORA)
#include <helpers/LilyGoTLoraBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
static LilyGoTLoraBoard board;
#elif defined(RAK_4631)
#include <helpers/nrf52/RAK4631Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static RAK4631Board board;
#elif defined(T1000_E)
#include <helpers/nrf52/T1000eBoard.h>
#include <helpers/CustomLR1110Wrapper.h>
static T1000eBoard board;
#elif defined(HELTEC_T114)
#include <helpers/nrf52/T114Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static T114Board board;
#elif defined(LILYGO_TECHO)
#include <helpers/nrf52/TechoBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
static TechoBoard board;
#elif defined(LILYGO_TBEAM)
#include <helpers/TBeamBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
static TBeamBoard board;
#elif defined(FAKETEC)
#include <helpers/nrf52/faketecBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomLLCC68Wrapper.h>
static faketecBoard board;
#else
#error "need to provide a 'board' object"
#endif
#ifdef DISPLAY_CLASS #ifdef DISPLAY_CLASS
#include "UITask.h" #include "UITask.h"
#include <helpers/ui/SSD1306Display.h> #include <helpers/ui/SSD1306Display.h>
@@ -1473,20 +1421,6 @@ public:
#error "need to define a serial interface" #error "need to define a serial interface"
#endif #endif
#if defined(NRF52_PLATFORM)
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#elif defined(LILYGO_TLORA)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#elif defined(LILYGO_TBEAM)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#elif defined(P_LORA_SCLK)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
StdRNG fast_rng; StdRNG fast_rng;
SimpleMeshTables tables; SimpleMeshTables tables;
MyMesh the_mesh(radio, *new WRAPPER_CLASS(radio, board), fast_rng, *new VolatileRTCClock(), tables); MyMesh the_mesh(radio, *new WRAPPER_CLASS(radio, board), fast_rng, *new VolatileRTCClock(), tables);
@@ -1499,43 +1433,8 @@ void setup() {
Serial.begin(115200); Serial.begin(115200);
board.begin(); board.begin();
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(NRF52_PLATFORM) if (!radio_init()) { halt(); }
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
#elif defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
#if defined(FAKETEC)
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
#define SX126X_DIO3_TCXO_VOLTAGE (0.0f);
tcxo = SX126X_DIO3_TCXO_VOLTAGE;
status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
}
#endif
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
halt();
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
fast_rng.begin(radio.random(0x7FFFFFFF)); fast_rng.begin(radio.random(0x7FFFFFFF));

View File

@@ -18,6 +18,7 @@
#include <helpers/TxtDataHelpers.h> #include <helpers/TxtDataHelpers.h>
#include <helpers/CommonCLI.h> #include <helpers/CommonCLI.h>
#include <RTClib.h> #include <RTClib.h>
#include <target.h>
/* ------------------------------ Config -------------------------------- */ /* ------------------------------ Config -------------------------------- */
@@ -59,52 +60,6 @@
#define ADMIN_PASSWORD "password" #define ADMIN_PASSWORD "password"
#endif #endif
#if defined(HELTEC_LORA_V3)
#include <helpers/HeltecV3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static HeltecV3Board board;
#elif defined(HELTEC_LORA_V2)
#include <helpers/HeltecV2Board.h>
#include <helpers/CustomSX1276Wrapper.h>
static HeltecV2Board board;
#elif defined(ARDUINO_XIAO_ESP32C3)
#include <helpers/XiaoC3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
static XiaoC3Board board;
#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3)
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static ESP32Board board;
#elif defined(LILYGO_TLORA)
#include <helpers/LilyGoTLoraBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
static LilyGoTLoraBoard board;
#elif defined(STATION_G2)
#include <helpers/StationG2Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static StationG2Board board;
#elif defined(RAK_4631)
#include <helpers/nrf52/RAK4631Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static RAK4631Board board;
#elif defined(HELTEC_T114)
#include <helpers/nrf52/T114Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static T114Board board;
#elif defined(LILYGO_TECHO)
#include <helpers/nrf52/TechoBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
static TechoBoard board;
#elif defined(FAKETEC)
#include <helpers/nrf52/faketecBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomLLCC68Wrapper.h>
static faketecBoard board;
#else
#error "need to provide a 'board' object"
#endif
#ifdef DISPLAY_CLASS #ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h> #include <helpers/ui/SSD1306Display.h>
@@ -638,17 +593,6 @@ public:
} }
}; };
#if defined(NRF52_PLATFORM)
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#elif defined(LILYGO_TLORA)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#elif defined(P_LORA_SCLK)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
StdRNG fast_rng; StdRNG fast_rng;
SimpleMeshTables tables; SimpleMeshTables tables;
@@ -677,44 +621,7 @@ void setup() {
#endif #endif
rtc_clock.begin(Wire); rtc_clock.begin(Wire);
#ifdef SX126X_DIO3_TCXO_VOLTAGE if (!radio_init()) { halt(); }
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(NRF52_PLATFORM)
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
#elif defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
#if defined(FAKETEC)
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
#define SX126X_DIO3_TCXO_VOLTAGE (0.0f);
tcxo = SX126X_DIO3_TCXO_VOLTAGE;
status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
}
#endif
if (status != RADIOLIB_ERR_NONE) {
delay(5000);
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
halt();
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
fast_rng.begin(radio.random(0x7FFFFFFF)); fast_rng.begin(radio.random(0x7FFFFFFF));

View File

@@ -18,6 +18,7 @@
#include <helpers/TxtDataHelpers.h> #include <helpers/TxtDataHelpers.h>
#include <helpers/CommonCLI.h> #include <helpers/CommonCLI.h>
#include <RTClib.h> #include <RTClib.h>
#include <target.h>
/* ------------------------------ Config -------------------------------- */ /* ------------------------------ Config -------------------------------- */
@@ -67,52 +68,6 @@
#define MAX_UNSYNCED_POSTS 16 #define MAX_UNSYNCED_POSTS 16
#endif #endif
#if defined(HELTEC_LORA_V3)
#include <helpers/HeltecV3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static HeltecV3Board board;
#elif defined(HELTEC_LORA_V2)
#include <helpers/HeltecV2Board.h>
#include <helpers/CustomSX1276Wrapper.h>
static HeltecV2Board board;
#elif defined(ARDUINO_XIAO_ESP32C3)
#include <helpers/XiaoC3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
static XiaoC3Board board;
#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3)
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static ESP32Board board;
#elif defined(LILYGO_TLORA)
#include <helpers/LilyGoTLoraBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
static LilyGoTLoraBoard board;
#elif defined(STATION_G2)
#include <helpers/StationG2Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static StationG2Board board;
#elif defined(RAK_4631)
#include <helpers/nrf52/RAK4631Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static RAK4631Board board;
#elif defined(HELTEC_T114)
#include <helpers/nrf52/T114Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static T114Board board;
#elif defined(LILYGO_TECHO)
#include <helpers/nrf52/TechoBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
static TechoBoard board;
#elif defined(FAKETEC)
#include <helpers/nrf52/faketecBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomLLCC68Wrapper.h>
static faketecBoard board;
#else
#error "need to provide a 'board' object"
#endif
#ifdef DISPLAY_CLASS #ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h> #include <helpers/ui/SSD1306Display.h>
@@ -773,17 +728,6 @@ public:
} }
}; };
#if defined(NRF52_PLATFORM)
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#elif defined(LILYGO_TLORA)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#elif defined(P_LORA_SCLK)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
StdRNG fast_rng; StdRNG fast_rng;
SimpleMeshTables tables; SimpleMeshTables tables;
@@ -812,44 +756,7 @@ void setup() {
#endif #endif
rtc_clock.begin(Wire); rtc_clock.begin(Wire);
#ifdef SX126X_DIO3_TCXO_VOLTAGE if (!radio_init()) { halt(); }
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(NRF52_PLATFORM)
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
#elif defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
#if defined(FAKETEC)
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
#define SX126X_DIO3_TCXO_VOLTAGE (0.0f);
tcxo = SX126X_DIO3_TCXO_VOLTAGE;
status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
}
#endif
if (status != RADIOLIB_ERR_NONE) {
delay(5000);
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
halt();
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
fast_rng.begin(radio.random(0x7FFFFFFF)); fast_rng.begin(radio.random(0x7FFFFFFF));

View File

@@ -15,6 +15,7 @@
#include <helpers/SimpleMeshTables.h> #include <helpers/SimpleMeshTables.h>
#include <helpers/IdentityStore.h> #include <helpers/IdentityStore.h>
#include <RTClib.h> #include <RTClib.h>
#include <target.h>
/* ---------------------------------- CONFIGURATION ------------------------------------- */ /* ---------------------------------- CONFIGURATION ------------------------------------- */
@@ -49,44 +50,6 @@
#define PUBLIC_GROUP_PSK "izOH6cXN6mrJ5e26oRXNcg==" #define PUBLIC_GROUP_PSK "izOH6cXN6mrJ5e26oRXNcg=="
#if defined(HELTEC_LORA_V3)
#include <helpers/HeltecV3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static HeltecV3Board board;
#elif defined(HELTEC_LORA_V2)
#include <helpers/HeltecV2Board.h>
#include <helpers/CustomSX1276Wrapper.h>
static HeltecV2Board board;
#elif defined(ARDUINO_XIAO_ESP32C3)
#include <helpers/XiaoC3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
static XiaoC3Board board;
#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3)
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static ESP32Board board;
#elif defined(LILYGO_TLORA)
#include <helpers/LilyGoTLoraBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
static LilyGoTLoraBoard board;
#elif defined(RAK_4631)
#include <helpers/nrf52/RAK4631Board.h>
#include <helpers/CustomSX1262Wrapper.h>
static RAK4631Board board;
#elif defined(T1000_E)
#include <helpers/nrf52/T1000eBoard.h>
#include <helpers/CustomLR1110Wrapper.h>
static T1000eBoard board;
#elif defined(FAKETEC)
#include <helpers/nrf52/faketecBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomLLCC68Wrapper.h>
static faketecBoard board;
#else
#error "need to provide a 'board' object"
#endif
// Believe it or not, this std C function is busted on some platforms! // Believe it or not, this std C function is busted on some platforms!
static uint32_t _atoi(const char* sp) { static uint32_t _atoi(const char* sp) {
uint32_t n = 0; uint32_t n = 0;
@@ -548,17 +511,6 @@ public:
} }
}; };
#if defined(NRF52_PLATFORM)
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#elif defined(LILYGO_TLORA)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#elif defined(P_LORA_SCLK)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
StdRNG fast_rng; StdRNG fast_rng;
SimpleMeshTables tables; SimpleMeshTables tables;
MyMesh the_mesh(*new WRAPPER_CLASS(radio, board), fast_rng, *new VolatileRTCClock(), tables); MyMesh the_mesh(*new WRAPPER_CLASS(radio, board), fast_rng, *new VolatileRTCClock(), tables);
@@ -571,34 +523,8 @@ void setup() {
Serial.begin(115200); Serial.begin(115200);
board.begin(); board.begin();
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(NRF52_PLATFORM) if (!radio_init()) { halt(); }
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
#elif defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
halt();
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
fast_rng.begin(radio.random(0x7FFFFFFF)); fast_rng.begin(radio.random(0x7FFFFFFF));

View File

@@ -4,34 +4,6 @@
namespace mesh { namespace mesh {
/**
* An abstraction of the device's Realtime Clock.
*/
class RTCClock {
uint32_t last_unique;
protected:
RTCClock() { last_unique = 0; }
public:
/**
* \returns the current time. in UNIX epoch seconds.
*/
virtual uint32_t getCurrentTime() = 0;
/**
* \param time current time in UNIX epoch seconds.
*/
virtual void setCurrentTime(uint32_t time) = 0;
uint32_t getCurrentTimeUnique() {
uint32_t t = getCurrentTime();
if (t <= last_unique) {
return ++last_unique;
}
return last_unique = t;
}
};
class GroupChannel { class GroupChannel {
public: public:
uint8_t hash[PATH_HASH_SIZE]; uint8_t hash[PATH_HASH_SIZE];

View File

@@ -45,4 +45,32 @@ public:
virtual bool startOTAUpdate() { return false; } // not supported virtual bool startOTAUpdate() { return false; } // not supported
}; };
/**
* An abstraction of the device's Realtime Clock.
*/
class RTCClock {
uint32_t last_unique;
protected:
RTCClock() { last_unique = 0; }
public:
/**
* \returns the current time. in UNIX epoch seconds.
*/
virtual uint32_t getCurrentTime() = 0;
/**
* \param time current time in UNIX epoch seconds.
*/
virtual void setCurrentTime(uint32_t time) = 0;
uint32_t getCurrentTimeUnique() {
uint32_t t = getCurrentTime();
if (t <= last_unique) {
return ++last_unique;
}
return last_unique = t;
}
};
} }

View File

@@ -7,6 +7,7 @@
#include <rom/rtc.h> #include <rom/rtc.h>
#include <sys/time.h> #include <sys/time.h>
#include <Wire.h>
class ESP32Board : public mesh::MainBoard { class ESP32Board : public mesh::MainBoard {
protected: protected:

View File

@@ -6,7 +6,7 @@
static BLEDfu bledfu; static BLEDfu bledfu;
void faketecBoard::begin() { void FaketecBoard::begin() {
// for future use, sub-classes SHOULD call this from their begin() // for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL; startup_reason = BD_STARTUP_NORMAL;
btn_prev_state = HIGH; btn_prev_state = HIGH;
@@ -39,7 +39,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
MESH_DEBUG_PRINTLN("BLE client disconnected"); MESH_DEBUG_PRINTLN("BLE client disconnected");
} }
bool faketecBoard::startOTAUpdate() { bool FaketecBoard::startOTAUpdate() {
// Config the peripheral connection with maximum bandwidth // Config the peripheral connection with maximum bandwidth
// more SRAM required by SoftDevice // more SRAM required by SoftDevice
// Note: All config***() function must be called before begin() // Note: All config***() function must be called before begin()

View File

@@ -20,7 +20,7 @@
#define PIN_VBAT_READ 17 #define PIN_VBAT_READ 17
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking #define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
class faketecBoard : public mesh::MainBoard { class FaketecBoard : public mesh::MainBoard {
protected: protected:
uint8_t startup_reason; uint8_t startup_reason;
uint8_t btn_prev_state; uint8_t btn_prev_state;

View File

@@ -3,6 +3,7 @@ extends = esp32_base
board = heltec_wifi_lora_32_V2 ; heltec_wifi_lora_32_V2 board = heltec_wifi_lora_32_V2 ; heltec_wifi_lora_32_V2
build_flags = build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-I variants/heltec_v2
-D HELTEC_LORA_V2 -D HELTEC_LORA_V2
-D PIN_BOARD_SDA=4 -D PIN_BOARD_SDA=4
-D PIN_BOARD_SCL=15 -D PIN_BOARD_SCL=15
@@ -13,6 +14,7 @@ build_flags =
-D LORA_TX_POWER=20 -D LORA_TX_POWER=20
-D P_LORA_TX_LED=25 -D P_LORA_TX_LED=25
build_src_filter = ${esp32_base.build_src_filter} build_src_filter = ${esp32_base.build_src_filter}
+<../variants/heltec_v2>
lib_deps = lib_deps =
${esp32_base.lib_deps} ${esp32_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13 adafruit/Adafruit SSD1306 @ ^2.5.13

View File

@@ -0,0 +1,31 @@
#include <Arduino.h>
#include "target.h"
HeltecV2Board board;
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/HeltecV2Board.h>
#include <helpers/CustomSX1276Wrapper.h>
extern HeltecV2Board board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -3,6 +3,7 @@ extends = esp32_base
board = esp32-s3-devkitc-1 board = esp32-s3-devkitc-1
build_flags = build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-I variants/heltec_v3
-D HELTEC_LORA_V3 -D HELTEC_LORA_V3
-D RADIO_CLASS=CustomSX1262 -D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper -D WRAPPER_CLASS=CustomSX1262Wrapper
@@ -16,6 +17,7 @@ build_flags =
-D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power!
-D SX126X_RX_BOOSTED_GAIN=1 -D SX126X_RX_BOOSTED_GAIN=1
build_src_filter = ${esp32_base.build_src_filter} build_src_filter = ${esp32_base.build_src_filter}
+<../variants/heltec_v3>
lib_deps = lib_deps =
${esp32_base.lib_deps} ${esp32_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13 adafruit/Adafruit SSD1306 @ ^2.5.13

View File

@@ -0,0 +1,47 @@
#include <Arduino.h>
#include "target.h"
HeltecV3Board board;
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/HeltecV3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
extern HeltecV3Board board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -3,6 +3,7 @@ extends = esp32_base
board = t3_s3_v1_x board = t3_s3_v1_x
build_flags = build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-I variants/lilygo_t3s3
-D LILYGO_T3S3 -D LILYGO_T3S3
-D P_LORA_DIO_1=33 -D P_LORA_DIO_1=33
-D P_LORA_NSS=7 -D P_LORA_NSS=7
@@ -26,6 +27,7 @@ build_flags =
-D LORA_TX_POWER=22 -D LORA_TX_POWER=22
-D SX126X_RX_BOOSTED_GAIN=1 -D SX126X_RX_BOOSTED_GAIN=1
build_src_filter = ${esp32_base.build_src_filter} build_src_filter = ${esp32_base.build_src_filter}
+<../variants/lilygo_t3s3>
lib_deps = lib_deps =
${esp32_base.lib_deps} ${esp32_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13 adafruit/Adafruit SSD1306 @ ^2.5.13

View File

@@ -0,0 +1,47 @@
#include <Arduino.h>
#include "target.h"
ESP32Board board;
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
extern ESP32Board board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -3,12 +3,14 @@ extends = esp32_base
board = ttgo-t-beam board = ttgo-t-beam
build_flags = build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-I variants/lilygo_tbeam
-D LILYGO_TBEAM -D LILYGO_TBEAM
-D RADIO_CLASS=CustomSX1276 -D RADIO_CLASS=CustomSX1276
-D WRAPPER_CLASS=CustomSX1276Wrapper -D WRAPPER_CLASS=CustomSX1276Wrapper
-D LORA_TX_POWER=20 -D LORA_TX_POWER=20
-D P_LORA_TX_LED=4 -D P_LORA_TX_LED=4
build_src_filter = ${esp32_base.build_src_filter} build_src_filter = ${esp32_base.build_src_filter}
+<../variants/lilygo_tbeam>
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
[env:Tbeam_companion_radio_ble] [env:Tbeam_companion_radio_ble]

View File

@@ -0,0 +1,31 @@
#include <Arduino.h>
#include "target.h"
TBeamBoard board;
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/TBeamBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
extern TBeamBoard board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -6,6 +6,7 @@ build_type = release ; Set build type to release
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
build_flags = build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-I variants/lilygo_tlora_v2_1
-Os -ffunction-sections -fdata-sections ; Optimize for size -Os -ffunction-sections -fdata-sections ; Optimize for size
-D LILYGO_TLORA ; LILYGO T-LoRa V2.1-1.6 ESP32 with SX1276 -D LILYGO_TLORA ; LILYGO T-LoRa V2.1-1.6 ESP32 with SX1276
-D P_LORA_DIO_0=26 ; SX1276 DIO0 interrupt pin -D P_LORA_DIO_0=26 ; SX1276 DIO0 interrupt pin
@@ -23,6 +24,8 @@ build_flags =
-D DISPLAY_CLASS=SSD1306Display -D DISPLAY_CLASS=SSD1306Display
-D WRAPPER_CLASS=CustomSX1276Wrapper -D WRAPPER_CLASS=CustomSX1276Wrapper
-D LORA_TX_POWER=20 -D LORA_TX_POWER=20
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/lilygo_tlora_v2_1>
lib_deps = lib_deps =
${esp32_base.lib_deps} ${esp32_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13 adafruit/Adafruit SSD1306 @ ^2.5.13

View File

@@ -0,0 +1,25 @@
#include <Arduino.h>
#include "target.h"
LilyGoTLoraBoard board;
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/LilyGoTLoraBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
extern LilyGoTLoraBoard board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -1,8 +1,10 @@
[faketec] [faketec]
extends = nrf52840_base extends = nrf52840_base
board = promicro_nrf52840 board = promicro_nrf52840
build_src_filter = ${nrf52840_base.build_src_filter} +<helpers/nrf52/faketecBoard.cpp>
build_flags = ${nrf52840_base.build_flags} build_flags = ${nrf52840_base.build_flags}
-I src
-I src/helpers/nrf52
-I variants/promicro_nrf52840
-D FAKETEC -D FAKETEC
-D RADIO_CLASS=CustomSX1262 -D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper -D WRAPPER_CLASS=CustomSX1262Wrapper
@@ -14,6 +16,9 @@ build_flags = ${nrf52840_base.build_flags}
-D PIN_BOARD_SDA=8 -D PIN_BOARD_SDA=8
-D PIN_OLED_RESET=-1 -D PIN_OLED_RESET=-1
-D PIN_USER_BTN=6 -D PIN_USER_BTN=6
build_src_filter = ${nrf52840_base.build_src_filter}
+<helpers/nrf52/FaketecBoard.cpp>
+<../variants/promicro_nrf52840>
lib_deps= lib_deps=
${nrf52840_base.lib_deps} ${nrf52840_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13 adafruit/Adafruit SSD1306 @ ^2.5.13
@@ -98,14 +103,17 @@ lib_deps =
[ProMicroLLCC68] [ProMicroLLCC68]
extends = nrf52840_base extends = nrf52840_base
board = promicro_nrf52840 board = promicro_nrf52840
build_src_filter = ${nrf52840_base.build_src_filter} +<helpers/nrf52/faketecBoard.cpp>
build_flags = ${nrf52840_base.build_flags} build_flags = ${nrf52840_base.build_flags}
-I variants/promicro_nrf52840
-D FAKETEC -D FAKETEC
-D RADIO_CLASS=CustomLLCC68 -D RADIO_CLASS=CustomLLCC68
-D WRAPPER_CLASS=CustomLLCC68Wrapper -D WRAPPER_CLASS=CustomLLCC68Wrapper
-D LORA_TX_POWER=22 -D LORA_TX_POWER=22
-D SX126X_CURRENT_LIMIT=130 -D SX126X_CURRENT_LIMIT=130
-D SX126X_RX_BOOSTED_GAIN=1 -D SX126X_RX_BOOSTED_GAIN=1
build_src_filter = ${nrf52840_base.build_src_filter}
+<helpers/nrf52/FaketecBoard.cpp>
+<../variants/promicro_nrf52840>
[env:ProMicroLLCC68_Repeater] [env:ProMicroLLCC68_Repeater]
extends = ProMicroLLCC68 extends = ProMicroLLCC68

View File

@@ -0,0 +1,46 @@
#include <Arduino.h>
#include "target.h"
FaketecBoard board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
#define SX126X_DIO3_TCXO_VOLTAGE (0.0f);
tcxo = SX126X_DIO3_TCXO_VOLTAGE;
status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
}
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include <FaketecBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomLLCC68Wrapper.h>
extern FaketecBoard board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -4,6 +4,7 @@ platform = https://github.com/maxgerhardt/platform-nordicnrf52.git#rak
board = wiscore_rak4631 board = wiscore_rak4631
board_check = true board_check = true
build_flags = ${nrf52840_base.build_flags} build_flags = ${nrf52840_base.build_flags}
-I variants/rak4631
-D RAK_4631 -D RAK_4631
-D PIN_USER_BTN=9 -D PIN_USER_BTN=9
-D RADIO_CLASS=CustomSX1262 -D RADIO_CLASS=CustomSX1262
@@ -13,6 +14,7 @@ build_flags = ${nrf52840_base.build_flags}
-D SX126X_RX_BOOSTED_GAIN=1 -D SX126X_RX_BOOSTED_GAIN=1
build_src_filter = ${nrf52840_base.build_src_filter} build_src_filter = ${nrf52840_base.build_src_filter}
+<helpers/nrf52/*.cpp> +<helpers/nrf52/*.cpp>
+<../variants/rak4631>
lib_deps = lib_deps =
${nrf52840_base.lib_deps} ${nrf52840_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13 adafruit/Adafruit SSD1306 @ ^2.5.13

View File

@@ -0,0 +1,41 @@
#include <Arduino.h>
#include "target.h"
RAK4631Board board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/nrf52/RAK4631Board.h>
#include <helpers/CustomSX1262Wrapper.h>
extern RAK4631Board board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -3,6 +3,7 @@ extends = esp32_base
board = station-g2 board = station-g2
build_flags = build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-I variants/station_g2
-D STATION_G2 -D STATION_G2
-D RADIO_CLASS=CustomSX1262 -D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper -D WRAPPER_CLASS=CustomSX1262Wrapper
@@ -16,8 +17,8 @@ build_flags =
-D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power!
; -D SX126X_RX_BOOSTED_GAIN=1 - DO NOT ENABLE THIS! ; -D SX126X_RX_BOOSTED_GAIN=1 - DO NOT ENABLE THIS!
; https://wiki.uniteng.com/en/meshtastic/station-g2#impact-of-lora-node-dense-areashigh-noise-environments-on-rf-performance ; https://wiki.uniteng.com/en/meshtastic/station-g2#impact-of-lora-node-dense-areashigh-noise-environments-on-rf-performance
build_src_filter = ${esp32_base.build_src_filter} build_src_filter = ${esp32_base.build_src_filter}
+<../variants/station_g2>
lib_deps = lib_deps =
${esp32_base.lib_deps} ${esp32_base.lib_deps}

View File

@@ -0,0 +1,47 @@
#include <Arduino.h>
#include "target.h"
StationG2Board board;
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/StationG2Board.h>
#include <helpers/CustomSX1262Wrapper.h>
extern StationG2Board board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -19,14 +19,14 @@ extends = nrf52840_t1000e
board = tracker-t1000-e board = tracker-t1000-e
board_build.ldscript = boards/nrf52840_s140_v7.ld board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52840_t1000e.build_flags} build_flags = ${nrf52840_t1000e.build_flags}
-Ivariants/t1000-e -I variants/t1000-e
-D T1000_E -D T1000_E
-D PIN_USER_BTN=6 -D PIN_USER_BTN=6
-D USER_BTN_PRESSED=HIGH -D USER_BTN_PRESSED=HIGH
-D PIN_STATUS_LED=24 -D PIN_STATUS_LED=24
-D RADIO_CLASS=CustomLR1110 -D RADIO_CLASS=CustomLR1110
-D WRAPPER_CLASS=CustomLR1110Wrapper -D WRAPPER_CLASS=CustomLR1110Wrapper
-D MAX_LORA_TX_POWER=22 -D LORA_TX_POWER=22
build_src_filter = ${nrf52840_t1000e.build_src_filter} build_src_filter = ${nrf52840_t1000e.build_src_filter}
+<helpers/*.cpp> +<helpers/*.cpp>
+<helpers/nrf52/T1000eBoard.cpp> +<helpers/nrf52/T1000eBoard.cpp>

View File

@@ -0,0 +1,41 @@
#include <Arduino.h>
#include "target.h"
T1000eBoard board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/nrf52/T1000eBoard.h>
#include <helpers/CustomLR1110Wrapper.h>
extern T1000eBoard board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -14,7 +14,7 @@ extends = nrf52840_t114
board = heltec_t114 board = heltec_t114
board_build.ldscript = boards/nrf52840_s140_v6.ld board_build.ldscript = boards/nrf52840_s140_v6.ld
build_flags = ${nrf52840_t114.build_flags} build_flags = ${nrf52840_t114.build_flags}
-Ivariants/t114 -I variants/t114
-DHELTEC_T114 -DHELTEC_T114
-D P_LORA_TX_LED=35 -D P_LORA_TX_LED=35
-D RADIO_CLASS=CustomSX1262 -D RADIO_CLASS=CustomSX1262

41
variants/t114/target.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include <Arduino.h>
#include "target.h"
T114Board board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

9
variants/t114/target.h Normal file
View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/nrf52/T114Board.h>
#include <helpers/CustomSX1262Wrapper.h>
extern T114Board board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -14,7 +14,7 @@ extends = nrf52840_techo
board = t-echo board = t-echo
board_build.ldscript = boards/nrf52840_s140_v6.ld board_build.ldscript = boards/nrf52840_s140_v6.ld
build_flags = ${nrf52840_techo.build_flags} build_flags = ${nrf52840_techo.build_flags}
-Ivariants/techo -I variants/techo
-DLILYGO_TECHO -DLILYGO_TECHO
-D RADIO_CLASS=CustomSX1262 -D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper -D WRAPPER_CLASS=CustomSX1262Wrapper

41
variants/techo/target.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include <Arduino.h>
#include "target.h"
TechoBoard board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

9
variants/techo/target.h Normal file
View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/nrf52/TechoBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
extern TechoBoard board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -3,6 +3,7 @@ extends = esp32_base
board = seeed_xiao_esp32c3 board = seeed_xiao_esp32c3
build_flags = build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-I variants/xiao_c3
-D LORA_TX_BOOST_PIN=D3 -D LORA_TX_BOOST_PIN=D3
-D P_LORA_TX_LED=D5 -D P_LORA_TX_LED=D5
-D PIN_VBAT_READ=D0 -D PIN_VBAT_READ=D0
@@ -15,6 +16,8 @@ build_flags =
-D SX126X_DIO2_AS_RF_SWITCH=true -D SX126X_DIO2_AS_RF_SWITCH=true
-D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power!
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/xiao_c3>
[env:Xiao_C3_Repeater_sx1262] [env:Xiao_C3_Repeater_sx1262]
extends = Xiao_esp32_C3 extends = Xiao_esp32_C3

View File

@@ -0,0 +1,47 @@
#include <Arduino.h>
#include "target.h"
XiaoC3Board board;
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

10
variants/xiao_c3/target.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
#include <helpers/XiaoC3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
extern XiaoC3Board board;
extern RADIO_CLASS radio;
bool radio_init();

View File

@@ -4,6 +4,7 @@ board = seeed_xiao_esp32s3
board_check = true board_check = true
board_build.mcu = esp32s3 board_build.mcu = esp32s3
build_flags = ${esp32_base.build_flags} build_flags = ${esp32_base.build_flags}
-I variants/xiao_s3_wio
-D SEEED_XIAO_S3 -D SEEED_XIAO_S3
-D P_LORA_DIO_1=39 -D P_LORA_DIO_1=39
-D P_LORA_NSS=41 -D P_LORA_NSS=41
@@ -19,6 +20,8 @@ build_flags = ${esp32_base.build_flags}
-D WRAPPER_CLASS=CustomSX1262Wrapper -D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22 -D LORA_TX_POWER=22
-D SX126X_RX_BOOSTED_GAIN=1 -D SX126X_RX_BOOSTED_GAIN=1
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/xiao_s3_wio>
[env:Xiao_S3_WIO_Repeater] [env:Xiao_S3_WIO_Repeater]
extends = Xiao_S3_WIO extends = Xiao_S3_WIO

View File

@@ -0,0 +1,47 @@
#include <Arduino.h>
#include "target.h"
ESP32Board board;
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
extern ESP32Board board;
extern RADIO_CLASS radio;
bool radio_init();