Merge branch 'dev' into solar-watchdog

This commit is contained in:
Quency-D 2026-02-09 10:15:50 +08:00 committed by GitHub
commit 9df34e09d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
254 changed files with 5226 additions and 972 deletions

View file

@ -75,7 +75,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -38,7 +38,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -17,5 +17,5 @@ extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -25,7 +25,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
// no-op
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio_driver.setTxPower(dbm);
}

View file

@ -12,5 +12,5 @@ extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -27,7 +27,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -16,5 +16,5 @@ extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -44,7 +44,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern MomentaryButton user_btn;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -44,7 +44,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern MomentaryButton user_btn;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -20,9 +20,9 @@
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
class MeshSolarBoard : public NRF52BoardOTA {
class MeshSolarBoard : public NRF52BoardDCDC {
public:
MeshSolarBoard() : NRF52BoardOTA("MESH_SOLAR_OTA") {}
MeshSolarBoard() : NRF52Board("MESH_SOLAR_OTA") {}
void begin();
uint16_t getBattMilliVolts() override {

View file

@ -35,7 +35,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -53,5 +53,5 @@ extern SolarExWatchdog ex_watchdog;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -3,9 +3,37 @@
#include <Arduino.h>
#include <Wire.h>
#ifdef NRF52_POWER_MANAGEMENT
// Static configuration for power management
// Values come from variant.h defines
const PowerMgtConfig power_config = {
.lpcomp_ain_channel = PWRMGT_LPCOMP_AIN,
.lpcomp_refsel = PWRMGT_LPCOMP_REFSEL,
.voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK
};
void T114Board::initiateShutdown(uint8_t reason) {
#if ENV_INCLUDE_GPS == 1
pinMode(GPS_EN, OUTPUT);
digitalWrite(GPS_EN, LOW);
#endif
digitalWrite(SX126X_POWER_EN, LOW);
bool enable_lpcomp = (reason == SHUTDOWN_REASON_LOW_VOLTAGE ||
reason == SHUTDOWN_REASON_BOOT_PROTECT);
pinMode(PIN_BAT_CTL, OUTPUT);
digitalWrite(PIN_BAT_CTL, enable_lpcomp ? HIGH : LOW);
if (enable_lpcomp) {
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);
}
enterSystemOff(reason);
}
#endif // NRF52_POWER_MANAGEMENT
void T114Board::begin() {
NRF52Board::begin();
NRF_POWER->DCDCEN = 1;
pinMode(PIN_VBAT_READ, INPUT);
@ -21,6 +49,11 @@ void T114Board::begin() {
#endif
pinMode(SX126X_POWER_EN, OUTPUT);
#ifdef NRF52_POWER_MANAGEMENT
// Boot voltage protection check (may not return if voltage too low)
// We need to call this after we configure SX126X_POWER_EN as output but before we pull high
checkBootVoltage(&power_config);
#endif
digitalWrite(SX126X_POWER_EN, HIGH);
delay(10); // give sx1262 some time to power up
}

View file

@ -9,9 +9,14 @@
#define PIN_BAT_CTL 6
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
class T114Board : public NRF52BoardOTA {
class T114Board : public NRF52BoardDCDC {
protected:
#ifdef NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
public:
T114Board() : NRF52BoardOTA("T114_OTA") {}
T114Board() : NRF52Board("T114_OTA") {}
void begin();
#if defined(P_LORA_TX_LED)
@ -42,13 +47,13 @@ public:
}
void powerOff() override {
#ifdef LED_PIN
#ifdef LED_PIN
digitalWrite(LED_PIN, HIGH);
#endif
#if ENV_INCLUDE_GPS == 1
#endif
#if ENV_INCLUDE_GPS == 1
pinMode(GPS_EN, OUTPUT);
digitalWrite(GPS_EN, LOW);
#endif
#endif
sd_power_system_off();
}
};

View file

@ -6,11 +6,13 @@ extends = nrf52_base
board = heltec_t114
board_build.ldscript = boards/nrf52840_s140_v6.ld
build_flags = ${nrf52_base.build_flags}
${sensor_base.build_flags}
-I lib/nrf52/s140_nrf52_6.1.1_API/include
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
-I variants/heltec_t114
-I src/helpers/ui
-D HELTEC_T114
-D NRF52_POWER_MANAGEMENT
-D P_LORA_DIO_1=20
-D P_LORA_NSS=24
-D P_LORA_RESET=25
@ -27,20 +29,20 @@ build_flags = ${nrf52_base.build_flags}
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D DISPLAY_CLASS=NullDisplayDriver
-D ST7789
-D PIN_GPS_RX=39
-D PIN_GPS_TX=37
-D PIN_GPS_EN=21
-D PIN_GPS_RESET=38
-D PIN_GPS_RESET_ACTIVE=LOW
-D ENV_PIN_SDA=PIN_WIRE1_SDA
-D ENV_PIN_SCL=PIN_WIRE1_SCL
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<../variants/heltec_t114>
lib_deps =
${nrf52_base.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
adafruit/Adafruit GFX Library @ ^1.12.1
${sensor_base.lib_deps}
debug_tool = jlink
upload_protocol = nrfutil
@ -99,6 +101,7 @@ board_upload.maximum_size = 712704
build_flags =
${Heltec_t114.build_flags}
-I examples/companion_radio/ui-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
@ -121,6 +124,7 @@ board_upload.maximum_size = 712704
build_flags =
${Heltec_t114.build_flags}
-I examples/companion_radio/ui-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
; -D BLE_PIN_CODE=123456
@ -143,6 +147,7 @@ extends = Heltec_t114
board = heltec_t114
board_build.ldscript = boards/nrf52840_s140_v6.ld
build_flags = ${Heltec_t114.build_flags}
-D ST7789
-D HELTEC_T114_WITH_DISPLAY
-D DISPLAY_CLASS=ST7789Display
build_src_filter = ${Heltec_t114.build_src_filter}
@ -152,6 +157,7 @@ build_src_filter = ${Heltec_t114.build_src_filter}
+<helpers/ui/OLEDDisplayFonts.cpp>
lib_deps =
${Heltec_t114.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13
debug_tool = jlink
upload_protocol = nrfutil

View file

@ -1,28 +1,46 @@
#include <Arduino.h>
#include "target.h"
#include <Arduino.h>
#include <helpers/ArduinoHelpers.h>
#ifdef ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
#endif
T114Board board;
#if defined(P_LORA_SCLK)
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
WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
T114SensorManager sensors = T114SensorManager(nmea);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
#endif
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
#endif
bool radio_init() {
rtc_clock.begin(Wire);
#if defined(P_LORA_SCLK)
return radio.std_init(&SPI);
#else
return radio.std_init();
#endif
}
uint32_t radio_get_rng_seed() {
@ -36,98 +54,11 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
void T114SensorManager::start_gps() {
if (!gps_active) {
gps_active = true;
_location->begin();
}
}
void T114SensorManager::stop_gps() {
if (gps_active) {
gps_active = false;
_location->stop();
}
}
bool T114SensorManager::begin() {
Serial1.begin(9600);
// Try to detect if GPS is physically connected to determine if we should expose the setting
pinMode(GPS_EN, OUTPUT);
digitalWrite(GPS_EN, HIGH); // Power on GPS
// Give GPS a moment to power up and send data
delay(1500);
// We'll consider GPS detected if we see any data on Serial1
gps_detected = (Serial1.available() > 0);
if (gps_detected) {
MESH_DEBUG_PRINTLN("GPS detected");
} else {
MESH_DEBUG_PRINTLN("No GPS detected");
}
digitalWrite(GPS_EN, LOW); // Power off GPS until the setting is changed
return true;
}
bool T114SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
}
return true;
}
void T114SensorManager::loop() {
static long next_gps_update = 0;
_location->loop();
if (millis() > next_gps_update) {
if (_location->isValid()) {
node_lat = ((double)_location->getLatitude())/1000000.;
node_lon = ((double)_location->getLongitude())/1000000.;
node_altitude = ((double)_location->getAltitude()) / 1000.0;
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
}
next_gps_update = millis() + 1000;
}
}
int T114SensorManager::getNumSettings() const {
return gps_detected ? 1 : 0; // only show GPS setting if GPS is detected
}
const char* T114SensorManager::getSettingName(int i) const {
return (gps_detected && i == 0) ? "gps" : NULL;
}
const char* T114SensorManager::getSettingValue(int i) const {
if (gps_detected && i == 0) {
return gps_active ? "1" : "0";
}
return NULL;
}
bool T114SensorManager::setSettingValue(const char* name, const char* value) {
if (gps_detected && strcmp(name, "gps") == 0) {
if (strcmp(value, "0") == 0) {
stop_gps();
} else {
start_gps();
}
return true;
}
return false; // not supported
return mesh::LocalIdentity(&rng); // create new random identity
}

View file

@ -2,11 +2,11 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <T114Board.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#ifdef DISPLAY_CLASS
@ -18,37 +18,18 @@
#endif
#endif
class T114SensorManager : public SensorManager {
bool gps_active = false;
bool gps_detected = false;
LocationProvider* _location;
void start_gps();
void stop_gps();
public:
T114SensorManager(LocationProvider &location): _location(&location) { }
bool begin() override;
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
void loop() override;
LocationProvider* getLocationProvider() override { return gps_detected ? _location : NULL; }
int getNumSettings() const override;
const char* getSettingName(int i) const override;
const char* getSettingValue(int i) const override;
bool setSettingValue(const char* name, const char* value) override;
};
extern T114Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern T114SensorManager sensors;
extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
#endif
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -14,7 +14,7 @@
#define USE_LFXO // 32.768 kHz crystal oscillator
#define VARIANT_MCK (64000000ul)
#define WIRE_INTERFACES_COUNT (1)
#define WIRE_INTERFACES_COUNT (2)
////////////////////////////////////////////////////////////////////////////////
// Power
@ -30,6 +30,14 @@
#define AREF_VOLTAGE (3.0)
// Power management boot protection threshold (millivolts)
// Set to 0 to disable boot protection
#define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV)
// LPCOMP wake configuration (voltage recovery from SYSTEMOFF)
// AIN2 = P0.04 = BATTERY_PIN / PIN_VBAT_READ
#define PWRMGT_LPCOMP_AIN 2
#define PWRMGT_LPCOMP_REFSEL 1 // 2/8 VDD (~3.68-4.04V)
////////////////////////////////////////////////////////////////////////////////
// Number of pins
@ -50,8 +58,11 @@
////////////////////////////////////////////////////////////////////////////////
// I2C pin definition
#define PIN_WIRE_SDA (26) // P0.26
#define PIN_WIRE_SCL (27) // P0.27
#define PIN_WIRE_SDA (26) // P0.26
#define PIN_WIRE_SCL (27) // P0.27
#define PIN_WIRE1_SDA (7) // P0.8
#define PIN_WIRE1_SCL (8) // P0.7
////////////////////////////////////////////////////////////////////////////////
// SPI pin definition

View file

@ -44,7 +44,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern MomentaryButton user_btn;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -47,7 +47,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -43,5 +43,5 @@ extern HWTSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -50,7 +50,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -26,5 +26,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -43,7 +43,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -367,3 +367,12 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter}
lib_deps =
${Heltec_lora32_v3.lib_deps}
${esp32_ota.lib_deps}
[env:Heltec_v3_kiss_modem]
extends = Heltec_lora32_v3
build_flags =
${Heltec_lora32_v3.build_flags}
build_src_filter = ${Heltec_lora32_v3.build_src_filter}
+<../examples/kiss_modem/>
lib_deps =
${Heltec_lora32_v3.lib_deps}

View file

@ -50,7 +50,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -26,5 +26,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -86,5 +86,9 @@ void HeltecV4Board::begin() {
}
const char* HeltecV4Board::getManufacturerName() const {
return "Heltec V4";
#ifdef HELTEC_LORA_V4_TFT
return "Heltec V4 TFT";
#else
return "Heltec V4 OLED";
#endif
}

View file

@ -17,20 +17,19 @@ build_flags =
-D P_LORA_SCLK=9
-D P_LORA_MISO=11
-D P_LORA_MOSI=10
-D P_LORA_PA_POWER=7 ;power en
-D P_LORA_PA_EN=2
-D P_LORA_PA_TX_EN=46 ;enable tx
-D PIN_BOARD_SDA=17
-D PIN_BOARD_SCL=18
-D P_LORA_PA_POWER=7 ; VFEM_Ctrl - Power on GC1109
-D P_LORA_PA_EN=2 ; PA CSD - Enable GC1109
-D P_LORA_PA_TX_EN=46 ; PA CPS - GC1109 TX PA full(High) / bypass(Low)
-D PIN_USER_BTN=0
-D PIN_VEXT_EN=36
-D PIN_VEXT_EN_ACTIVE=HIGH
-D PIN_VEXT_EN_ACTIVE=LOW
-D LORA_TX_POWER=10 ;If it is configured as 10 here, the final output will be 22 dbm.
-D MAX_LORA_TX_POWER=22 ; Max SX1262 output
-D SX126X_DIO2_AS_RF_SWITCH=true
-D SX126X_REGISTER_PATCH=1 ; Patch register 0x8B5 for improved RX
-D SX126X_DIO2_AS_RF_SWITCH=true ; GC1109 CTX is controlled by SX1262 DIO2
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D SX126X_RX_BOOSTED_GAIN=1 ; In some cases, commenting this out will improve RX
-D PIN_GPS_RX=38
-D PIN_GPS_TX=39
-D PIN_GPS_RESET=42
@ -47,10 +46,44 @@ lib_deps =
${esp32_base.lib_deps}
${sensor_base.lib_deps}
[env:heltec_v4_repeater]
[heltec_v4_oled]
extends = Heltec_lora32_v4
build_flags =
${Heltec_lora32_v4.build_flags}
-D HELTEC_LORA_V4_OLED
-D PIN_BOARD_SDA=17
-D PIN_BOARD_SCL=18
-D ENV_PIN_SDA=4
-D ENV_PIN_SCL=3
build_src_filter= ${Heltec_lora32_v4.build_src_filter}
lib_deps = ${Heltec_lora32_v4.lib_deps}
[heltec_v4_tft]
extends = Heltec_lora32_v4
build_flags =
${Heltec_lora32_v4.build_flags}
-D HELTEC_LORA_V4_TFT
-D PIN_BOARD_SDA=4
-D PIN_BOARD_SCL=3
-D DISPLAY_SCALE_X=2.5
-D DISPLAY_SCALE_Y=3.75
-D PIN_TFT_RST=18
-D PIN_TFT_VDD_CTL=-1
-D PIN_TFT_LEDA_CTL=21
-D PIN_TFT_LEDA_CTL_ACTIVE=HIGH
-D PIN_TFT_CS=15
-D PIN_TFT_DC=16
-D PIN_TFT_SCL=17
-D PIN_TFT_SDA=33
build_src_filter= ${Heltec_lora32_v4.build_src_filter}
lib_deps =
${Heltec_lora32_v4.lib_deps}
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
[env:heltec_v4_repeater]
extends = heltec_v4_oled
build_flags =
${heltec_v4_oled.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"Heltec Repeater"'
-D ADVERT_LAT=0.0
@ -59,18 +92,18 @@ build_flags =
-D MAX_NEIGHBOURS=50
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
build_src_filter = ${heltec_v4_oled.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
lib_deps =
${Heltec_lora32_v4.lib_deps}
${heltec_v4_oled.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0
[env:heltec_v4_repeater_bridge_espnow]
extends = Heltec_lora32_v4
extends = heltec_v4_oled
build_flags =
${Heltec_lora32_v4.build_flags}
${heltec_v4_oled.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"ESPNow Bridge"'
-D ADVERT_LAT=0.0
@ -81,18 +114,18 @@ build_flags =
; -D BRIDGE_DEBUG=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
build_src_filter = ${heltec_v4_oled.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
lib_deps =
${Heltec_lora32_v4.lib_deps}
${heltec_v4_oled.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_v4_room_server]
extends = Heltec_lora32_v4
extends = heltec_v4_oled
build_flags =
${Heltec_lora32_v4.build_flags}
${heltec_v4_oled.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"Heltec Room"'
-D ADVERT_LAT=0.0
@ -101,50 +134,50 @@ build_flags =
-D ROOM_PASSWORD='"hello"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
build_src_filter = ${heltec_v4_oled.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_room_server>
lib_deps =
${Heltec_lora32_v4.lib_deps}
${heltec_v4_oled.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_v4_terminal_chat]
extends = Heltec_lora32_v4
extends = heltec_v4_oled
build_flags =
${Heltec_lora32_v4.build_flags}
${heltec_v4_oled.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
build_src_filter = ${heltec_v4_oled.build_src_filter}
+<../examples/simple_secure_chat/main.cpp>
lib_deps =
${Heltec_lora32_v4.lib_deps}
${heltec_v4_oled.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_v4_companion_radio_usb]
extends = Heltec_lora32_v4
extends = heltec_v4_oled
build_flags =
${Heltec_lora32_v4.build_flags}
${heltec_v4_oled.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=SSD1306Display
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
build_src_filter = ${heltec_v4_oled.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_lora32_v4.lib_deps}
${heltec_v4_oled.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_v4_companion_radio_ble]
extends = Heltec_lora32_v4
extends = heltec_v4_oled
build_flags =
${Heltec_lora32_v4.build_flags}
${heltec_v4_oled.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@ -155,20 +188,20 @@ build_flags =
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
build_src_filter = ${heltec_v4_oled.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_lora32_v4.lib_deps}
${heltec_v4_oled.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_v4_companion_radio_wifi]
extends = Heltec_lora32_v4
extends = heltec_v4_oled
build_flags =
${Heltec_lora32_v4.build_flags}
${heltec_v4_oled.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
@ -176,24 +209,23 @@ build_flags =
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
build_src_filter = ${heltec_v4_oled.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_lora32_v4.lib_deps}
${heltec_v4_oled.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_v4_sensor]
extends = Heltec_lora32_v4
extends = heltec_v4_oled
build_flags =
${Heltec_lora32_v4.build_flags}
-D ADVERT_NAME='"Heltec v3 Sensor"'
${heltec_v4_oled.build_flags}
-D ADVERT_NAME='"Heltec v4 Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
@ -202,9 +234,172 @@ build_flags =
-D DISPLAY_CLASS=SSD1306Display
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v4.build_src_filter}
build_src_filter = ${heltec_v4_oled.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_sensor>
lib_deps =
${Heltec_lora32_v4.lib_deps}
${heltec_v4_oled.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_v4_tft_repeater]
extends = heltec_v4_tft
build_flags =
${heltec_v4_tft.build_flags}
-D DISPLAY_CLASS=ST7789LCDDisplay
-D ADVERT_NAME='"Heltec Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<helpers/ui/ST7789LCDDisplay.cpp>
+<../examples/simple_repeater>
lib_deps =
${heltec_v4_tft.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0
[env:heltec_v4_tft_repeater_bridge_espnow]
extends = heltec_v4_tft
build_flags =
${heltec_v4_tft.build_flags}
-D DISPLAY_CLASS=ST7789LCDDisplay
-D ADVERT_NAME='"ESPNow Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
-D WITH_ESPNOW_BRIDGE=1
; -D BRIDGE_DEBUG=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<helpers/ui/ST7789LCDDisplay.cpp>
+<../examples/simple_repeater>
lib_deps =
${heltec_v4_tft.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_v4_tft_room_server]
extends = heltec_v4_tft
build_flags =
${heltec_v4_tft.build_flags}
-D DISPLAY_CLASS=ST7789LCDDisplay
-D ADVERT_NAME='"Heltec Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<helpers/ui/ST7789LCDDisplay.cpp>
+<../examples/simple_room_server>
lib_deps =
${heltec_v4_tft.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_v4_tft_terminal_chat]
extends = heltec_v4_tft
build_flags =
${heltec_v4_tft.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<../examples/simple_secure_chat/main.cpp>
lib_deps =
${heltec_v4_tft.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_v4_tft_companion_radio_usb]
extends = heltec_v4_tft
build_flags =
${heltec_v4_tft.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=ST7789LCDDisplay
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<helpers/ui/ST7789LCDDisplay.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${heltec_v4_tft.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_v4_tft_companion_radio_ble]
extends = heltec_v4_tft
build_flags =
${heltec_v4_tft.build_flags}
-I examples/companion_radio/ui-new
-D DISPLAY_CLASS=ST7789LCDDisplay
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
-D AUTO_SHUTDOWN_MILLIVOLTS=3400
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<helpers/ui/ST7789LCDDisplay.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${heltec_v4_tft.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_v4_tft_companion_radio_wifi]
extends = heltec_v4_tft
build_flags =
${heltec_v4_tft.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=ST7789LCDDisplay
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<helpers/ui/ST7789LCDDisplay.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${heltec_v4_tft.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_v4_tft_sensor]
extends = heltec_v4_tft
build_flags =
${heltec_v4_tft.build_flags}
-D ADVERT_NAME='"Heltec v4 Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ENV_PIN_SDA=3
-D ENV_PIN_SCL=4
-D DISPLAY_CLASS=ST7789LCDDisplay
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<helpers/ui/ST7789LCDDisplay.cpp>
+<../examples/simple_sensor>
lib_deps =
${heltec_v4_tft.lib_deps}
${esp32_ota.lib_deps}

View file

@ -24,7 +24,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#endif
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
DISPLAY_CLASS display(&(board.periph_power));
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
#endif
@ -50,7 +50,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -9,7 +9,11 @@
#include <helpers/SensorManager.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
#ifdef HELTEC_LORA_V4_OLED
#include <helpers/ui/SSD1306Display.h>
#elif defined(HELTEC_LORA_V4_TFT)
#include <helpers/ui/ST7789LCDDisplay.h>
#endif
#include <helpers/ui/MomentaryButton.h>
#endif
@ -26,5 +30,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -5,7 +5,7 @@ build_flags =
${esp32_base.build_flags}
-I variants/heltec_wireless_paper
-D HELTEC_WIRELESS_PAPER
-D ARDUINO_USB_CDC_ON_BOOT=1 ; need for Serial
;-D ARDUINO_USB_CDC_ON_BOOT=1 ; this breaks Serial
-D P_LORA_DIO_1=14
-D P_LORA_NSS=8
-D P_LORA_RESET=RADIOLIB_NC
@ -17,8 +17,8 @@ build_flags =
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D P_LORA_TX_LED=18
-D PIN_BOARD_SDA=17
-D PIN_BOARD_SCL=18
;-D PIN_BOARD_SDA=17
;-D PIN_BOARD_SCL=18 ; same GPIO as P_LORA_TX_LED
-D PIN_USER_BTN=0
-D PIN_VEXT_EN=45
-D PIN_VBAT_READ=20
@ -139,4 +139,4 @@ build_src_filter = ${Heltec_Wireless_Paper_base.build_src_filter}
+<../examples/simple_room_server>
lib_deps =
${Heltec_Wireless_Paper_base.lib_deps}
${esp32_ota.lib_deps}
${esp32_ota.lib_deps}

View file

@ -43,7 +43,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern MomentaryButton user_btn;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -6,9 +6,9 @@
#ifdef IKOKA_NRF52
class IkokaNrf52Board : public NRF52BoardOTA {
class IkokaNrf52Board : public NRF52BoardDCDC {
public:
IkokaNrf52Board() : NRF52BoardOTA("XIAO_NRF52_OTA") {}
IkokaNrf52Board() : NRF52Board("XIAO_NRF52_OTA") {}
void begin();
#if defined(P_LORA_TX_LED)

View file

@ -36,7 +36,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -6,9 +6,9 @@
#ifdef XIAO_NRF52
class IkokaNanoNRFBoard : public NRF52BoardOTA {
class IkokaNanoNRFBoard : public NRF52BoardDCDC {
public:
IkokaNanoNRFBoard() : NRF52BoardOTA("XIAO_NRF52_OTA") {}
IkokaNanoNRFBoard() : NRF52Board("XIAO_NRF52_OTA") {}
void begin();
#if defined(P_LORA_TX_LED)

View file

@ -34,7 +34,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -24,5 +24,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -6,9 +6,9 @@
#ifdef XIAO_NRF52
class IkokaStickNRFBoard : public NRF52BoardOTA {
class IkokaStickNRFBoard : public NRF52BoardDCDC {
public:
IkokaStickNRFBoard() : NRF52BoardOTA("XIAO_NRF52_OTA") {}
IkokaStickNRFBoard() : NRF52Board("XIAO_NRF52_OTA") {}
void begin();
#if defined(P_LORA_TX_LED)

View file

@ -34,7 +34,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -24,5 +24,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -4,12 +4,12 @@
#include <Arduino.h>
#include <helpers/NRF52Board.h>
class KeepteenLT1Board : public NRF52BoardOTA {
class KeepteenLT1Board : public NRF52Board {
protected:
uint8_t btn_prev_state;
public:
KeepteenLT1Board() : NRF52BoardOTA("KeepteenLT1_OTA") {}
KeepteenLT1Board() : NRF52Board("KeepteenLT1_OTA") {}
void begin();
#define BATTERY_SAMPLES 8

View file

@ -40,7 +40,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -26,5 +26,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -38,7 +38,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -44,7 +44,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -0,0 +1,71 @@
#include "TBeam1WBoard.h"
void TBeam1WBoard::begin() {
ESP32Board::begin();
// Power on radio module (must be done before radio init)
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH);
radio_powered = true;
delay(10); // Allow radio to power up
// RF switch RXEN pin handled by RadioLib via setRfSwitchPins()
// Initialize LED
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
// Initialize fan control (on by default - 1W PA can overheat)
pinMode(FAN_CTRL_PIN, OUTPUT);
digitalWrite(FAN_CTRL_PIN, HIGH);
}
void TBeam1WBoard::onBeforeTransmit() {
// RF switching handled by RadioLib via SX126X_DIO2_AS_RF_SWITCH and setRfSwitchPins()
digitalWrite(LED_PIN, HIGH); // TX LED on
}
void TBeam1WBoard::onAfterTransmit() {
digitalWrite(LED_PIN, LOW); // TX LED off
}
uint16_t TBeam1WBoard::getBattMilliVolts() {
// T-Beam 1W uses 7.4V battery with voltage divider
// ADC reads through divider - adjust multiplier based on actual divider ratio
analogReadResolution(12);
uint32_t raw = 0;
for (int i = 0; i < 8; i++) {
raw += analogRead(BATTERY_PIN);
}
raw = raw / 8;
// Assuming voltage divider ratio from ADC_MULTIPLIER
// 3.3V reference, 12-bit ADC (4095 max)
return static_cast<uint16_t>((raw * 3300 * ADC_MULTIPLIER) / 4095);
}
const char* TBeam1WBoard::getManufacturerName() const {
return "LilyGo T-Beam 1W";
}
void TBeam1WBoard::powerOff() {
// Turn off radio LNA (CTRL pin must be LOW when not receiving)
digitalWrite(SX126X_RXEN, LOW);
// Turn off radio power
digitalWrite(SX126X_POWER_EN, LOW);
radio_powered = false;
// Turn off LED and fan
digitalWrite(LED_PIN, LOW);
digitalWrite(FAN_CTRL_PIN, LOW);
ESP32Board::powerOff();
}
void TBeam1WBoard::setFanEnabled(bool enabled) {
digitalWrite(FAN_CTRL_PIN, enabled ? HIGH : LOW);
}
bool TBeam1WBoard::isFanEnabled() const {
return digitalRead(FAN_CTRL_PIN) == HIGH;
}

View file

@ -0,0 +1,45 @@
#pragma once
#include <Arduino.h>
#include <helpers/ESP32Board.h>
#include "variant.h"
// LilyGo T-Beam 1W with SX1262 + external PA (XY16P35 module)
//
// Power architecture (LDO is separate chip on T-Beam board, not inside XY16P35):
//
// VCC (+4.0~+8.0V) ──┬──────────────────► XY16P35 VCC pin 5 (PA direct)
// (USB or Battery) │
// │ ┌───────────┐
// └──►│ LDO Chip │──► +3.3V ──► XY16P35 (SX1262 + LNA)
// │ EN=GPIO40 │
// └───────────┘
// LDO_EN (GPIO 40): H @ +1.2V~VIN, active high, not floating
//
// Control signals:
// - LDO_EN (GPIO 40): HIGH enables LDO → powers SX1262 + LNA
// - TCXO_EN (DIO3): HIGH enables TCXO (set to 1.8V per Meshtastic)
// - CTL (GPIO 21): HIGH=RX (LNA on), LOW=TX (LNA off)
// - DIO2: AUTO via SX126X_DIO2_AS_RF_SWITCH (TX path)
//
// Power notes:
// - PA needs VCC 4.0-8.0V for full 32dBm output
// - USB-C (3.9-6V) marginal; 7.4V battery recommended
// - Battery must support 2A+ discharge for high-power TX
class TBeam1WBoard : public ESP32Board {
private:
bool radio_powered = false;
public:
void begin();
void onBeforeTransmit() override;
void onAfterTransmit() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override;
void powerOff() override;
// Fan control methods
void setFanEnabled(bool enabled);
bool isFanEnabled() const;
};

View file

@ -0,0 +1,26 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <stdint.h>
#define USB_VID 0x303a
#define USB_PID 0x1001
// Serial (USB CDC)
static const uint8_t TX = 43;
static const uint8_t RX = 44;
// I2C for OLED and sensors
static const uint8_t SDA = 8;
static const uint8_t SCL = 9;
// Default SPI mapped to Radio/SD
static const uint8_t SS = 15; // LoRa CS
static const uint8_t MOSI = 11;
static const uint8_t MISO = 12;
static const uint8_t SCK = 13;
// SD Card CS
#define SDCARD_CS 10
#endif /* Pins_Arduino_h */

View file

@ -0,0 +1,193 @@
[LilyGo_TBeam_1W]
extends = esp32_base
board = t_beam_1w
build_flags =
${esp32_base.build_flags}
-I variants/lilygo_tbeam_1w
-D TBEAM_1W
; Radio - SX1262 with high-power PA (32dBm max output)
; Note: Set SX1262 output to 22dBm max, external PA provides additional gain
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D P_LORA_DIO_1=1
-D P_LORA_NSS=15
-D P_LORA_RESET=3
-D P_LORA_BUSY=38
-D P_LORA_SCLK=13
-D P_LORA_MISO=12
-D P_LORA_MOSI=11
; RF switch configuration:
; DIO2 controls TX path (PA enable) via SX126X_DIO2_AS_RF_SWITCH
; GPIO21 controls RX path (LNA enable) via SX126X_RXEN
; Truth table: DIO2=1,RXEN=0 → TX | DIO2=0,RXEN=1 → RX
-D SX126X_DIO2_AS_RF_SWITCH=true
-D SX126X_RXEN=21
-D SX126X_DIO3_TCXO_VOLTAGE=3.0
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
; TX power: 22dBm to SX1262, PA module adds ~10dB for 32dBm total
-D LORA_TX_POWER=22
; Battery - 2S 7.4V LiPo (6.0V min, 8.4V max)
-D BATT_MIN_MILLIVOLTS=6000
-D BATT_MAX_MILLIVOLTS=8400
; Display - SH1106 OLED at 0x3C
-D DISPLAY_CLASS=SH1106Display
; I2C pins
-D PIN_BOARD_SDA=8
-D PIN_BOARD_SCL=9
; GPS - L76K module
; GNSS_TXD (IO5) = GPS transmits → MCU RX
; GNSS_RXD (IO6) = GPS receives → MCU TX
-D PIN_GPS_TX=5
-D PIN_GPS_RX=6
-D PIN_GPS_EN=16
-D ENV_INCLUDE_GPS=1
; User interface
-D PIN_USER_BTN=17
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/lilygo_tbeam_1w>
+<helpers/ui/SH1106Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/sensors>
lib_deps =
${esp32_base.lib_deps}
adafruit/Adafruit SH110X @ ~2.1.13
stevemarple/MicroNMEA @ ~2.0.6
; === LILYGO T-Beam 1W Repeater ===
[env:LilyGo_TBeam_1W_repeater]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-D ADVERT_NAME='"T-Beam 1W Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<../examples/simple_repeater>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
${esp32_ota.lib_deps}
; === LILYGO T-Beam 1W Room Server ===
[env:LilyGo_TBeam_1W_room_server]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-D ADVERT_NAME='"T-Beam 1W Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<../examples/simple_room_server>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
${esp32_ota.lib_deps}
; === LILYGO T-Beam 1W Companion Radio (USB) ===
[env:LilyGo_TBeam_1W_companion_radio_usb]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
densaugeo/base64 @ ~1.4.0
; === LILYGO T-Beam 1W Companion Radio (BLE) ===
[env:LilyGo_TBeam_1W_companion_radio_ble]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
densaugeo/base64 @ ~1.4.0
; === LILYGO T-Beam 1W Companion Radio (WiFi) ===
[env:LilyGo_TBeam_1W_companion_radio_wifi]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
densaugeo/base64 @ ~1.4.0
; === LILYGO T-Beam 1W Repeater with ESPNow Bridge ===
[env:LilyGo_TBeam_1W_repeater_bridge_espnow]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-D ADVERT_NAME='"T-Beam 1W ESPNow Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
-D WITH_ESPNOW_BRIDGE=1
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D BRIDGE_DEBUG=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<../examples/simple_repeater>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
${esp32_ota.lib_deps}

View file

@ -0,0 +1,64 @@
#include <Arduino.h>
#include "target.h"
TBeam1WBoard board;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
#endif
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
#endif
bool radio_init() {
fallback_clock.begin();
rtc_clock.begin(Wire);
// Initialize SPI for radio
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
// GPS serial initialized by EnvironmentSensorManager::begin()
bool success = radio.std_init(&spi);
if (success) {
// T-Beam 1W has external PA requiring longer ramp time (>800us recommended)
// RADIOLIB_SX126X_PA_RAMP_800U = 0x05
radio.setTxParams(LORA_TX_POWER, RADIOLIB_SX126X_PA_RAMP_800U);
}
return success;
}
uint32_t radio_get_rng_seed() {
return radio.random(0x7FFFFFFF);
}
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setFrequency(freq);
radio.setSpreadingFactor(sf);
radio.setBandwidth(bw);
radio.setCodingRate(cr);
}
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng);
}

View file

@ -0,0 +1,27 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#include "TBeam1WBoard.h"
#ifdef DISPLAY_CLASS
#include <helpers/ui/SH1106Display.h>
#include <helpers/ui/MomentaryButton.h>
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
#endif
extern TBeam1WBoard board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -0,0 +1,96 @@
// LilyGo T-Beam-1W variant.h
// Configuration based on Meshtastic PR #8967 and LilyGO documentation
#pragma once
// I2C for OLED display (SH1106 at 0x3C)
#define I2C_SDA 8
#define I2C_SCL 9
// GPS - Quectel L76K
// GNSS_TXD (IO5) = GPS transmits → MCU RX (setPins rxPin)
// GNSS_RXD (IO6) = GPS receives → MCU TX (setPins txPin)
#define PIN_GPS_TX 5 // MCU receives from GPS TX
#define PIN_GPS_RX 6 // MCU transmits to GPS RX
#define PIN_GPS_PPS 7 // GPS PPS output
#define PIN_GPS_EN 16 // GPS wake-up/enable (GPS_EN_PIN in LilyGO code)
#define HAS_GPS 1
#define GPS_BAUDRATE 9600
// Buttons
#define BUTTON_PIN 0 // BUTTON 1 (boot)
#define BUTTON_PIN_ALT 17 // BUTTON 2
// SPI (shared by LoRa and SD)
#define SPI_MOSI 11
#define SPI_SCK 13
#define SPI_MISO 12
#define SPI_CS 10
// SD Card
#define HAS_SDCARD
#define SDCARD_USE_SPI1
#define SDCARD_CS SPI_CS
// LoRa Radio - SX1262 with 1W PA
#define USE_SX1262
#define LORA_SCK SPI_SCK
#define LORA_MISO SPI_MISO
#define LORA_MOSI SPI_MOSI
#define LORA_CS 15
#define LORA_RESET 3
#define LORA_DIO1 1
#define LORA_BUSY 38
// CRITICAL: Radio power enable - MUST be HIGH before lora.begin()!
// GPIO 40 powers the SX1262 + PA module via LDO
#define SX126X_POWER_EN 40
#ifdef USE_SX1262
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_BUSY
#define SX126X_RESET LORA_RESET
// RF switching configuration for 1W PA module
// DIO2 controls PA (via SX126X_DIO2_AS_RF_SWITCH)
// CTRL PIN (GPIO 21) controls LNA - must be HIGH during RX
// Truth table: DIO2=1,CTRL=0 -> TX (PA on, LNA off)
// DIO2=0,CTRL=1 -> RX (PA off, LNA on)
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_RXEN 21 // LNA enable - HIGH during RX
// TCXO voltage - required for radio init
#define SX126X_DIO3_TCXO_VOLTAGE 3.0
#define SX126X_MAX_POWER 22
#endif
// LED
#define LED_PIN 18
#define LED_STATE_ON 1 // HIGH = ON
// Battery ADC
#define BATTERY_PIN 4
#define ADC_CHANNEL ADC1_GPIO4_CHANNEL
#define BATTERY_SENSE_SAMPLES 30
#define ADC_MULTIPLIER 3.0
// NTC temperature sensor
#define NTC_PIN 14
// Fan control
#define FAN_CTRL_PIN 41
// PA Ramp Time - T-Beam 1W requires >800us stabilization (default is 200us)
// Value 0x05 = RADIOLIB_SX126X_PA_RAMP_800U
#define SX126X_PA_RAMP_US 0x05
// Display - SH1106 OLED (128x64)
#define USE_SH1106
#define OLED_WIDTH 128
#define OLED_HEIGHT 64
// 32768 Hz crystal present
#define HAS_32768HZ 1

View file

@ -45,7 +45,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -50,7 +50,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -42,7 +42,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -23,5 +23,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -45,7 +45,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -27,5 +27,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -13,9 +13,9 @@
#define PIN_VBAT_READ (4)
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class TechoBoard : public NRF52BoardOTA {
class TechoBoard : public NRF52BoardDCDC {
public:
TechoBoard() : NRF52BoardOTA("TECHO_OTA") {}
TechoBoard() : NRF52Board("TECHO_OTA") {}
void begin();
uint16_t getBattMilliVolts() override;

View file

@ -42,7 +42,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -27,5 +27,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -13,9 +13,9 @@
#define PIN_VBAT_READ (4)
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class TechoBoard : public NRF52BoardOTA {
class TechoBoard : public NRF52BoardDCDC {
public:
TechoBoard() : NRF52BoardOTA("TECHO_OTA") {}
TechoBoard() : NRF52Board("TECHO_OTA") {}
void begin();
uint16_t getBattMilliVolts() override;

View file

@ -41,7 +41,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -27,5 +27,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -38,7 +38,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -16,5 +16,5 @@ extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -39,7 +39,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -0,0 +1,49 @@
#include <Arduino.h>
#include "target.h"
UnitC6LBoard board;
#if defined(P_LORA_SCLK)
static SPIClass spi(0);
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
WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
SensorManager sensors;
bool radio_init() {
fallback_clock.begin();
rtc_clock.begin(Wire);
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
return radio.std_init(&spi);
#else
return radio.std_init();
#endif
}
uint32_t radio_get_rng_seed() {
return radio.random(0x7FFFFFFF);
}
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setFrequency(freq);
radio.setSpreadingFactor(sf);
radio.setBandwidth(bw);
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}

View file

@ -0,0 +1,15 @@
#pragma once
#include <Arduino.h>
#include <helpers/ESP32Board.h>
class UnitC6LBoard : public ESP32Board {
public:
void begin() {
ESP32Board::begin();
}
const char* getManufacturerName() const override {
return "Unit C6L";
}
};

View file

@ -0,0 +1,104 @@
[M5Stack_Unit_C6L]
extends = esp32c6_base
board = esp32-c6-devkitm-1
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
build_flags =
${esp32c6_base.build_flags}
${sensor_base.build_flags}
-I variants/M5Stack_Unit_C6L
-D P_LORA_TX_LED=15
-D P_LORA_SCLK=20
-D P_LORA_MISO=22
-D P_LORA_MOSI=21
-D P_LORA_NSS=23
-D P_LORA_DIO_1=7
-D P_LORA_BUSY=19
-D P_LORA_RESET=-1
-D PIN_BUZZER=11
-D PIN_BOARD_SDA=16
-D PIN_BOARD_SCL=17
-D SX126X_RXEN=5
-D SX126X_DIO2_AS_RF_SWITCH=true
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D DISABLE_WIFI_OTA=1
-D GPS_RX=4
-D GPS_TX=5
build_src_filter = ${esp32c6_base.build_src_filter}
+<../variants/m5stack_unit_c6l>
+<UnitC6LBoard.cpp>
lib_deps =
${esp32c6_base.lib_deps}
${sensor_base.lib_deps}
[env:M5Stack_Unit_C6L_repeater]
extends = M5Stack_Unit_C6L
build_src_filter = ${M5Stack_Unit_C6L.build_src_filter}
+<../examples/simple_repeater/*.cpp>
build_flags =
${M5Stack_Unit_C6L.build_flags}
-D ADVERT_NAME='"Unit C6L Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps =
${M5Stack_Unit_C6L.lib_deps}
; ${esp32_ota.lib_deps}
[env:M5Stack_Unit_C6L_room_server]
extends = M5Stack_Unit_C6L
build_src_filter = ${M5Stack_Unit_C6L.build_src_filter}
+<../examples/simple_room_server>
build_flags =
${M5Stack_Unit_C6L.build_flags}
-D ADVERT_NAME='"Unit C6L Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps =
${M5Stack_Unit_C6L.lib_deps}
; ${esp32_ota.lib_deps}
[env:M5Stack_Unit_C6L_companion_radio_ble]
extends = M5Stack_Unit_C6L
build_flags = ${M5Stack_Unit_C6L.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${M5Stack_Unit_C6L.build_src_filter}
+<helpers/esp32/*.cpp>
-<helpers/esp32/ESPNOWRadio.cpp>
+<../examples/companion_radio/*.cpp>
lib_deps =
${M5Stack_Unit_C6L.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:M5Stack_Unit_C6L_companion_radio_usb]
extends = M5Stack_Unit_C6L
build_flags = ${M5Stack_Unit_C6L.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${M5Stack_Unit_C6L.build_src_filter}
+<helpers/esp32/*.cpp>
-<helpers/esp32/ESPNOWRadio.cpp>
+<../examples/companion_radio/*.cpp>
lib_deps =
${M5Stack_Unit_C6L.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0

View file

@ -0,0 +1,21 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <UnitC6LBoard.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/ESP32Board.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
extern UnitC6LBoard board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -9,9 +9,9 @@
#define PIN_BAT_CTL 34
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
class HeltecMeshPocket : public NRF52BoardOTA {
class HeltecMeshPocket : public NRF52BoardDCDC {
public:
HeltecMeshPocket() : NRF52BoardOTA("MESH_POCKET_OTA") {}
HeltecMeshPocket() : NRF52Board("MESH_POCKET_OTA") {}
void begin();
uint16_t getBattMilliVolts() override {

View file

@ -34,7 +34,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -26,7 +26,7 @@ extern AutoDiscoverRTCClock rtc_clock;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
extern SensorManager sensors;

View file

@ -41,7 +41,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -45,5 +45,5 @@ extern MASensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -0,0 +1,44 @@
#include "MeshtinyBoard.h"
#include <Arduino.h>
#include <Wire.h>
#include <bluefruit.h>
static BLEDfu bledfu;
static void connect_callback(uint16_t conn_handle) {
(void)conn_handle;
MESH_DEBUG_PRINTLN("BLE client connected");
}
static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
(void)conn_handle;
(void)reason;
MESH_DEBUG_PRINTLN("BLE client disconnected");
}
void MeshtinyBoard::begin() {
NRF52BoardDCDC::begin();
btn_prev_state = HIGH;
pinMode(PIN_VBAT_READ, INPUT); // VBAT ADC input
// Set all button pins to INPUT_PULLUP
pinMode(PIN_BUTTON1, INPUT_PULLUP);
pinMode(PIN_BUTTON2, INPUT_PULLUP);
pinMode(PIN_BUTTON3, INPUT_PULLUP);
pinMode(PIN_BUTTON4, INPUT_PULLUP);
#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
#endif
Wire.begin();
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH);
delay(10); // give sx1262 some time to power up
}

View file

@ -0,0 +1,66 @@
#pragma once
#include <Arduino.h>
#include <MeshCore.h>
#include <helpers/NRF52Board.h>
class MeshtinyBoard : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
MeshtinyBoard() : NRF52Board("Meshtiny OTA") {}
void begin();
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
#endif
uint16_t getBattMilliVolts() override {
int adcvalue = 0;
analogReadResolution(12);
analogReference(AR_INTERNAL_3_0);
delay(10);
adcvalue = analogRead(PIN_VBAT_READ);
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
}
const char *getManufacturerName() const override { return "Meshtiny"; }
void reboot() override { NVIC_SystemReset(); }
void powerOff() override {
#ifdef PIN_USER_BTN
while (digitalRead(PIN_USER_BTN) == LOW) {
delay(10);
}
#endif
#ifdef PIN_3V3_EN
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, LOW);
#endif
#ifdef PIN_LED1
digitalWrite(PIN_LED1, LOW);
#endif
#ifdef PIN_LED2
digitalWrite(PIN_LED2, LOW);
#endif
#ifdef PIN_USER_BTN
nrf_gpio_cfg_sense_input(g_ADigitalPinMap[PIN_USER_BTN], NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
#endif
sd_power_system_off();
}
};

View file

@ -0,0 +1,68 @@
[Meshtiny]
extends = nrf52_base
board = meshtiny
board_build.ldscript = boards/nrf52840_s140_v6.ld
build_flags = ${nrf52_base.build_flags}
-I lib/nrf52/s140_nrf52_6.1.1_API/include
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
-I variants/meshtiny
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D PIN_3V3_EN=34
-D MESHTINY
-D UI_HAS_JOYSTICK
build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/meshtiny>
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/buzzer.cpp>
+<helpers/sensors>
lib_deps =
${nrf52_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13
end2endzone/NonBlockingRTTTL@^1.3.0
[env:Meshtiny_companion_radio_usb]
extends = Meshtiny
build_flags =
${Meshtiny.build_flags}
-I examples/companion_radio/ui-new
-D MESHTINY
-D PIN_BUZZER=30
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Meshtiny.build_src_filter}
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Meshtiny.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Meshtiny_companion_radio_ble]
extends = Meshtiny
build_flags =
${Meshtiny.build_flags}
-I examples/companion_radio/ui-new
-D MESHTINY
-D PIN_BUZZER=30
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
; -D BLE_DEBUG_LOGGING=1
build_src_filter = ${Meshtiny.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Meshtiny.lib_deps}
densaugeo/base64 @ ~1.4.0

View file

@ -0,0 +1,47 @@
#include "target.h"
#include <Arduino.h>
#include <helpers/ArduinoHelpers.h>
MeshtinyBoard board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager();
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(ENCODER_PRESS, 1000, true, true);
MomentaryButton joystick_left(ENCODER_LEFT, 1000, true, true);
MomentaryButton joystick_right(ENCODER_RIGHT, 1000, true, true);
MomentaryButton back_btn(PIN_SIDE_BUTTON, 1000, true, true);
#endif
bool radio_init() {
rtc_clock.begin(Wire);
return radio.std_init(&SPI);
}
uint32_t radio_get_rng_seed() {
return radio.random(0x7FFFFFFF);
}
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setFrequency(freq);
radio.setSpreadingFactor(sf);
radio.setBandwidth(bw);
radio.setCodingRate(cr);
}
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}

View file

@ -0,0 +1,33 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <MeshtinyBoard.h>
#include <RadioLib.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/MomentaryButton.h>
#include <helpers/ui/SSD1306Display.h>
#endif
#include <helpers/sensors/EnvironmentSensorManager.h>
extern MeshtinyBoard board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern MomentaryButton joystick_left;
extern MomentaryButton joystick_right;
extern MomentaryButton back_btn;
#endif
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -0,0 +1,51 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "variant.h"
#include "nrf.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
const uint32_t g_ADigitalPinMap[] = {
// P0
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31,
// P1
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
};
void initVariant() {
// LED1 & LED2
#ifdef PIN_LED1
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
#endif
#ifdef PIN_LED2
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
#endif
// 3V3 Power Rail - nothing connected on meshtiny
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, LOW);
}

View file

@ -0,0 +1,98 @@
#ifndef _MESHTINY_H_
#define _MESHTINY_H_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#define PINS_COUNT (48)
#define NUM_DIGITAL_PINS (48)
#define NUM_ANALOG_INPUTS (6)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED1 (35) // Green LED
#define PIN_LED2 (36) // Blue LED
#define LED_RED (-1)
#define LED_GREEN PIN_LED1
#define LED_BLUE (-1) // Disable annoying flashing caused by Bluefruit
#define P_LORA_TX_LED PIN_LED2 // Blue LED
// #define PIN_STATUS_LED LED_GREEN // disable status led.
#define LED_BUILTIN LED_GREEN
#define PIN_LED LED_BUILTIN
#define LED_PIN LED_BUILTIN
#define LED_STATE_ON HIGH
// Buttons
#define PIN_BUTTON1 (9) // side button
#define PIN_BUTTON2 (4) // encoder left
#define PIN_BUTTON3 (26) // encoder right
#define PIN_BUTTON4 (28) // encoder press
#define PIN_SIDE_BUTTON PIN_BUTTON1
#define ENCODER_LEFT PIN_BUTTON2
#define ENCODER_RIGHT PIN_BUTTON3
#define ENCODER_PRESS PIN_BUTTON4
#define PIN_USER_BTN PIN_SIDE_BUTTON
// VBAT sensing
#define PIN_VBAT_READ (5)
#define BATTERY_SENSE_RESOLUTION_BITS 12
#define BATTERY_SENSE_RESOLUTION 4096.0
#define AREF_VOLTAGE 3.0
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
#define ADC_MULTIPLIER 1.73
#define ADC_RESOLUTION 14
// Serial interfaces
#define PIN_SERIAL1_RX (15)
#define PIN_SERIAL1_TX (16)
#define PIN_SERIAL2_RX (8) // Connected to Jlink CDC
#define PIN_SERIAL2_TX (6)
// SPI Interfaces
#define SPI_INTERFACES_COUNT 2
#define PIN_SPI_MISO (45)
#define PIN_SPI_MOSI (44)
#define PIN_SPI_SCK (43)
#define PIN_SPI1_MISO (29)
#define PIN_SPI1_MOSI (30)
#define PIN_SPI1_SCK (3)
// LoRa SX1262 module pins
#define P_LORA_SCLK PIN_SPI_SCK
#define P_LORA_MISO PIN_SPI_MISO
#define P_LORA_MOSI PIN_SPI_MOSI
#define P_LORA_DIO_1 (47)
#define P_LORA_RESET (38)
#define P_LORA_BUSY (46)
#define P_LORA_NSS (42)
#define SX126X_POWER_EN (37)
#define SX126X_RXEN RADIOLIB_NC
#define SX126X_TXEN RADIOLIB_NC
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE (1.8f)
// Wire Interfaces
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (13)
#define PIN_WIRE_SCL (14)
#define PIN_BOARD_SDA (13)
#define PIN_BOARD_SCL (14)
// Power control
#define PIN_3V3_EN (34) // nothing connected on meshtiny board
#endif // _MESHTINY_H_

View file

@ -20,12 +20,12 @@
#define PIN_VBAT_READ BATTERY_PIN
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
class MinewsemiME25LS01Board : public NRF52BoardOTA {
class MinewsemiME25LS01Board : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
MinewsemiME25LS01Board() : NRF52BoardOTA("Minewsemi_OTA") {}
MinewsemiME25LS01Board() : NRF52Board("Minewsemi_OTA") {}
void begin();
#define BATTERY_SAMPLES 8

View file

@ -88,7 +88,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
void radio_set_tx_power(int8_t dbm) {
radio.setOutputPower(dbm);
}

View file

@ -25,5 +25,5 @@ extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View file

@ -3,25 +3,8 @@
#ifdef NANO_G2_ULTRA
#include <bluefruit.h>
#include <Wire.h>
static BLEDfu bledfu;
static void connect_callback(uint16_t conn_handle)
{
(void)conn_handle;
MESH_DEBUG_PRINTLN("BLE client connected");
}
static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
(void)conn_handle;
(void)reason;
MESH_DEBUG_PRINTLN("BLE client disconnected");
}
void NanoG2Ultra::begin()
{
NRF52Board::begin();
@ -56,48 +39,4 @@ uint16_t NanoG2Ultra::getBattMilliVolts()
// divider into account (providing the actual LIPO voltage)
return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
}
bool NanoG2Ultra::startOTAUpdate(const char *id, char reply[])
{
// Config the peripheral connection with maximum bandwidth
// more SRAM required by SoftDevice
// Note: All config***() function must be called before begin()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
Bluefruit.begin(1, 0);
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
// Set the BLE device name
Bluefruit.setName("NANO_G2_OTA");
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Set up and start advertising
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
Bluefruit.Advertising.addName();
/* Start Advertising
- Enable auto advertising if disconnected
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
- Timeout for fast mode is 30 seconds
- Start(timeout) with timeout = 0 will advertise forever (until connected)
For recommended advertising interval
https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
strcpy(reply, "OK - started");
return true;
}
#endif

Some files were not shown because too many files have changed in this diff Show more