Merge branch 'dev' into dev

This commit is contained in:
Frieder Schrempf
2026-09-15 22:59:09 +02:00
committed by GitHub
609 changed files with 21807 additions and 5010 deletions
+6
View File
@@ -102,6 +102,7 @@ build_flags =
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
@@ -135,3 +136,8 @@ build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
lib_deps =
${Ebyte_EoRa-S3.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Ebyte_EoRa-S3_kiss_modem]
extends = Ebyte_EoRa-S3
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -64,21 +64,6 @@ bool radio_init() {
return true; // 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); // create new random identity
-3
View File
@@ -23,7 +23,4 @@ extern SensorManager sensors;
#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();
@@ -47,7 +47,7 @@ public:
uint32_t button_pin = PIN_BUTTON1;
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
sd_power_system_off();
NRF52Board::powerOff();
}
};
@@ -74,6 +74,7 @@ build_flags =
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${GAT562_30S_Mesh_Kit.build_src_filter}
@@ -111,3 +112,7 @@ lib_deps =
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:GAT562_30S_Mesh_Kit_kiss_modem]
extends = GAT562_30S_Mesh_Kit
build_src_filter = ${GAT562_30S_Mesh_Kit.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -38,21 +38,6 @@ bool radio_init() {
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
-3
View File
@@ -24,7 +24,4 @@ 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();
@@ -47,7 +47,7 @@ public:
uint32_t button_pin = PIN_BUTTON1;
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
sd_power_system_off();
NRF52Board::powerOff();
}
};
@@ -49,3 +49,8 @@ build_flags =
; -D MESH_DEBUG=1
build_src_filter = ${GAT562_Mesh_EVB_Pro.build_src_filter}
+<../examples/simple_room_server>
[env:GAT562_Mesh_EVB_Pro_kiss_modem]
extends = GAT562_Mesh_EVB_Pro
build_src_filter = ${GAT562_Mesh_EVB_Pro.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -37,21 +37,6 @@ bool radio_init() {
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
-3
View File
@@ -23,7 +23,4 @@ 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();
@@ -47,7 +47,7 @@ public:
uint32_t button_pin = PIN_BUTTON1;
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
sd_power_system_off();
NRF52Board::powerOff();
}
};
@@ -70,6 +70,7 @@ build_flags =
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
@@ -105,3 +106,7 @@ lib_deps =
${GAT562_Mesh_Tracker_Pro.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:GAT562_Mesh_Tracker_Pro_kiss_modem]
extends = GAT562_Mesh_Tracker_Pro
build_src_filter = ${GAT562_Mesh_Tracker_Pro.build_src_filter}
+<../examples/kiss_modem/>
@@ -38,21 +38,6 @@ bool radio_init() {
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
@@ -24,7 +24,4 @@ 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();
@@ -38,7 +38,7 @@ public:
uint32_t button_pin = PIN_BUTTON1;
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
sd_power_system_off();
NRF52Board::powerOff();
}
};
@@ -86,3 +86,7 @@ lib_deps =
${GAT562_Mesh_Watch13.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:GAT562_Mesh_Watch13_kiss_modem]
extends = GAT562_Mesh_Watch13
build_src_filter = ${GAT562_Mesh_Watch13.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -29,21 +29,6 @@ bool radio_init() {
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
-3
View File
@@ -25,7 +25,4 @@ 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();
+5
View File
@@ -95,6 +95,11 @@ lib_deps =
${Generic_E22.lib_deps}
${esp32_ota.lib_deps}
[env:Generic_E22_kiss_modem]
extends = Generic_E22
build_src_filter = ${Generic_E22.build_src_filter}
+<../examples/kiss_modem/>
[env:Generic_E22_sx1268_repeater]
extends = Generic_E22
build_src_filter = ${Generic_E22.build_src_filter}
-15
View File
@@ -27,21 +27,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -15,8 +15,5 @@ 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(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
-12
View File
@@ -17,18 +17,6 @@ bool radio_init() {
return true; // success
}
uint32_t radio_get_rng_seed() {
return millis() + radio_driver.intID(); // TODO: where to get some entropy?
}
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
// no-op
}
void radio_set_tx_power(int8_t dbm) {
radio_driver.setTxPower(dbm);
}
// NOTE: as we are using the WiFi radio, the ESP_IDF will have enabled hardware RNG:
// https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/random.html
class ESP_RNG : public mesh::RNG {
-3
View File
@@ -10,7 +10,4 @@ extern ESP32RTCClock 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(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
+6
View File
@@ -101,6 +101,7 @@ build_flags =
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
-D ENABLE_USB_INTERFACE
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_ct62.build_src_filter}
@@ -150,3 +151,8 @@ build_src_filter = ${Heltec_ct62.build_src_filter}
lib_deps =
${Heltec_ct62.lib_deps}
${esp32_ota.lib_deps}
[env:Heltec_ct62_kiss_modem]
extends = Heltec_ct62
build_src_filter = ${Heltec_ct62.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -16,21 +16,6 @@ bool radio_init() {
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
-3
View File
@@ -14,7 +14,4 @@ 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(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
-27
View File
@@ -20,33 +20,6 @@ void HeltecE213Board::begin() {
}
}
void HeltecE213Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
if (pin_wake_btn < 0) {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
} else {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
}
if (secs > 0) {
esp_sleep_enable_timer_wakeup(secs * 1000000);
}
// Finally set ESP32 into sleep
esp_deep_sleep_start(); // CPU halts here and never returns!
}
void HeltecE213Board::powerOff() {
enterDeepSleep(0);
}
uint16_t HeltecE213Board::getBattMilliVolts() {
analogReadResolution(10);
digitalWrite(PIN_ADC_CTRL, HIGH);
-3
View File
@@ -3,7 +3,6 @@
#include <Arduino.h>
#include <helpers/RefCountedDigitalPin.h>
#include <helpers/ESP32Board.h>
#include <driver/rtc_io.h>
class HeltecE213Board : public ESP32Board {
@@ -13,8 +12,6 @@ public:
HeltecE213Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
void begin();
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
void powerOff() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override ;
};
+6
View File
@@ -73,6 +73,7 @@ build_flags =
-D DISPLAY_CLASS=E213Display
-D AUTO_OFF_MILLIS=0
-D OFFLINE_QUEUE_SIZE=256
-D ENABLE_USB_INTERFACE
build_src_filter = ${Heltec_E213_base.build_src_filter}
+<helpers/ui/E213Display.cpp>
+<helpers/esp32/*.cpp>
@@ -166,3 +167,8 @@ lib_deps =
${Heltec_E213_base.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0
[env:Heltec_E213_kiss_modem]
extends = Heltec_E213_base
build_src_filter = ${Heltec_E213_base.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -33,21 +33,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -23,7 +23,4 @@ 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(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
-27
View File
@@ -20,33 +20,6 @@ void HeltecE290Board::begin() {
}
}
void HeltecE290Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
if (pin_wake_btn < 0) {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
} else {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
}
if (secs > 0) {
esp_sleep_enable_timer_wakeup(secs * 1000000);
}
// Finally set ESP32 into sleep
esp_deep_sleep_start(); // CPU halts here and never returns!
}
void HeltecE290Board::powerOff() {
enterDeepSleep(0);
}
uint16_t HeltecE290Board::getBattMilliVolts() {
analogReadResolution(10);
digitalWrite(PIN_ADC_CTRL, HIGH);
-3
View File
@@ -3,7 +3,6 @@
#include <Arduino.h>
#include <helpers/RefCountedDigitalPin.h>
#include <helpers/ESP32Board.h>
#include <driver/rtc_io.h>
class HeltecE290Board : public ESP32Board {
@@ -13,8 +12,6 @@ public:
HeltecE290Board() : periph_power(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE) { }
void begin();
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
void powerOff() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override ;
+5 -1
View File
@@ -66,7 +66,6 @@ build_flags =
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=E290Display
-D AUTO_OFF_MILLIS=0
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${Heltec_E290_base.build_src_filter}
@@ -162,3 +161,8 @@ lib_deps =
${Heltec_E290_base.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0
[env:Heltec_E290_kiss_modem]
extends = Heltec_E290_base
build_src_filter = ${Heltec_E290_base.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -33,21 +33,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -23,7 +23,4 @@ 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(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
+12 -2
View File
@@ -1,7 +1,6 @@
[Heltec_mesh_solar]
extends = nrf52_base
board = heltec_mesh_solar
platform_packages = framework-arduinoadafruitnrf52
board_build.ldscript = boards/nrf52840_s140_v6.ld
build_flags = ${nrf52_base.build_flags}
-I src/helpers/nrf52
@@ -14,6 +13,11 @@ build_flags = ${nrf52_base.build_flags}
-D LORA_TX_POWER=22
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D HAS_EXTERNAL_WATCHDOG
-D EXTERNAL_WATCHDOG_DONE_PIN=9
-D EXTERNAL_WATCHDOG_WAKE_PIN=10
-D EXTERNAL_WATCHDOG_FEED_INTERVAL_MS=480000 ; 8 minute feed interval, safely inside the hardware watchdog timeout
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<../variants/heltec_mesh_solar>
@@ -83,6 +87,7 @@ build_flags =
${Heltec_mesh_solar.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; -D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
@@ -92,4 +97,9 @@ build_src_filter = ${Heltec_mesh_solar.build_src_filter}
+<../examples/companion_radio/*.cpp>
lib_deps =
${Heltec_mesh_solar.lib_deps}
densaugeo/base64 @ ~1.4.0
densaugeo/base64 @ ~1.4.0
[env:Heltec_mesh_solar_kiss_modem]
extends = Heltec_mesh_solar
build_src_filter = ${Heltec_mesh_solar.build_src_filter}
+<../examples/kiss_modem/>
+32 -15
View File
@@ -13,6 +13,7 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
SolarSensorManager sensors = SolarSensorManager(nmea);
SolarExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
@@ -23,21 +24,6 @@ bool radio_init() {
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
@@ -121,3 +107,34 @@ bool SolarSensorManager::setSettingValue(const char* name, const char* value) {
}
return false; // not supported
}
bool SolarExternalWatchdog::begin() {
last_feed_watchdog = 0;
pinMode(EXTERNAL_WATCHDOG_WAKE_PIN, INPUT);
pinMode(EXTERNAL_WATCHDOG_DONE_PIN, OUTPUT);
delay(1);
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
delay(1);
feed();
return true;
}
void SolarExternalWatchdog::loop() {
if (millis() - last_feed_watchdog >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
feed();
}
}
unsigned long SolarExternalWatchdog::getIntervalMs() const {
unsigned long elapsed_ms = millis() - last_feed_watchdog;
if (elapsed_ms >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
return 0;
}
return EXTERNAL_WATCHDOG_FEED_INTERVAL_MS - elapsed_ms;
}
void SolarExternalWatchdog::feed() {
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, HIGH);
delay(1);
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
last_feed_watchdog = millis();
}
+11 -3
View File
@@ -8,6 +8,7 @@
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#include <helpers/ExternalWatchdogManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/ST7789Display.h>
#endif
@@ -30,17 +31,24 @@ public:
bool setSettingValue(const char* name, const char* value) override;
};
class SolarExternalWatchdog : public ExternalWatchdogManager {
public:
SolarExternalWatchdog() {}
bool begin() override;
void loop() override;
unsigned long getIntervalMs() const override;
void feed() override;
};
extern MeshSolarBoard board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern SolarSensorManager sensors;
extern SolarExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
#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();
+2 -2
View File
@@ -34,8 +34,8 @@
#define PIN_SERIAL1_RX (37)
#define PIN_SERIAL1_TX (39)
#define PIN_SERIAL2_RX (9)
#define PIN_SERIAL2_TX (10)
#define PIN_SERIAL2_RX (-1)
#define PIN_SERIAL2_TX (-1)
////////////////////////////////////////////////////////////////////////////////
// I2C pin definition
+68
View File
@@ -0,0 +1,68 @@
#include "HeltecRC32Board.h"
void HeltecRC32Board::begin() {
ESP32Board::begin();
pinMode(PIN_ADC_CTRL, OUTPUT);
digitalWrite(PIN_ADC_CTRL, !ADC_CTRL_ENABLED);
#ifdef SENSOR_RST_PIN
pinMode(SENSOR_RST_PIN, OUTPUT);
digitalWrite(SENSOR_RST_PIN, HIGH);
#endif
#ifdef LED_POWER
pinMode(LED_POWER, OUTPUT);
digitalWrite(LED_POWER, LOW);
#endif
periph_power.begin();
periph_power.claim();
esp_reset_reason_t reason = esp_reset_reason();
if (reason == ESP_RST_DEEPSLEEP) {
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
if (wakeup_source & (1L << P_LORA_DIO_1)) {
startup_reason = BD_STARTUP_RX_PACKET;
}
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
}
}
void HeltecRC32Board::powerOff() {
enterDeepSleep(0);
}
void HeltecRC32Board::onBeforeTransmit() {
digitalWrite(P_LORA_TX_LED, HIGH);
}
void HeltecRC32Board::onAfterTransmit() {
digitalWrite(P_LORA_TX_LED, LOW);
}
uint16_t HeltecRC32Board::getBattMilliVolts() {
analogReadResolution(12);
analogSetAttenuation(ADC_2_5db);
digitalWrite(PIN_ADC_CTRL, ADC_CTRL_ENABLED);
delay(10);
uint32_t raw = 0;
for (int i = 0; i < 8; i++) {
raw += analogReadMilliVolts(PIN_VBAT_READ);
}
raw = raw / 8;
digitalWrite(PIN_ADC_CTRL, !ADC_CTRL_ENABLED);
return (adc_mult * raw);
}
bool HeltecRC32Board::setAdcMultiplier(float multiplier) {
adc_mult = multiplier == 0.0f ? ADC_MULTIPLIER : multiplier;
return true;
}
const char* HeltecRC32Board::getManufacturerName() const {
return "Heltec RC32";
}
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#include <Arduino.h>
#include <driver/rtc_io.h>
#include <helpers/ESP32Board.h>
#include <helpers/RefCountedDigitalPin.h>
#ifndef ADC_MULTIPLIER
#define ADC_MULTIPLIER 4.9f
#endif
class HeltecRC32Board : public ESP32Board {
protected:
float adc_mult = ADC_MULTIPLIER;
public:
RefCountedDigitalPin periph_power;
HeltecRC32Board() : periph_power(SENSOR_POWER_CTRL_PIN, SENSOR_POWER_ON){}
void begin();
void onBeforeTransmit() override;
void onAfterTransmit() override;
void powerOff() override;
uint16_t getBattMilliVolts() override;
bool setAdcMultiplier(float multiplier) override;
float getAdcMultiplier() const override { return adc_mult; }
const char* getManufacturerName() const override;
};
@@ -0,0 +1,122 @@
#include "HeltecRC32RotaryInput.h"
#include <Wire.h>
namespace {
constexpr uint8_t TCA6408_ADDR = 0x20;
constexpr uint8_t TCA6408_INPUT_REG = 0x00;
constexpr uint8_t TCA6408_POLARITY_REG = 0x02;
constexpr uint8_t TCA6408_CONFIG_REG = 0x03;
constexpr uint8_t TCA6408_ROTARY_A_MASK = 0x01;
constexpr uint8_t TCA6408_ROTARY_B_MASK = 0x02;
constexpr uint8_t TCA6408_ROTARY_MASK = TCA6408_ROTARY_A_MASK | TCA6408_ROTARY_B_MASK;
constexpr uint32_t TCA6408_DEBOUNCE_MS = 5;
}
bool HeltecRC32RotaryInput::begin() {
initialized = true;
ready = false;
input_state = TCA6408_ROTARY_MASK;
active_low_phase = false;
if (periph_power && !power_claimed) {
periph_power->claim();
power_claimed = true;
delay(12);
}
if (!writeRegister(TCA6408_POLARITY_REG, 0x00) || !writeRegister(TCA6408_CONFIG_REG, 0xFF)) {
return false;
}
uint8_t state = 0;
if (!readInput(state)) {
return false;
}
input_state = state & TCA6408_ROTARY_MASK;
ready = true;
return true;
}
RotaryInputEvent HeltecRC32RotaryInput::poll() {
if (!initialized) {
begin();
return RotaryInputEvent::None;
}
if (!ready) {
return RotaryInputEvent::None;
}
uint8_t new_state = 0;
if (!readInput(new_state)) {
return RotaryInputEvent::None;
}
new_state &= TCA6408_ROTARY_MASK;
RotaryInputEvent event = handleTransition(new_state);
input_state = new_state;
return event;
}
bool HeltecRC32RotaryInput::writeRegister(uint8_t reg, uint8_t value) {
Wire.beginTransmission(TCA6408_ADDR);
Wire.write(reg);
Wire.write(value);
return Wire.endTransmission() == 0;
}
bool HeltecRC32RotaryInput::readInput(uint8_t& value) {
Wire.beginTransmission(TCA6408_ADDR);
Wire.write(TCA6408_INPUT_REG);
if (Wire.endTransmission(false) != 0) {
return false;
}
if (Wire.requestFrom(TCA6408_ADDR, static_cast<uint8_t>(1)) != 1) {
return false;
}
value = Wire.read();
return true;
}
RotaryInputEvent HeltecRC32RotaryInput::handleTransition(uint8_t newState) {
uint8_t changed = (input_state ^ newState) & TCA6408_ROTARY_MASK;
RotaryInputEvent event = RotaryInputEvent::None;
bool a_low = (newState & TCA6408_ROTARY_A_MASK) == 0;
bool b_low = (newState & TCA6408_ROTARY_B_MASK) == 0;
if (!a_low && !b_low) {
active_low_phase = false;
}
if (!active_low_phase && (changed & TCA6408_ROTARY_A_MASK) && a_low && !b_low) {
event = RotaryInputEvent::Prev;
active_low_phase = true;
} else if (!active_low_phase && (changed & TCA6408_ROTARY_B_MASK) && b_low && !a_low) {
event = RotaryInputEvent::Next;
active_low_phase = true;
}
if (event == RotaryInputEvent::None && !active_low_phase && (changed & TCA6408_ROTARY_A_MASK)) {
bool a_rising = (newState & TCA6408_ROTARY_A_MASK) != 0;
if (a_rising && b_low) {
event = RotaryInputEvent::Prev;
}
}
if (event == RotaryInputEvent::None && !active_low_phase && (changed & TCA6408_ROTARY_B_MASK)) {
bool b_rising = (newState & TCA6408_ROTARY_B_MASK) != 0;
if (b_rising && a_low) {
event = RotaryInputEvent::Next;
}
}
if (event == RotaryInputEvent::None || (millis() - last_event_ms) < TCA6408_DEBOUNCE_MS) {
return RotaryInputEvent::None;
}
last_event_ms = millis();
return event;
}
@@ -0,0 +1,26 @@
#pragma once
#include <helpers/RefCountedDigitalPin.h>
#include <helpers/ui/RotaryInput.h>
class HeltecRC32RotaryInput : public RotaryInput {
public:
explicit HeltecRC32RotaryInput(RefCountedDigitalPin* periphPower = nullptr) : periph_power(periphPower) { }
bool begin() override;
RotaryInputEvent poll() override;
bool isReady() const override { return ready; }
private:
bool writeRegister(uint8_t reg, uint8_t value);
bool readInput(uint8_t& value);
RotaryInputEvent handleTransition(uint8_t newState);
uint8_t input_state = 0x03;
uint32_t last_event_ms = 0;
bool ready = false;
bool initialized = false;
bool power_claimed = false;
bool active_low_phase = false;
RefCountedDigitalPin* periph_power = nullptr;
};
+60
View File
@@ -0,0 +1,60 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <stdint.h>
#define USB_VID 0x303a
#define USB_PID 0x1001
static const uint8_t TX = 43;
static const uint8_t RX = 44;
static const uint8_t SDA = 21;
static const uint8_t SCL = 18;
static const uint8_t SS = 10;
static const uint8_t MOSI = 12;
static const uint8_t MISO = 13;
static const uint8_t SCK = 11;
static const uint8_t A0 = 1;
static const uint8_t A1 = 2;
static const uint8_t A2 = 3;
static const uint8_t A3 = 4;
static const uint8_t A4 = 5;
static const uint8_t A5 = 6;
static const uint8_t A6 = 7;
static const uint8_t A7 = 8;
static const uint8_t A8 = 9;
static const uint8_t A9 = 10;
static const uint8_t A10 = 11;
static const uint8_t A11 = 12;
static const uint8_t A12 = 13;
static const uint8_t A13 = 14;
static const uint8_t A14 = 15;
static const uint8_t A15 = 16;
static const uint8_t A16 = 17;
static const uint8_t A17 = 18;
static const uint8_t A18 = 19;
static const uint8_t A19 = 20;
static const uint8_t T1 = 1;
static const uint8_t T2 = 2;
static const uint8_t T3 = 3;
static const uint8_t T4 = 4;
static const uint8_t T5 = 5;
static const uint8_t T6 = 6;
static const uint8_t T7 = 7;
static const uint8_t T8 = 8;
static const uint8_t T9 = 9;
static const uint8_t T10 = 10;
static const uint8_t T11 = 11;
static const uint8_t T12 = 12;
static const uint8_t T13 = 13;
static const uint8_t T14 = 14;
static const uint8_t RST_LoRa = 9;
static const uint8_t BUSY_LoRa = 1;
static const uint8_t DIO1_LoRa = 14;
#endif
+357
View File
@@ -0,0 +1,357 @@
[Heltec_RC32]
extends = esp32_base
board = heltec-rc32
board_build.partitions = default_16MB.csv
build_flags =
${esp32_base.build_flags}
${sensor_base.build_flags}
-I variants/heltec_rc32
-I src/helpers/ui
-D HELTEC_RC32
-D USE_SX1262
-D ESP32_CPU_FREQ=160
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D P_LORA_DIO_1=14
-D P_LORA_NSS=10
-D P_LORA_RESET=9
-D P_LORA_BUSY=1
-D P_LORA_SCLK=11
-D P_LORA_MISO=13
-D P_LORA_MOSI=12
-D LORA_TX_POWER=22
-D PIN_USER_BTN=0
-D PIN_BOARD_SDA=21
-D PIN_BOARD_SCL=18
-D SENSOR_POWER_CTRL_PIN=46
-D SENSOR_POWER_ON=HIGH
-D SENSOR_RST_PIN=2
-D P_LORA_TX_LED=47
-D PIN_BUZZER=48
-D PIN_TFT_SCL=17
-D PIN_TFT_SDA=38
-D PIN_TFT_CS=39
-D PIN_TFT_DC=16
-D PIN_TFT_RST=4
-D PIN_TFT_EN=6
-D PIN_TFT_EN_ACTIVE=LOW
-D PIN_TFT_BL=5
-D PIN_TFT_BL_ACTIVE=HIGH
-D SPI_FREQUENCY=8000000
-D PIN_GPS_TX=44
-D PIN_GPS_RX=43
-D PIN_GPS_EN=45
-D PIN_GPS_EN_ACTIVE=HIGH
-D PIN_GPS_RESET=40
-D PIN_GPS_RESET_ACTIVE=LOW
-D PIN_GPS_PPS=41
-D GPS_BAUD_RATE=9600
-D ENV_INCLUDE_GPS=1
-D PIN_ADC_CTRL=15
-D PIN_VBAT_READ=7
-D ADC_CTRL_ENABLED=HIGH
-D ADC_MULTIPLIER=4.9
-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 SX126X_REGISTER_PATCH=1 ; Patch register 0x8B5 for improved RX
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/heltec_rc32>
+<helpers/sensors>
lib_deps =
${esp32_base.lib_deps}
${sensor_base.lib_deps}
[Heltec_RC32_with_display]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-D HELTEC_RC32_WITH_DISPLAY
-D DISPLAY_CLASS=NV3001BDisplay
build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/ui/NV3001BDisplay.cpp>
+<helpers/ui/MomentaryButton.cpp>
lib_deps =
${Heltec_RC32.lib_deps}
[env:heltec_rc32_without_display_repeater]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-D ADVERT_NAME='"Heltec RC32 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
build_src_filter = ${Heltec_RC32.build_src_filter}
+<../examples/simple_repeater>
lib_deps =
${Heltec_RC32.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0
[env:heltec_rc32_without_display_repeater_bridge_espnow]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-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
build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<../examples/simple_repeater>
lib_deps =
${Heltec_RC32.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_rc32_without_display_room_server]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-D ADVERT_NAME='"Heltec RC32 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
build_src_filter = ${Heltec_RC32.build_src_filter}
+<../examples/simple_room_server>
lib_deps =
${Heltec_RC32.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_rc32_without_display_companion_radio_usb]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-I examples/companion_radio/ui-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/buzzer.cpp>
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_RC32.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:heltec_rc32_without_display_companion_radio_ble]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.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
-D AUTO_SHUTDOWN_MILLIVOLTS=3400
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/buzzer.cpp>
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_RC32.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:heltec_rc32_without_display_companion_radio_wifi]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-I examples/companion_radio/ui-new
-D ENABLE_WIFI_INTERFACE
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${Heltec_RC32.build_src_filter}
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/buzzer.cpp>
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_RC32.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:heltec_rc32_without_display_sensor]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-D ADVERT_NAME='"Heltec RC32 Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ENV_PIN_SDA=21
-D ENV_PIN_SCL=18
build_src_filter = ${Heltec_RC32.build_src_filter}
+<../examples/simple_sensor>
lib_deps =
${Heltec_RC32.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_rc32_repeater]
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-D ADVERT_NAME='"Heltec RC32 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<../examples/simple_repeater>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0
[env:heltec_rc32_repeater_bridge_espnow]
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-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
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<../examples/simple_repeater>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_rc32_room_server]
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-D ADVERT_NAME='"Heltec RC32 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<../examples/simple_room_server>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_rc32_terminal_chat]
extends = Heltec_RC32
build_flags =
${Heltec_RC32.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=1
build_src_filter = ${Heltec_RC32.build_src_filter}
+<../examples/simple_secure_chat/main.cpp>
lib_deps =
${Heltec_RC32.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:heltec_rc32_companion_radio_usb]
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I examples/companion_radio/ui-new
-D UI_HAS_ROTARY_INPUT
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:heltec_rc32_companion_radio_ble]
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I examples/companion_radio/ui-new
-D UI_HAS_ROTARY_INPUT
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D AUTO_SHUTDOWN_MILLIVOLTS=3400
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:heltec_rc32_companion_radio_wifi]
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-I examples/companion_radio/ui-new
-D ENABLE_WIFI_INTERFACE
-D UI_HAS_ROTARY_INPUT
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:heltec_rc32_sensor]
extends = Heltec_RC32_with_display
build_flags =
${Heltec_RC32_with_display.build_flags}
-D ADVERT_NAME='"Heltec RC32 Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ENV_PIN_SDA=21
-D ENV_PIN_SCL=18
build_src_filter = ${Heltec_RC32_with_display.build_src_filter}
+<../examples/simple_sensor>
lib_deps =
${Heltec_RC32_with_display.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_rc32_kiss_modem]
extends = Heltec_RC32
build_src_filter = ${Heltec_RC32.build_src_filter}
+<../examples/kiss_modem/>
+52
View File
@@ -0,0 +1,52 @@
#include <Arduino.h>
#include "target.h"
#if defined(UI_HAS_ROTARY_INPUT)
#include "HeltecRC32RotaryInput.h"
#endif
HeltecRC32Board board;
#if defined(P_LORA_SCLK)
static SPIClass spi(FSPI);
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);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, PIN_GPS_RESET, PIN_GPS_EN);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
#endif
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
#if defined(UI_HAS_ROTARY_INPUT)
static HeltecRC32RotaryInput rotaryInputImpl(&board.periph_power);
RotaryInput& rotary_input = rotaryInputImpl;
#endif
#endif
bool radio_init() {
fallback_clock.begin();
rtc_clock.begin(Wire);
#if defined(P_LORA_SCLK)
return radio.std_init(&spi);
#else
return radio.std_init();
#endif
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng);
}
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <HeltecRC32Board.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/MomentaryButton.h>
#if defined(UI_HAS_ROTARY_INPUT)
#include <helpers/ui/RotaryInput.h>
#endif
#ifdef HELTEC_RC32_WITH_DISPLAY
#include <helpers/ui/NV3001BDisplay.h>
#else
#include <helpers/ui/NullDisplayDriver.h>
#endif
#endif
extern HeltecRC32Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
#if defined(UI_HAS_ROTARY_INPUT)
extern RotaryInput& rotary_input;
#endif
#endif
bool radio_init();
mesh::LocalIdentity radio_new_identity();
+29
View File
@@ -0,0 +1,29 @@
#ifndef _VARIANT_HELTEC_RC32_
#define _VARIANT_HELTEC_RC32_
#define BUTTON_PIN 0
#define I2C_SCL 18
#define I2C_SDA 21
#define SENSOR_INT_PIN 42
#define PERIPHERAL_WARMUP_MS 100
#define LORA_SCK 11
#define LORA_MISO 13
#define LORA_MOSI 12
#define LORA_CS 10
#define LORA_DIO0 RADIOLIB_NC
#define LORA_DIO1 14
#define LORA_RESET 9
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY 1
#define SX126X_RESET LORA_RESET
#define BATTERY_PIN 7
#define ADC_CHANNEL ADC_CHANNEL_6
#define ADC_CTRL 15
#define ADC_ATTENUATION ADC_ATTEN_DB_2_5
#endif
+3 -2
View File
@@ -12,10 +12,11 @@ class LoRaFEMControl
void setRxModeEnable(void);
void setRxModeEnableWhenMCUSleep(void);
void setLNAEnable(bool enabled);
bool isLnaCanControl(void) { return lna_can_control; }
bool isLnaCanControl(void) const { return lna_can_control; }
void setLnaCanControl(bool can_control) { lna_can_control = can_control; }
bool isLNAEnabled(void) const { return lna_enabled; }
private:
bool lna_enabled = true;
bool lna_enabled = false;
bool lna_can_control = false;
};
+62 -8
View File
@@ -112,15 +112,69 @@ void T096Board::variant_shutdown() {
}
void T096Board::powerOff() {
#if ENV_INCLUDE_GPS == 1
pinMode(PIN_GPS_EN, OUTPUT);
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
#endif
loRaFEMControl.setSleepModeEnable();
variant_shutdown();
sd_power_system_off();
loRaFEMControl.setSleepModeEnable();
nrf_gpio_cfg_default(PIN_GPS_EN); // 363uA down to 39uA
NRF52Board::powerOff();
}
const char* T096Board::getManufacturerName() const {
return "Heltec T096";
}
}
bool T096Board::setLoRaFemLnaEnabled(bool enable) {
if (!loRaFEMControl.isLnaCanControl()) {
return false;
}
loRaFEMControl.setLNAEnable(enable);
loRaFEMControl.setRxModeEnable();
return true;
}
bool T096Board::isLoRaFemLnaEnabled() const {
return loRaFEMControl.isLNAEnabled();
}
void T096Board::attachDynamicPrefs(KeyValueStore* prefs) {
_prefs = prefs;
char radio_fem_rxgain[8] = { 0 };
_prefs->getByKey("fem_rxgain", radio_fem_rxgain, 7); // get initial values
setLoRaFemLnaEnabled(strcmp(radio_fem_rxgain, "1") == 0);
}
bool T096Board::handleCommand(const char* command, uint32_t sender_timestamp, char* reply) {
if (strcmp(command, "get radio.fem.rxgain") == 0) {
if (!loRaFEMControl.isLnaCanControl()) {
strcpy(reply, "Error: unsupported");
} else {
sprintf(reply, "> %s", isLoRaFemLnaEnabled() ? "on" : "off");
}
return true;
}
if (memcmp(command, "set radio.fem.rxgain ", 21) == 0) {
if (!loRaFEMControl.isLnaCanControl()) {
strcpy(reply, "Error: unsupported");
} else if (memcmp(&command[21], "on", 2) == 0) {
if (setLoRaFemLnaEnabled(true)) {
_prefs->setByKey("fem_rxgain", "1");
strcpy(reply, "OK - LoRa FEM RX gain on");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
}
} else if (memcmp(&command[21], "off", 3) == 0) {
if (setLoRaFemLnaEnabled(false)) {
_prefs->setByKey("fem_rxgain", "0");
strcpy(reply, "OK - LoRa FEM RX gain off");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
}
} else {
strcpy(reply, "Error: state must be on or off");
}
return true;
}
return false; // not handled
}
+8
View File
@@ -4,21 +4,29 @@
#include <Arduino.h>
#include <helpers/NRF52Board.h>
#include <helpers/RefCountedDigitalPin.h>
#include <helpers/KeyValueStore.h>
#include "LoRaFEMControl.h"
class T096Board : public NRF52BoardDCDC {
KeyValueStore* _prefs = NULL;
protected:
#ifdef NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
void variant_shutdown();
bool setLoRaFemLnaEnabled(bool enable);
bool isLoRaFemLnaEnabled() const;
public:
RefCountedDigitalPin periph_power;
LoRaFEMControl loRaFEMControl;
T096Board() :periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE), NRF52Board("T096_OTA") {}
void begin();
void attachDynamicPrefs(KeyValueStore* prefs);
bool handleCommand(const char* command, uint32_t sender_timestamp, char* reply) override;
void onBeforeTransmit(void) override;
void onAfterTransmit(void) override;
+26 -3
View File
@@ -50,7 +50,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
bodmer/TFT_eSPI @ ^2.4.31
debug_tool = jlink
upload_protocol = nrfutil
@@ -91,7 +91,7 @@ build_src_filter = ${Heltec_t096.build_src_filter}
[env:Heltec_t096_room_server]
extends = Heltec_t096
build_src_filter = ${Heltec_t096.build_src_filter}
+<../examples/simple_room_server>
+<../examples/simple_room_server>
build_flags =
${Heltec_t096.build_flags}
-D ADVERT_NAME='"Heltec_t096 Room"'
@@ -102,6 +102,23 @@ build_flags =
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
[env:Heltec_t096_sensor]
extends = Heltec_t096
build_flags =
${Heltec_t096.build_flags}
-D ADVERT_NAME='"Heltec_t096 Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ENV_PIN_SDA=PIN_WIRE1_SDA
-D ENV_PIN_SCL=PIN_WIRE1_SCL
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_t096.build_src_filter}
+<../examples/simple_sensor>
lib_deps =
${Heltec_t096.lib_deps}
[env:Heltec_t096_companion_radio_ble]
extends = Heltec_t096
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
@@ -134,6 +151,7 @@ build_flags =
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; -D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
@@ -144,4 +162,9 @@ build_src_filter = ${Heltec_t096.build_src_filter}
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_t096.lib_deps}
densaugeo/base64 @ ~1.4.0
densaugeo/base64 @ ~1.4.0
[env:Heltec_t096_kiss_modem]
extends = Heltec_t096
build_src_filter = ${Heltec_t096.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -43,21 +43,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -27,7 +27,4 @@ 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(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
+1 -1
View File
@@ -104,7 +104,7 @@
#define PIN_SPI_SCK (32 + 8)
#define PIN_SPI_NSS LORA_CS
#define PIN_SPI1_MISO (-1)
#define PIN_SPI1_MISO (0)
#define PIN_SPI1_MOSI (0+17)
#define PIN_SPI1_SCK (0+20)
+107
View File
@@ -0,0 +1,107 @@
#include "T1Board.h"
#include <Arduino.h>
#include <Wire.h>
#ifdef NRF52_POWER_MANAGEMENT
const PowerMgtConfig power_config = {
.lpcomp_ain_channel = PWRMGT_LPCOMP_AIN,
.lpcomp_refsel = PWRMGT_LPCOMP_REFSEL,
.voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK
};
void T1Board::initiateShutdown(uint8_t reason) {
variant_shutdown();
bool enable_lpcomp = (reason == SHUTDOWN_REASON_LOW_VOLTAGE ||
reason == SHUTDOWN_REASON_BOOT_PROTECT);
pinMode(PIN_BAT_CTL, OUTPUT);
digitalWrite(PIN_BAT_CTL, enable_lpcomp ? ADC_CTRL_ENABLED : !ADC_CTRL_ENABLED);
if (enable_lpcomp) {
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);
}
enterSystemOff(reason);
}
#endif
void T1Board::begin() {
NRF52Board::begin();
#ifdef NRF52_POWER_MANAGEMENT
checkBootVoltage(&power_config);
#endif
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
#endif
Wire.begin();
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON);
pinMode(PIN_GPS_EN, OUTPUT);
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
pinMode(PIN_SENSOR_EN, OUTPUT);
digitalWrite(PIN_SENSOR_EN, PIN_SENSOR_EN_ACTIVE);
pinMode(PIN_BUZZER, OUTPUT);
digitalWrite(PIN_BUZZER, LOW);
pinMode(PIN_BUZZER_VOLTAGE_MULTIPLIER_1, OUTPUT);
pinMode(PIN_BUZZER_VOLTAGE_MULTIPLIER_2, OUTPUT);
digitalWrite(PIN_BUZZER_VOLTAGE_MULTIPLIER_1, HIGH);
digitalWrite(PIN_BUZZER_VOLTAGE_MULTIPLIER_2, HIGH);
periph_power.begin();
delay(1);
}
void T1Board::onBeforeTransmit() {
digitalWrite(P_LORA_TX_LED, LED_STATE_ON);
}
void T1Board::onAfterTransmit() {
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON);
}
uint16_t T1Board::getBattMilliVolts() {
analogReadResolution(12);
analogReference(VBAT_AR_INTERNAL);
pinMode(PIN_VBAT_READ, INPUT);
pinMode(PIN_BAT_CTL, OUTPUT);
digitalWrite(PIN_BAT_CTL, ADC_CTRL_ENABLED);
delay(10);
int adcvalue = analogRead(PIN_VBAT_READ);
digitalWrite(PIN_BAT_CTL, !ADC_CTRL_ENABLED);
return (uint16_t)((float)adcvalue * MV_LSB * ADC_MULTIPLIER);
}
void T1Board::variant_shutdown() {
nrf_gpio_cfg_default(PIN_BUZZER_VOLTAGE_MULTIPLIER_1);
nrf_gpio_cfg_default(PIN_BUZZER_VOLTAGE_MULTIPLIER_2);
pinMode(PIN_BUZZER, OUTPUT);
digitalWrite(PIN_BUZZER, LOW);
pinMode(PIN_SENSOR_EN, OUTPUT);
digitalWrite(PIN_SENSOR_EN, !PIN_SENSOR_EN_ACTIVE);
pinMode(PIN_LED1, OUTPUT);
digitalWrite(PIN_LED1, !LED_STATE_ON);
pinMode(PIN_BAT_CTL, OUTPUT);
digitalWrite(PIN_BAT_CTL, !ADC_CTRL_ENABLED);
}
void T1Board::powerOff() {
variant_shutdown();
NRF52Board::powerOff();
}
const char* T1Board::getManufacturerName() const {
return "Heltec T1";
}
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#include <Arduino.h>
#include <MeshCore.h>
#include <helpers/NRF52Board.h>
#include <helpers/RefCountedDigitalPin.h>
class T1Board : public NRF52BoardDCDC {
protected:
#ifdef NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
void variant_shutdown();
public:
RefCountedDigitalPin periph_power;
T1Board() : periph_power(PIN_TFT_VDD_CTL, PIN_TFT_VDD_CTL_ACTIVE), NRF52Board("T1_OTA") {}
void begin();
void onBeforeTransmit() override;
void onAfterTransmit() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override;
void powerOff() override;
};
+109
View File
@@ -0,0 +1,109 @@
[Heltec_t1]
extends = nrf52_base
board = heltec_t1
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_t1
-I src/helpers/ui
-D HELTEC_T1
-D NRF52_POWER_MANAGEMENT
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D DISPLAY_CLASS=ST7735Display
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<../variants/heltec_t1>
+<helpers/ui/ST7735Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
bodmer/TFT_eSPI @ ^2.4.31
debug_tool = jlink
upload_protocol = nrfutil
[env:Heltec_t1_repeater]
extends = Heltec_t1
build_src_filter = ${Heltec_t1.build_src_filter}
+<../examples/simple_repeater>
build_flags =
${Heltec_t1.build_flags}
-D ADVERT_NAME='"Heltec_t1 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
[env:Heltec_t1_room_server]
extends = Heltec_t1
build_src_filter = ${Heltec_t1.build_src_filter}
+<../examples/simple_room_server>
build_flags =
${Heltec_t1.build_flags}
-D ADVERT_NAME='"Heltec_t1 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
[env:Heltec_t1_companion_radio_ble]
extends = Heltec_t1
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t1.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D ENV_INCLUDE_GPS=1
; -D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_t1.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_t1.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:Heltec_t1_companion_radio_usb]
extends = Heltec_t1
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_t1.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_t1.build_src_filter}
+<helpers/nrf52/*.cpp>
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_t1.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:Heltec_t1_kiss_modem]
extends = Heltec_t1
build_src_filter = ${Heltec_t1.build_src_filter}
+<../examples/kiss_modem/>
+48
View File
@@ -0,0 +1,48 @@
#include "target.h"
#include <Arduino.h>
#include <helpers/ArduinoHelpers.h>
#ifdef ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
#endif
T1Board 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);
#if ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, GPS_RESET, GPS_EN, &board.periph_power);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
#endif
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display(&board.periph_power);
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
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng);
}
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <T1Board.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/MomentaryButton.h>
#include <helpers/ui/ST7735Display.h>
#else
#include "helpers/ui/NullDisplayDriver.h"
#endif
extern T1Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
#endif
bool radio_init();
mesh::LocalIdentity radio_new_identity();
+15
View File
@@ -0,0 +1,15 @@
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
const uint32_t g_ADigitalPinMap[] = {
0xff, 0xff, 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, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47
};
void initVariant()
{
pinMode(PIN_USER_BTN, INPUT);
}
+168
View File
@@ -0,0 +1,168 @@
/*
* Heltec Mesh Node T1 nRF52840 variant.
*/
#pragma once
#include "WVariant.h"
#define USE_LFXO
#define VARIANT_MCK (64000000ul)
////////////////////////////////////////////////////////////////////////////////
// Number of pins
#define PINS_COUNT (48)
#define NUM_DIGITAL_PINS (48)
#define NUM_ANALOG_INPUTS (1)
#define NUM_ANALOG_OUTPUTS (0)
////////////////////////////////////////////////////////////////////////////////
// Display
#define ST7735_CS (0 + 12)
#define ST7735_RS (0 + 22)
#define ST7735_SDA (0 + 24)
#define ST7735_SCK (32 + 0)
#define ST7735_RESET (0 + 20)
#define ST7735_MISO (0) // 0 maps to 0xff on this device which is NRFX_SPIM_PIN_NOT_USED
#define ST7735_BUSY (0) // 0 maps to 0xff on this device which is NRFX_SPIM_PIN_NOT_USED
#define ST7735_BL (0 + 15)
#define VTFT_CTRL (0 + 13)
#define PIN_TFT_CS ST7735_CS
#define PIN_TFT_DC ST7735_RS
#define PIN_TFT_SDA ST7735_SDA
#define PIN_TFT_SCL ST7735_SCK
#define PIN_TFT_RST ST7735_RESET
#define PIN_TFT_LEDA_CTL ST7735_BL
#define PIN_TFT_LEDA_CTL_ACTIVE LOW
#define PIN_TFT_VDD_CTL VTFT_CTRL
#define PIN_TFT_VDD_CTL_ACTIVE LOW
#define DISPLAY_ROTATION 3
////////////////////////////////////////////////////////////////////////////////
// Builtin LEDs
#define PIN_LED1 (0 + 16)
#define LED_BUILTIN PIN_LED1
#define PIN_LED LED_BUILTIN
#define LED_RED (-1)
#define LED_BLUE (-1)
#define LED_GREEN (-1)
#define LED_PIN LED_BUILTIN
#define LED_STATE_ON LOW
////////////////////////////////////////////////////////////////////////////////
// Builtin buttons
#define PIN_BUTTON1 (32 + 10)
#define PIN_BUTTON2 (0 + 14)
#define BUTTON_PIN PIN_BUTTON1
#define BUTTON_PIN2 PIN_BUTTON2
#define PIN_USER_BTN BUTTON_PIN
////////////////////////////////////////////////////////////////////////////////
// UART
// No longer populated on PCB.
// Removed the pin definitions to avoid potential issues with Uart.
////////////////////////////////////////////////////////////////////////////////
// I2C
#define WIRE_INTERFACES_COUNT (1)
#define PIN_WIRE_SDA (32 + 3)
#define PIN_WIRE_SCL (0 + 10)
#define PIN_SENSOR_EN (32 + 6)
#define PIN_SENSOR_EN_ACTIVE LOW
////////////////////////////////////////////////////////////////////////////////
// LoRa
#define USE_SX1262
#define SX126X_CS (32 + 11)
#define LORA_CS SX126X_CS
#define SX126X_DIO1 (0 + 31)
#define SX126X_BUSY (0 + 29)
#define SX126X_RESET (0 + 2)
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
#define SX126X_CURRENT_LIMIT 140
#define SX126X_RX_BOOSTED_GAIN 1
#define P_LORA_DIO_1 SX126X_DIO1
#define P_LORA_NSS LORA_CS
#define P_LORA_RESET SX126X_RESET
#define P_LORA_BUSY SX126X_BUSY
#define P_LORA_TX_LED PIN_LED1
////////////////////////////////////////////////////////////////////////////////
// SPI
#define SPI_INTERFACES_COUNT (2)
#define PIN_SPI_MISO (0 + 3)
#define PIN_SPI_MOSI (32 + 14)
#define PIN_SPI_SCK (32 + 13)
#define PIN_SPI_NSS LORA_CS
#define PIN_SPI1_MISO ST7735_MISO
#define PIN_SPI1_MOSI ST7735_SDA
#define PIN_SPI1_SCK ST7735_SCK
#define P_LORA_SCLK PIN_SPI_SCK
#define P_LORA_MISO PIN_SPI_MISO
#define P_LORA_MOSI PIN_SPI_MOSI
////////////////////////////////////////////////////////////////////////////////
// GPS
#define GPS_UC6580
#define GPS_BAUD_RATE 115200
#define PIN_GPS_RESET (0 + 26)
#define GPS_RESET PIN_GPS_RESET
#define GPS_RESET_MODE LOW
#define PIN_GPS_RESET_ACTIVE LOW
#define PIN_GPS_EN (0 + 4)
#define GPS_EN PIN_GPS_EN
#define GPS_EN_ACTIVE LOW
#define PIN_GPS_EN_ACTIVE LOW
#define PIN_GPS_PPS (32 + 9)
#define GPS_TX_PIN (0 + 8)
#define GPS_RX_PIN (0 + 7)
#define PIN_GPS_TX GPS_TX_PIN
#define PIN_GPS_RX GPS_RX_PIN
#define PIN_SERIAL1_RX GPS_RX_PIN
#define PIN_SERIAL1_TX GPS_TX_PIN
////////////////////////////////////////////////////////////////////////////////
// Buzzer
#define PIN_BUZZER (0 + 9)
#define PIN_BUZZER_VOLTAGE_MULTIPLIER_1 (32 + 2)
#define PIN_BUZZER_VOLTAGE_MULTIPLIER_2 (32 + 5)
////////////////////////////////////////////////////////////////////////////////
// Battery
#define ADC_CTRL (0 + 11)
#define PIN_BAT_CTL ADC_CTRL
#define ADC_CTRL_ENABLED HIGH
#define BATTERY_PIN (0 + 5)
#define PIN_VBAT_READ BATTERY_PIN
#define ADC_RESOLUTION (14)
#define AREF_VOLTAGE (3.0)
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
#define ADC_MULTIPLIER (4.916F)
#define MV_LSB (3000.0F / 4096.0F)
#define PWRMGT_VOLTAGE_BOOTLOCK 3100
#define PWRMGT_LPCOMP_AIN 3
#define PWRMGT_LPCOMP_REFSEL 1
#define HAS_RTC 0
+1 -1
View File
@@ -33,7 +33,7 @@ void T114Board::initiateShutdown(uint8_t reason) {
#endif // NRF52_POWER_MANAGEMENT
void T114Board::begin() {
NRF52Board::begin();
NRF52BoardDCDC::begin();
pinMode(PIN_VBAT_READ, INPUT);
+2 -5
View File
@@ -50,10 +50,7 @@ public:
#ifdef LED_PIN
digitalWrite(LED_PIN, HIGH);
#endif
#if ENV_INCLUDE_GPS == 1
pinMode(GPS_EN, OUTPUT);
digitalWrite(GPS_EN, LOW);
#endif
sd_power_system_off();
NRF52Board::powerOff();
}
};
+10 -6
View File
@@ -49,7 +49,6 @@ upload_protocol = nrfutil
extends = Heltec_t114
build_src_filter = ${Heltec_t114.build_src_filter}
+<../examples/simple_repeater>
build_flags =
${Heltec_t114.build_flags}
-D ADVERT_NAME='"Heltec_T114 Repeater"'
@@ -109,6 +108,7 @@ build_flags =
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_t114.build_src_filter}
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
@@ -126,12 +126,10 @@ build_flags =
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
; -D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
-D ENABLE_USB_INTERFACE
build_src_filter = ${Heltec_t114.build_src_filter}
+<helpers/nrf52/*.cpp>
+<helpers/ui/NullDisplayDriver.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
@@ -240,6 +238,7 @@ build_flags =
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; -D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
@@ -250,4 +249,9 @@ build_src_filter = ${Heltec_t114_with_display.build_src_filter}
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_t114_with_display.lib_deps}
densaugeo/base64 @ ~1.4.0
densaugeo/base64 @ ~1.4.0
[env:Heltec_t114_kiss_modem]
extends = Heltec_t114
build_src_filter = ${Heltec_t114.build_src_filter}
+<../examples/kiss_modem/>
+1 -16
View File
@@ -22,7 +22,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -43,21 +43,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -29,7 +29,4 @@ 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(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
-27
View File
@@ -20,33 +20,6 @@ void HeltecT190Board::begin() {
}
}
void HeltecT190Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
if (pin_wake_btn < 0) {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
} else {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
}
if (secs > 0) {
esp_sleep_enable_timer_wakeup(secs * 1000000);
}
// Finally set ESP32 into sleep
esp_deep_sleep_start(); // CPU halts here and never returns!
}
void HeltecT190Board::powerOff() {
enterDeepSleep(0);
}
uint16_t HeltecT190Board::getBattMilliVolts() {
analogReadResolution(10);
digitalWrite(PIN_ADC_CTRL, HIGH);
-3
View File
@@ -3,7 +3,6 @@
#include <Arduino.h>
#include <helpers/RefCountedDigitalPin.h>
#include <helpers/ESP32Board.h>
#include <driver/rtc_io.h>
class HeltecT190Board : public ESP32Board {
@@ -13,8 +12,6 @@ public:
HeltecT190Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
void begin();
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
void powerOff() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override ;
+6
View File
@@ -74,6 +74,7 @@ build_flags =
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
-D ENABLE_USB_INTERFACE
build_src_filter = ${Heltec_T190_base.build_src_filter}
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
@@ -153,3 +154,8 @@ build_src_filter = ${Heltec_T190_base.build_src_filter}
lib_deps =
${Heltec_T190_base.lib_deps}
${esp32_ota.lib_deps}
[env:Heltec_T190_kiss_modem]
extends = Heltec_T190_base
build_src_filter = ${Heltec_T190_base.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -33,21 +33,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -23,7 +23,4 @@ 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(int8_t dbm);
mesh::LocalIdentity radio_new_identity();
@@ -0,0 +1,103 @@
#include "HeltecTowerV2Board.h"
#include <Arduino.h>
#include <Wire.h>
extern void variant_shutdown();
#ifdef NRF52_POWER_MANAGEMENT
const PowerMgtConfig power_config = {
.lpcomp_ain_channel = PWRMGT_LPCOMP_AIN,
.lpcomp_refsel = PWRMGT_LPCOMP_REFSEL,
.voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK
};
void HeltecTowerV2Board::initiateShutdown(uint8_t reason) {
pinMode(PIN_GPS_EN, OUTPUT);
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
pinMode(PIN_GPS_STANDBY, OUTPUT);
digitalWrite(PIN_GPS_STANDBY, LOW);
pinMode(PIN_GPS_RESET, OUTPUT);
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE);
loRaFEMControl.setSleepModeEnable();
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);
}
variant_shutdown();
enterSystemOff(reason);
}
#endif
void HeltecTowerV2Board::begin() {
NRF52Board::begin();
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON);
pinMode(PIN_BAT_CTL, OUTPUT);
digitalWrite(PIN_BAT_CTL, LOW);
#ifdef NRF52_POWER_MANAGEMENT
checkBootVoltage(&power_config);
#endif
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
Wire.begin();
pinMode(PIN_GPS_EN, OUTPUT);
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
pinMode(PIN_GPS_RESET, OUTPUT);
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE);
pinMode(PIN_GPS_STANDBY, OUTPUT);
digitalWrite(PIN_GPS_STANDBY, HIGH);
loRaFEMControl.init();
}
void HeltecTowerV2Board::onBeforeTransmit() {
digitalWrite(P_LORA_TX_LED, LED_STATE_ON);
loRaFEMControl.setTxModeEnable();
}
void HeltecTowerV2Board::onAfterTransmit() {
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON);
loRaFEMControl.setRxModeEnable();
}
uint16_t HeltecTowerV2Board::getBattMilliVolts() {
analogReadResolution(12);
analogReference(VBAT_AR_INTERNAL);
pinMode(PIN_VBAT_READ, INPUT);
pinMode(PIN_BAT_CTL, OUTPUT);
digitalWrite(PIN_BAT_CTL, HIGH);
delay(10);
int adcvalue = analogRead(PIN_VBAT_READ);
digitalWrite(PIN_BAT_CTL, LOW);
return (uint16_t)((float)adcvalue * MV_LSB * ADC_MULTIPLIER);
}
const char* HeltecTowerV2Board::getManufacturerName() const {
return "Heltec Tower V2";
}
void HeltecTowerV2Board::powerOff() {
pinMode(PIN_GPS_EN, OUTPUT);
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
pinMode(PIN_GPS_STANDBY, OUTPUT);
digitalWrite(PIN_GPS_STANDBY, LOW);
pinMode(PIN_GPS_RESET, OUTPUT);
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE);
loRaFEMControl.setSleepModeEnable();
pinMode(PIN_BAT_CTL, OUTPUT);
digitalWrite(PIN_BAT_CTL, LOW);
variant_shutdown();
sd_power_system_off();
}
@@ -0,0 +1,24 @@
#pragma once
#include <Arduino.h>
#include <MeshCore.h>
#include <helpers/NRF52Board.h>
#include "LoRaFEMControl.h"
class HeltecTowerV2Board : public NRF52BoardDCDC {
protected:
#ifdef NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
public:
LoRaFEMControl loRaFEMControl;
HeltecTowerV2Board() : NRF52Board("TOWER_V2_OTA") {}
void begin();
void onBeforeTransmit() override;
void onAfterTransmit() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override;
void powerOff() override;
};
@@ -0,0 +1,40 @@
#include "LoRaFEMControl.h"
#include <Arduino.h>
#include "variant.h"
static void enableFEMPower() {
bool wasOff = digitalRead(LORA_KCT8103L_EN) != HIGH;
digitalWrite(LORA_KCT8103L_EN, HIGH);
if (wasOff) {
delay(5);
}
}
void LoRaFEMControl::init() {
pinMode(LORA_KCT8103L_EN, OUTPUT);
digitalWrite(LORA_KCT8103L_EN, HIGH);
delay(1);
pinMode(LORA_KCT8103L_TX_RX, OUTPUT);
digitalWrite(LORA_KCT8103L_TX_RX, LOW);
}
void LoRaFEMControl::setSleepModeEnable() {
pinMode(LORA_KCT8103L_EN, OUTPUT);
digitalWrite(LORA_KCT8103L_EN, LOW);
}
void LoRaFEMControl::setTxModeEnable() {
enableFEMPower();
digitalWrite(LORA_KCT8103L_TX_RX, HIGH);
}
void LoRaFEMControl::setRxModeEnable() {
enableFEMPower();
digitalWrite(LORA_KCT8103L_TX_RX, LOW);
}
void LoRaFEMControl::setRxModeEnableWhenMCUSleep() {
enableFEMPower();
digitalWrite(LORA_KCT8103L_TX_RX, LOW);
}
+13
View File
@@ -0,0 +1,13 @@
#pragma once
class LoRaFEMControl {
public:
LoRaFEMControl() {}
virtual ~LoRaFEMControl() {}
void init();
void setSleepModeEnable();
void setTxModeEnable();
void setRxModeEnable();
void setRxModeEnableWhenMCUSleep();
};
+107
View File
@@ -0,0 +1,107 @@
[Heltec_tower_v2]
extends = nrf52_base
board = heltec_tower_v2
board_build.ldscript = boards/nrf52840_s140_v6.ld
build_flags = ${nrf52_base.build_flags}
-D ENV_INCLUDE_GPS=1
-I lib/nrf52/s140_nrf52_6.1.1_API/include
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
-I variants/heltec_tower_v2
-D HELTEC_TOWER_V2
-D NRF52_POWER_MANAGEMENT
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=12
-D MAX_LORA_TX_POWER=22 ; Max SX1262 output -> ~29dBm at antenna
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<../variants/heltec_tower_v2>
lib_deps =
${nrf52_base.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
debug_tool = jlink
upload_protocol = nrfutil
[env:Heltec_tower_v2_repeater]
extends = Heltec_tower_v2
build_src_filter = ${Heltec_tower_v2.build_src_filter}
+<../examples/simple_repeater>
build_flags =
${Heltec_tower_v2.build_flags}
-D ADVERT_NAME='"Heltec_Tower_V2 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
[env:Heltec_tower_v2_room_server]
extends = Heltec_tower_v2
build_src_filter = ${Heltec_tower_v2.build_src_filter}
+<../examples/simple_room_server>
build_flags =
${Heltec_tower_v2.build_flags}
-D ADVERT_NAME='"Heltec_Tower_V2 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
[env:Heltec_tower_v2_companion_radio_ble]
extends = Heltec_tower_v2
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_tower_v2.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
; -D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_tower_v2.build_src_filter}
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_tower_v2.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Heltec_tower_v2_companion_radio_usb]
extends = Heltec_tower_v2
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${Heltec_tower_v2.build_flags}
-I examples/companion_radio/ui-new
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; -D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_tower_v2.build_src_filter}
+<helpers/ui/NullDisplayDriver.cpp>
+<helpers/nrf52/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${Heltec_tower_v2.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Heltec_tower_v2_kiss_modem]
extends = Heltec_tower_v2
build_src_filter = ${Heltec_tower_v2.build_src_filter}
+<../examples/kiss_modem/>
+64
View File
@@ -0,0 +1,64 @@
#include "target.h"
#include <Arduino.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/MicroNMEALocationProvider.h>
HeltecTowerV2Board 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);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
TowerV2ExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
#endif
bool radio_init() {
rtc_clock.begin(Wire);
return radio.std_init(&SPI);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng);
}
bool TowerV2ExternalWatchdog::begin() {
last_feed_watchdog = 0;
pinMode(EXTERNAL_WATCHDOG_WAKE_PIN, INPUT);
pinMode(EXTERNAL_WATCHDOG_DONE_PIN, OUTPUT);
delay(1);
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
delay(1);
feed();
return true;
}
void TowerV2ExternalWatchdog::loop() {
if (millis() - last_feed_watchdog >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
feed();
}
}
unsigned long TowerV2ExternalWatchdog::getIntervalMs() const {
unsigned long elapsed_ms = millis() - last_feed_watchdog;
if (elapsed_ms >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
return 0;
}
return EXTERNAL_WATCHDOG_FEED_INTERVAL_MS - elapsed_ms;
}
void TowerV2ExternalWatchdog::feed() {
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, HIGH);
delay(1);
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
last_feed_watchdog = millis();
}
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <HeltecTowerV2Board.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#include <helpers/ExternalWatchdogManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/MomentaryButton.h>
#include "helpers/ui/NullDisplayDriver.h"
#endif
class TowerV2ExternalWatchdog : public ExternalWatchdogManager {
public:
TowerV2ExternalWatchdog() {}
bool begin() override;
void loop() override;
unsigned long getIntervalMs() const override;
void feed() override;
};
extern HeltecTowerV2Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
extern TowerV2ExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
#endif
bool radio_init();
mesh::LocalIdentity radio_new_identity();
+42
View File
@@ -0,0 +1,42 @@
#include "variant.h"
#include "Arduino.h"
#include "nrf.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
const uint32_t g_ADigitalPinMap[] = {
0xff, 0xff, 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, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47
};
void initVariant()
{
}
void variant_shutdown()
{
nrf_gpio_cfg_default(PIN_GPS_EN);
nrf_gpio_cfg_default(PIN_GPS_PPS);
nrf_gpio_cfg_default(PIN_GPS_RESET);
nrf_gpio_cfg_default(PIN_GPS_STANDBY);
nrf_gpio_cfg_default(GPS_RX_PIN);
nrf_gpio_cfg_default(GPS_TX_PIN);
pinMode(LORA_KCT8103L_EN, OUTPUT);
digitalWrite(LORA_KCT8103L_EN, LOW);
nrf_gpio_cfg_default(LORA_KCT8103L_TX_RX);
nrf_gpio_cfg_default(RF_PA_DETECT_PIN);
nrf_gpio_cfg_default(SX126X_CS);
nrf_gpio_cfg_default(SX126X_DIO1);
nrf_gpio_cfg_default(SX126X_BUSY);
nrf_gpio_cfg_default(SX126X_RESET);
nrf_gpio_cfg_default(PIN_SPI_MISO);
nrf_gpio_cfg_default(PIN_SPI_MOSI);
nrf_gpio_cfg_default(PIN_SPI_SCK);
nrf_gpio_cfg_default(PIN_LED);
detachInterrupt(PIN_GPS_PPS);
detachInterrupt(PIN_BUTTON1);
}
+108
View File
@@ -0,0 +1,108 @@
#pragma once
#include "WVariant.h"
#define USE_LFXO
#define VARIANT_MCK (64000000ul)
#define PINS_COUNT (48)
#define NUM_DIGITAL_PINS (48)
#define NUM_ANALOG_INPUTS (1)
#define NUM_ANALOG_OUTPUTS (0)
#define WIRE_INTERFACES_COUNT (1)
#define PIN_WIRE_SDA (0 + 30)
#define PIN_WIRE_SCL (0 + 5)
#define PIN_BOARD_SDA PIN_WIRE_SDA
#define PIN_BOARD_SCL PIN_WIRE_SCL
#define SPI_INTERFACES_COUNT (1)
#define PIN_SPI_MISO (0 + 23)
#define PIN_SPI_MOSI (0 + 22)
#define PIN_SPI_SCK (0 + 19)
#define PIN_SPI_NSS LORA_CS
#define LED_BUILTIN (32 + 15)
#define PIN_LED LED_BUILTIN
#define LED_RED (-1)
#define LED_GREEN (-1)
#define LED_BLUE (-1)
#define LED_PIN (-1)
#define P_LORA_TX_LED LED_BUILTIN
#define LED_STATE_ON LOW
#define PIN_BUTTON1 (32 + 10)
#define BUTTON_PIN PIN_BUTTON1
#define PIN_USER_BTN BUTTON_PIN
#define USE_SX1262
#define SX126X_CS (0 + 24)
#define LORA_CS SX126X_CS
#define SX126X_DIO1 (0 + 20)
#define SX126X_BUSY (0 + 17)
#define SX126X_RESET (0 + 25)
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
#define P_LORA_NSS LORA_CS
#define P_LORA_DIO_1 SX126X_DIO1
#define P_LORA_BUSY SX126X_BUSY
#define P_LORA_RESET SX126X_RESET
#define P_LORA_MISO PIN_SPI_MISO
#define P_LORA_MOSI PIN_SPI_MOSI
#define P_LORA_SCLK PIN_SPI_SCK
#define USE_KCT8103L_PA_ONLY
#define LORA_KCT8103L_EN (0 + 15)
#define LORA_KCT8103L_TX_RX (0 + 16)
#define LORA_PA_POWER LORA_KCT8103L_EN
#define RF_PA_DETECT_PIN (0 + 13)
#define RF_PA_HIGH_POWER_VALUE HIGH
#define GPS_L76K
#define GPS_RESET_MODE LOW
#define PIN_GPS_RESET (32 + 6)
#define PIN_GPS_RESET_ACTIVE GPS_RESET_MODE
#define PIN_GPS_EN (0 + 7)
#define PIN_GPS_EN_ACTIVE LOW
#define GPS_EN_ACTIVE PIN_GPS_EN_ACTIVE
#define PIN_GPS_STANDBY (32 + 2)
#define PIN_GPS_PPS (32 + 4)
#define GPS_BAUD_RATE 9600
// Upstream names are from the GPS perspective. MeshCore's PIN_GPS_TX is the
// CPU RX pin because EnvironmentSensorManager passes it as Serial1 RX.
#define GPS_TX_PIN (32 + 7)
#define GPS_RX_PIN (32 + 5)
#define PIN_GPS_TX GPS_RX_PIN
#define PIN_GPS_RX GPS_TX_PIN
#define PIN_SERIAL1_RX PIN_GPS_TX
#define PIN_SERIAL1_TX PIN_GPS_RX
#define PIN_SERIAL2_RX (-1)
#define PIN_SERIAL2_TX (-1)
#define HAS_EXTERNAL_WATCHDOG
#define EXTERNAL_WATCHDOG_DONE_PIN (0 + 9)
#define EXTERNAL_WATCHDOG_WAKE_PIN (0 + 10)
#define EXTERNAL_WATCHDOG_FEED_INTERVAL_MS (8 * 60 * 1000)
#define SERIAL_PRINT_PORT 0
#define PIN_BAT_CTL (0 + 21)
#define ADC_CTRL PIN_BAT_CTL
#define ADC_CTRL_ENABLED HIGH
#define BATTERY_PIN (0 + 4)
#define PIN_VBAT_READ BATTERY_PIN
#define ADC_RESOLUTION 14
#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 (4.916F)
#define MV_LSB (3000.0F / 4096.0F)
#define NRF52_POWER_MANAGEMENT
#define PWRMGT_VOLTAGE_BOOTLOCK 3100
#define PWRMGT_LPCOMP_AIN 2
#define PWRMGT_LPCOMP_REFSEL 1
+7 -1
View File
@@ -47,7 +47,7 @@ build_src_filter = ${esp32_base.build_src_filter}
lib_deps =
${esp32_base.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
bodmer/TFT_eSPI @ ^2.4.31
[env:Heltec_Wireless_Tracker_companion_radio_usb]
extends = Heltec_tracker_base
@@ -59,6 +59,7 @@ build_flags =
-D DISPLAY_CLASS=ST7735Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; -D BLE_PIN_CODE=123456 ; HWT will use display for pin
; -D OFFLINE_QUEUE_SIZE=256
; -D BLE_DEBUG_LOGGING=1
@@ -186,3 +187,8 @@ build_src_filter = ${Heltec_tracker_base.build_src_filter}
lib_deps =
${Heltec_tracker_base.lib_deps}
${esp32_ota.lib_deps}
[env:Heltec_Wireless_Tracker_kiss_modem]
extends = Heltec_tracker_base
build_src_filter = ${Heltec_tracker_base.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -37,21 +37,6 @@ bool radio_init() {
}
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
-3
View File
@@ -42,7 +42,4 @@ extern HWTSensorManager sensors;
#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();
@@ -35,33 +35,12 @@ void HeltecTrackerV2Board::begin() {
loRaFEMControl.setRxModeEnable();
}
void HeltecTrackerV2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
void HeltecTrackerV2Board::powerOff() {
// Turn off PA
digitalWrite(P_LORA_PA_POWER, LOW);
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER);
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
loRaFEMControl.setRxModeEnableWhenMCUSleep();//It also needs to be enabled in receive mode
if (pin_wake_btn < 0) {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
} else {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
}
if (secs > 0) {
esp_sleep_enable_timer_wakeup(secs * 1000000);
}
// Finally set ESP32 into sleep
esp_deep_sleep_start(); // CPU halts here and never returns!
}
void HeltecTrackerV2Board::powerOff() {
enterDeepSleep(0);
ESP32Board::powerOff();
}
uint16_t HeltecTrackerV2Board::getBattMilliVolts() {
@@ -82,3 +61,61 @@ void HeltecTrackerV2Board::begin() {
const char* HeltecTrackerV2Board::getManufacturerName() const {
return "Heltec Tracker V2";
}
bool HeltecTrackerV2Board::setLoRaFemLnaEnabled(bool enable) {
if (!loRaFEMControl.isLnaCanControl()) {
return false;
}
loRaFEMControl.setLNAEnable(enable);
loRaFEMControl.setRxModeEnable();
return true;
}
bool HeltecTrackerV2Board::isLoRaFemLnaEnabled() const {
return loRaFEMControl.isLNAEnabled();
}
void HeltecTrackerV2Board::attachDynamicPrefs(KeyValueStore* prefs) {
_prefs = prefs;
char radio_fem_rxgain[8] = { 0 };
_prefs->getByKey("fem_rxgain", radio_fem_rxgain, 7); // get initial values
setLoRaFemLnaEnabled(strcmp(radio_fem_rxgain, "1") == 0);
}
bool HeltecTrackerV2Board::handleCommand(const char* command, uint32_t sender_timestamp, char* reply) {
if (strcmp(command, "get radio.fem.rxgain") == 0) {
if (!loRaFEMControl.isLnaCanControl()) {
strcpy(reply, "Error: unsupported");
} else {
sprintf(reply, "> %s", isLoRaFemLnaEnabled() ? "on" : "off");
}
return true;
}
if (memcmp(command, "set radio.fem.rxgain ", 21) == 0) {
if (!loRaFEMControl.isLnaCanControl()) {
strcpy(reply, "Error: unsupported");
} else if (memcmp(&command[21], "on", 2) == 0) {
if (setLoRaFemLnaEnabled(true)) {
_prefs->setByKey("fem_rxgain", "1");
strcpy(reply, "OK - LoRa FEM RX gain on");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
}
} else if (memcmp(&command[21], "off", 3) == 0) {
if (setLoRaFemLnaEnabled(false)) {
_prefs->setByKey("fem_rxgain", "0");
strcpy(reply, "OK - LoRa FEM RX gain off");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
}
} else {
strcpy(reply, "Error: state must be on or off");
}
return true;
}
return false; // not handled
}
@@ -3,10 +3,13 @@
#include <Arduino.h>
#include <helpers/RefCountedDigitalPin.h>
#include <helpers/ESP32Board.h>
#include <driver/rtc_io.h>
#include "LoRaFEMControl.h"
class HeltecTrackerV2Board : public ESP32Board {
KeyValueStore* _prefs = NULL;
bool setLoRaFemLnaEnabled(bool enable);
bool isLoRaFemLnaEnabled() const;
public:
RefCountedDigitalPin periph_power;
@@ -15,9 +18,11 @@ public:
HeltecTrackerV2Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
void begin();
void attachDynamicPrefs(KeyValueStore* prefs);
bool handleCommand(const char* command, uint32_t sender_timestamp, char* reply) override;
void onBeforeTransmit(void) override;
void onAfterTransmit(void) override;
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
void powerOff() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override ;
+3 -2
View File
@@ -12,10 +12,11 @@ class LoRaFEMControl
void setRxModeEnable(void);
void setRxModeEnableWhenMCUSleep(void);
void setLNAEnable(bool enabled);
bool isLnaCanControl(void) { return lna_can_control; }
bool isLnaCanControl(void) const { return lna_can_control; }
void setLnaCanControl(bool can_control) { lna_can_control = can_control; }
bool isLNAEnabled(void) const { return lna_enabled; }
private:
bool lna_enabled = true;
bool lna_enabled = false;
bool lna_can_control = false;
};
+10 -2
View File
@@ -55,7 +55,7 @@ build_src_filter = ${esp32_base.build_src_filter}
lib_deps =
${esp32_base.lib_deps}
${sensor_base.lib_deps}
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
bodmer/TFT_eSPI @ ^2.4.31
[env:heltec_tracker_v2_repeater]
extends = Heltec_tracker_v2
@@ -140,6 +140,7 @@ build_flags =
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=ST7735Display
-D ENABLE_USB_INTERFACE
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${Heltec_tracker_v2.build_src_filter}
@@ -181,19 +182,21 @@ extends = Heltec_tracker_v2
build_flags =
${Heltec_tracker_v2.build_flags}
-I examples/companion_radio/ui-new
-D ENABLE_WIFI_INTERFACE
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=ST7735Display
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
-D OFFLINE_QUEUE_SIZE=256
-D OFFLINE_QUEUE_SIZE=256
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_tracker_v2.build_src_filter}
+<helpers/ui/ST7735Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
@@ -217,3 +220,8 @@ build_src_filter = ${Heltec_tracker_v2.build_src_filter}
lib_deps =
${Heltec_tracker_v2.lib_deps}
${esp32_ota.lib_deps}
[env:heltec_tracker_v2_kiss_modem]
extends = Heltec_tracker_v2
build_src_filter = ${Heltec_tracker_v2.build_src_filter}
+<../examples/kiss_modem/>
-15
View File
@@ -39,21 +39,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -24,8 +24,5 @@ extern EnvironmentSensorManager sensors;
#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();
+6 -27
View File
@@ -7,8 +7,6 @@
#define PIN_VBAT_READ 37
#define PIN_LED_BUILTIN 25
#include <driver/rtc_io.h>
class HeltecV2Board : public ESP32Board {
public:
void begin() {
@@ -17,38 +15,15 @@ public:
esp_reset_reason_t reason = esp_reset_reason();
if (reason == ESP_RST_DEEPSLEEP) {
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
if (wakeup_source & (1 << P_LORA_DIO_0)) { // received a LoRa packet (while in deep sleep)
startup_reason = BD_STARTUP_RX_PACKET;
}
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_0);
}
}
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
if (pin_wake_btn < 0) {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
} else {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
}
if (secs > 0) {
esp_sleep_enable_timer_wakeup(secs * 1000000);
}
// Finally set ESP32 into sleep
esp_deep_sleep_start(); // CPU halts here and never returns!
}
uint16_t getBattMilliVolts() override {
analogReadResolution(10);
@@ -64,4 +39,8 @@ public:
const char* getManufacturerName() const override {
return "Heltec V2";
}
uint32_t getIRQGpio() override {
return P_LORA_DIO_0; // default for SX1276
}
};
+14 -6
View File
@@ -7,10 +7,10 @@ build_flags =
-D HELTEC_LORA_V2
-D RADIO_CLASS=CustomSX1276
-D WRAPPER_CLASS=CustomSX1276Wrapper
-D P_LORA_DIO_1=26
-D P_LORA_DIO_0=26
-D P_LORA_DIO_1=35
-D P_LORA_NSS=18
-D P_LORA_RESET=RADIOLIB_NC
-D P_LORA_BUSY=RADIOLIB_NC
-D P_LORA_RESET=14
-D P_LORA_SCLK=5
-D P_LORA_MISO=19
-D P_LORA_MOSI=27
@@ -137,6 +137,7 @@ build_flags =
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=160
-D MAX_GROUP_CHANNELS=8
-D ENABLE_USB_INTERFACE
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v2.build_src_filter}
@@ -159,7 +160,7 @@ build_flags =
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
-D OFFLINE_QUEUE_SIZE=128
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v2.build_src_filter}
@@ -177,17 +178,19 @@ extends = Heltec_lora32_v2
build_flags =
${Heltec_lora32_v2.build_flags}
-I examples/companion_radio/ui-new
-D ENABLE_WIFI_INTERFACE
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=100
-D MAX_CONTACTS=160
-D MAX_GROUP_CHANNELS=8
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
-D OFFLINE_QUEUE_SIZE=256
-D OFFLINE_QUEUE_SIZE=128
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v2.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
@@ -195,3 +198,8 @@ build_src_filter = ${Heltec_lora32_v2.build_src_filter}
lib_deps =
${Heltec_lora32_v2.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Heltec_v2_kiss_modem]
extends = Heltec_lora32_v2
build_src_filter = ${Heltec_lora32_v2.build_src_filter}
+<../examples/kiss_modem/>
+2 -17
View File
@@ -5,9 +5,9 @@ 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);
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1);
#endif
WRAPPER_CLASS radio_driver(radio, board);
@@ -32,21 +32,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -23,7 +23,4 @@ extern SensorManager sensors;
#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();
-29
View File
@@ -17,8 +17,6 @@
#define PIN_ADC_CTRL_ACTIVE LOW
#define PIN_ADC_CTRL_INACTIVE HIGH
#include <driver/rtc_io.h>
class HeltecV3Board : public ESP32Board {
private:
bool adc_active_state;
@@ -52,33 +50,6 @@ public:
}
}
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
if (pin_wake_btn < 0) {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
} else {
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
}
if (secs > 0) {
esp_sleep_enable_timer_wakeup(secs * 1000000);
}
// Finally set ESP32 into sleep
esp_deep_sleep_start(); // CPU halts here and never returns!
}
void powerOff() override {
enterDeepSleep(0);
}
uint16_t getBattMilliVolts() override {
analogReadResolution(10);
digitalWrite(PIN_ADC_CTRL, adc_active_state);
+6 -4
View File
@@ -144,6 +144,7 @@ build_flags =
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=SSD1306Display
-D ENABLE_USB_INTERFACE
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v3.build_src_filter}
@@ -184,6 +185,7 @@ extends = Heltec_lora32_v3
build_flags =
${Heltec_lora32_v3.build_flags}
-I examples/companion_radio/ui-new
-D ENABLE_WIFI_INTERFACE
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=SSD1306Display
@@ -197,6 +199,7 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
@@ -326,6 +329,7 @@ build_flags =
${Heltec_lora32_v3.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v3.build_src_filter}
@@ -338,6 +342,7 @@ lib_deps =
extends = Heltec_lora32_v3
build_flags =
${Heltec_lora32_v3.build_flags}
-D ENABLE_WIFI_INTERFACE
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D WIFI_DEBUG_LOGGING=1
@@ -348,6 +353,7 @@ build_flags =
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v3.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
lib_deps =
${Heltec_lora32_v3.lib_deps}
@@ -371,9 +377,5 @@ 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}
-15
View File
@@ -39,21 +39,6 @@ bool radio_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(int8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
-3
View File
@@ -24,7 +24,4 @@ extern EnvironmentSensorManager sensors;
#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();

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