Merge branch 'dev' into feature/lilygo-t3-stm32

This commit is contained in:
fdlamotte authored and GitHub committed 2026-11-10 08:22:52 -04:00
commit f40e13a425
178 files changed
+5207 -1141

No files matched your search

+4 -3
View File
@@ -26,9 +26,10 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#include <helpers/sensors/RakLocationProvider.h>
RakI2cGpsDriver gps_driver;
RakLocationProvider location(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors(location);
#else
EnvironmentSensorManager sensors;
#endif
+2 -1
View File
@@ -26,7 +26,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
+2 -1
View File
@@ -27,7 +27,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
+6 -11
View File
@@ -11,7 +11,8 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
SolarSensorManager sensors = SolarSensorManager(nmea);
SolarExternalWatchdog external_watchdog;
@@ -30,17 +31,11 @@ mesh::LocalIdentity radio_new_identity() {
}
void SolarSensorManager::start_gps() {
if (!gps_active) {
gps_active = true;
_location->begin();
}
_location->setGpsOn(true);
}
void SolarSensorManager::stop_gps() {
if (gps_active) {
gps_active = false;
_location->stop();
}
_location->setGpsOn(false);
}
bool SolarSensorManager::begin() {
@@ -71,7 +66,7 @@ void SolarSensorManager::loop() {
_location->loop();
if (millis() > next_gps_update) {
if (_location->isValid()) {
if (_location->isGpsOn() && _location->hasValidFix()) {
node_lat = ((double)_location->getLatitude())/1000000.;
node_lon = ((double)_location->getLongitude())/1000000.;
node_altitude = ((double)_location->getAltitude()) / 1000.0;
@@ -91,7 +86,7 @@ const char* SolarSensorManager::getSettingName(int i) const {
const char* SolarSensorManager::getSettingValue(int i) const {
if (gps_detected && i == 0) {
return gps_active ? "1" : "0";
return _location->isGpsOn() ? "1" : "0";
}
return NULL;
}
-1
View File
@@ -14,7 +14,6 @@
#endif
class SolarSensorManager : public SensorManager {
bool gps_active = false;
bool gps_detected = false;
LocationProvider* _location;
+3 -1
View File
@@ -20,7 +20,9 @@ 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);
NmeaGpsDriver gps_driver(Serial1, PIN_GPS_TX, PIN_GPS_RX, PIN_GPS_RESET,
PIN_GPS_EN);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
+2 -2
View File
@@ -158,14 +158,14 @@ bool T096Board::handleCommand(const char* command, uint32_t sender_timestamp, ch
strcpy(reply, "Error: unsupported");
} else if (memcmp(&command[21], "on", 2) == 0) {
if (setLoRaFemLnaEnabled(true)) {
_prefs->setByKey("fem_rxgain", "1");
if (_prefs) _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");
if (_prefs) _prefs->setByKey("fem_rxgain", "0");
strcpy(reply, "OK - LoRa FEM RX gain off");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
+3 -1
View File
@@ -22,7 +22,9 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, GPS_RESET, GPS_EN, &board.periph_power);
NmeaGpsDriver gps_driver(Serial1, PIN_GPS_TX, PIN_GPS_RX, GPS_RESET, GPS_EN,
&board.periph_power);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
+3 -1
View File
@@ -21,7 +21,9 @@ 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);
NmeaGpsDriver gps_driver(Serial1, PIN_GPS_TX, PIN_GPS_RX, GPS_RESET, GPS_EN,
&board.periph_power);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
+2 -1
View File
@@ -22,7 +22,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
+2 -1
View File
@@ -12,7 +12,8 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
TowerV2ExternalWatchdog external_watchdog;
+2 -2
View File
@@ -31,8 +31,8 @@ build_flags =
-D USE_PIN_TFT=1
-D PIN_VEXT_EN=3 ; Vext is connected to VDD which is also connected to OLED & GPS
-D PIN_TFT_LEDA_CTL=21 ; LEDK (switches on/off via mosfet to create the ground)
-D PIN_GPS_RX=33
-D PIN_GPS_TX=34
-D PIN_GPS_TX=33 ; GPS module TX -> MCU RX (GPIO33)
-D PIN_GPS_RX=34 ; GPS module RX <- MCU TX (GPIO34)
-D PIN_GPS_EN=35 ; N-ch MOSFET Q2 drives P-ch high-side switch → active HIGH (default)
-D PIN_GPS_RESET=36
-D PIN_GPS_RESET_ACTIVE=LOW
+24 -14
View File
@@ -17,7 +17,25 @@ WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
// GPS_EN (GPIO35) drives N-ch MOSFET → P-ch high-side switch; GPS_RESET (GPIO36) active LOW
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, GPS_RESET, GPS_EN, &board.periph_power);
class HeltecTrackerGpsDriver : public NmeaGpsDriver {
public:
HeltecTrackerGpsDriver()
: NmeaGpsDriver(Serial1, PIN_GPS_TX, PIN_GPS_RX, GPS_RESET, GPS_EN,
&board.periph_power) {}
void reset() override {
NmeaGpsDriver::reset();
// Send configuration after reset
if (isActive()) {
delay(250);
sendNmeaSentence("$CFGSYS,h35155*68");
// TODO: remove active wait (250ms is a lot)
}
}
};
HeltecTrackerGpsDriver gps_driver;
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
HWTSensorManager sensors = HWTSensorManager(nmea);
#ifdef DISPLAY_CLASS
@@ -43,23 +61,15 @@ mesh::LocalIdentity radio_new_identity() {
}
void HWTSensorManager::start_gps() {
if (!gps_active) {
_location->begin(); // Claims periph_power via RefCountedDigitalPin
gps_active = true;
Serial1.println("$CFGSYS,h35155*68"); // Configure GPS for all constellations
}
_location->setGpsOn(true);
}
void HWTSensorManager::stop_gps() {
if (gps_active) {
gps_active = false;
_location->stop(); // Releases periph_power via RefCountedDigitalPin
}
_location->setGpsOn(false);
}
bool HWTSensorManager::begin() {
// init GPS port
Serial1.begin(115200, SERIAL_8N1, PIN_GPS_RX, PIN_GPS_TX);
// the GPS UART (pins, baud rate) is now configured by gps_driver when the GPS is started
return true;
}
@@ -76,7 +86,7 @@ void HWTSensorManager::loop() {
_location->loop();
if (millis() > next_gps_update) {
if (gps_active && _location->isValid()) {
if (_location->isGpsOn() && _location->hasValidFix()) {
node_lat = ((double)_location->getLatitude())/1000000.;
node_lon = ((double)_location->getLongitude())/1000000.;
node_altitude = ((double)_location->getAltitude()) / 1000.0;
@@ -93,7 +103,7 @@ const char* HWTSensorManager::getSettingName(int i) const {
}
const char* HWTSensorManager::getSettingValue(int i) const {
if (i == 0) {
return gps_active ? "1" : "0";
return _location->isGpsOn() ? "1" : "0";
}
return NULL;
}
-1
View File
@@ -14,7 +14,6 @@
#endif
class HWTSensorManager : public SensorManager {
bool gps_active = false;
LocationProvider * _location;
void start_gps();
@@ -99,14 +99,14 @@ bool HeltecTrackerV2Board::handleCommand(const char* command, uint32_t sender_ti
strcpy(reply, "Error: unsupported");
} else if (memcmp(&command[21], "on", 2) == 0) {
if (setLoRaFemLnaEnabled(true)) {
_prefs->setByKey("fem_rxgain", "1");
if (_prefs) _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");
if (_prefs) _prefs->setByKey("fem_rxgain", "0");
strcpy(reply, "OK - LoRa FEM RX gain off");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
+3 -2
View File
@@ -17,7 +17,9 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, GPS_RESET, GPS_EN, &board.periph_power);
NmeaGpsDriver gps_driver(Serial1, PIN_GPS_TX, PIN_GPS_RX, GPS_RESET, GPS_EN,
&board.periph_power);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -43,4 +45,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -2
View File
@@ -17,7 +17,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -43,4 +44,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -2
View File
@@ -100,14 +100,14 @@ bool HeltecV4Board::handleCommand(const char* command, uint32_t sender_timestamp
strcpy(reply, "Error: unsupported");
} else if (memcmp(&command[21], "on", 2) == 0) {
if (setLoRaFemLnaEnabled(true)) {
_prefs->setByKey("fem_rxgain", "1");
if (_prefs) _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");
if (_prefs) _prefs->setByKey("fem_rxgain", "0");
strcpy(reply, "OK - LoRa FEM RX gain off");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
+2
View File
@@ -380,12 +380,14 @@ build_flags =
-D AUTO_SHUTDOWN_MILLIVOLTS=3400
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
-D ENABLE_WIFI_INTERFACE
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${heltec_v4_tft.build_src_filter}
+<helpers/ui/ST7789LCDDisplay.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
+2 -2
View File
@@ -17,7 +17,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -43,4 +44,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -2
View File
@@ -122,14 +122,14 @@ bool HeltecV4R8Board::handleCommand(const char* command, uint32_t sender_timesta
strcpy(reply, "Error: unsupported");
} else if (memcmp(&command[21], "on", 2) == 0) {
if (setLoRaFemLnaEnabled(true)) {
_prefs->setByKey("fem_rxgain", "1");
if (_prefs) _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");
if (_prefs) _prefs->setByKey("fem_rxgain", "0");
strcpy(reply, "OK - LoRa FEM RX gain off");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
+3 -1
View File
@@ -17,7 +17,9 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, GPS_RESET, GPS_EN, &board.periph_power);
NmeaGpsDriver gps_driver(Serial1, PIN_GPS_TX, PIN_GPS_RX, GPS_RESET, GPS_EN,
&board.periph_power);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
+2 -2
View File
@@ -12,7 +12,8 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -34,4 +35,3 @@ mesh::LocalIdentity radio_new_identity() {
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -2
View File
@@ -13,7 +13,8 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -34,4 +35,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -2
View File
@@ -19,7 +19,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -47,4 +48,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng);
}
+2 -2
View File
@@ -17,7 +17,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -38,4 +39,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -1
View File
@@ -17,7 +17,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -131,11 +131,13 @@ build_flags =
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
-D ENABLE_WIFI_INTERFACE
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=8
; -D MESH_DEBUG=1
build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/wifi/*.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
@@ -19,7 +19,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -35,4 +36,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -1
View File
@@ -14,7 +14,8 @@ WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider gps(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider gps(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors(gps);
#ifdef DISPLAY_CLASS
+9 -3
View File
@@ -32,8 +32,16 @@ build_flags = ${nrf52_base.build_flags}
-D PIN_GPS_RESET_ACTIVE=LOW
-D TELEM_BME280_ADDRESS=0x77
-D DISPLAY_CLASS=GxEPDDisplay
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
-D EINK_SCALE_X=1.5625f
-D EINK_SCALE_Y=1.5625f
-D EINK_X_OFFSET=0
-D EINK_Y_OFFSET=10
-D EINK_SCREENOFF_BLANK
-D UI_RECENT_LIST_SIZE=9
-D UI_MSG_PREVIEW_SIZE=165
-D AUTO_OFF_MILLIS=300000
-D BACKLIGHT_BTN=PIN_BUTTON2
-D AUTO_OFF_MILLIS=0
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<TechoBoard.cpp>
@@ -91,7 +99,6 @@ build_flags =
-D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
-D UI_RECENT_LIST_SIZE=9
-D UI_SENSORS_PAGE=1
-D UI_GPS_PAGE=1
; -D MESH_PACKET_LOGGING=1
@@ -116,7 +123,6 @@ build_flags =
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
-D UI_RECENT_LIST_SIZE=9
-D UI_SENSORS_PAGE=1
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
-D QSPIFLASH=1
+3 -3
View File
@@ -13,7 +13,8 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -23,6 +24,7 @@ EnvironmentSensorManager sensors = EnvironmentSensorManager();
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
MomentaryButton backlight_btn(BACKLIGHT_BTN, 1000, true);
#endif
bool radio_init() {
@@ -35,5 +37,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+1
View File
@@ -22,6 +22,7 @@ extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern MomentaryButton backlight_btn;
#endif
bool radio_init();
+6
View File
@@ -131,6 +131,12 @@ extern const int SCK;
#define DISP_BUSY (3)
#define DISP_BACKLIGHT (43)
// used by GxEPDDisplay when EINK_DISPLAY_MODEL is set
#define PIN_DISPLAY_CS DISP_CS
#define PIN_DISPLAY_DC DISP_DC
#define PIN_DISPLAY_RST DISP_RST
#define PIN_DISPLAY_BUSY DISP_BUSY
////////////////////////////////////////////////////////////////////////////////
// GPS
+2 -1
View File
@@ -13,7 +13,8 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
+2 -2
View File
@@ -13,7 +13,8 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -35,4 +36,3 @@ mesh::LocalIdentity radio_new_identity() {
return mesh::LocalIdentity(&rng); // create new random identity
}
+4
View File
@@ -110,5 +110,9 @@ lib_deps =
[env:M5Stack_Unit_C6L_kiss_modem]
extends = M5Stack_Unit_C6L
build_flags = ${M5Stack_Unit_C6L.build_flags}
-D ARDUINO_USB_CDC_ON_BOOT=1
-D ARDUINO_USB_MODE=1
-D ENABLE_USB_INTERFACE
build_src_filter = ${M5Stack_Unit_C6L.build_src_filter}
+<../examples/kiss_modem/>
+2 -2
View File
@@ -23,8 +23,8 @@ build_flags =
-D SX126X_DIO2_AS_RF_SWITCH=false
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_RX_BOOSTED_GAIN=1
-D PIN_GPS_RX=12
-D PIN_GPS_TX=15
-D PIN_GPS_TX=12 ; GPS module TX -> MCU RX (GPIO12)
-D PIN_GPS_RX=15 ; GPS module RX <- MCU TX (GPIO15)
-D DISPLAY_CLASS=SSD1306Display
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/meshadventurer>
+10 -15
View File
@@ -11,7 +11,8 @@ WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
MASensorManager sensors = MASensorManager(nmea);
#ifdef DISPLAY_CLASS
@@ -37,23 +38,17 @@ mesh::LocalIdentity radio_new_identity() {
void MASensorManager::start_gps() {
if(!gps_active) {
MESH_DEBUG_PRINTLN("starting GPS");
gps_active = true;
}
MESH_DEBUG_PRINTLN("starting GPS");
_location->setGpsOn(true);
}
void MASensorManager::stop_gps() {
if(gps_active) {
MESH_DEBUG_PRINTLN("stopping GPS");
gps_active = false;
}
MESH_DEBUG_PRINTLN("stopping GPS");
_location->setGpsOn(false);
}
bool MASensorManager::begin() {
Serial1.setPins(PIN_GPS_RX, PIN_GPS_TX);
Serial1.begin(9600);
delay(500);
// the GPS UART (pins, baud rate) is now configured by gps_driver when the GPS is started
return true;
}
@@ -67,8 +62,8 @@ bool MASensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& te
void MASensorManager::loop() {
static long next_gps_update = 0;
_location->loop();
if(millis() > next_gps_update && gps_active) {
if(_location->isValid()) {
if(millis() > next_gps_update && _location->isGpsOn()) {
if(_location->hasValidFix()) {
node_lat = ((double)_location->getLatitude()) / 1000000.;
node_lon = ((double)_location->getLongitude()) / 1000000.;
node_altitude = ((double)_location->getAltitude()) / 1000.0;
@@ -85,7 +80,7 @@ const char* MASensorManager::getSettingName(int i) const {
}
const char* MASensorManager::getSettingValue(int i) const {
if(i == 0) {
return gps_active ? "1" : "0";
return _location->isGpsOn() ? "1" : "0";
}
return NULL;
}
+1 -2
View File
@@ -15,8 +15,7 @@
#endif
class MASensorManager : public SensorManager {
bool gps_active = false;
LocationProvider * _location;
LocationProvider* _location;
void start_gps();
void stop_gps();
+2 -2
View File
@@ -17,7 +17,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -70,4 +71,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
@@ -5,7 +5,6 @@
void MeshTrackerX1Board::begin() {
NRF52BoardDCDC::begin();
btn_prev_state = LOW; // button is active HIGH
#ifdef BUTTON_PIN
pinMode(BATTERY_PIN, INPUT);
@@ -5,9 +5,6 @@
#include <helpers/NRF52Board.h>
class MeshTrackerX1Board : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
MeshTrackerX1Board() : NRF52Board("X1_OTA") {}
void begin();
@@ -35,17 +32,6 @@ public:
return "Seeed SenseCAP MeshTracker X1";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == USER_BTN_PRESSED) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
#ifdef HAS_GPS
digitalWrite(GPS_VRTC_EN, LOW);
+1 -4
View File
@@ -34,6 +34,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/meshtracker_x1>
lib_deps = ${nrf52_base.lib_deps}
https://github.com/adafruit/Adafruit_SPA06_003/archive/refs/tags/1.0.2.zip
stevemarple/MicroNMEA @ ^2.0.6
debug_tool = jlink
upload_protocol = nrfutil
@@ -51,7 +52,6 @@ build_flags = ${MeshTracker_X1.build_flags}
build_src_filter = ${MeshTracker_X1.build_src_filter}
+<../examples/simple_repeater>
lib_deps = ${MeshTracker_X1.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
[env:MeshTracker_X1_room_server]
extends = MeshTracker_X1
@@ -67,7 +67,6 @@ build_flags = ${MeshTracker_X1.build_flags}
build_src_filter = ${MeshTracker_X1.build_src_filter}
+<../examples/simple_room_server>
lib_deps = ${MeshTracker_X1.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
[env:MeshTracker_X1_companion_radio_usb]
extends = MeshTracker_X1
@@ -94,7 +93,6 @@ build_src_filter = ${MeshTracker_X1.build_src_filter}
+<../examples/companion_radio/ui-orig/*.cpp>
lib_deps = ${MeshTracker_X1.lib_deps}
densaugeo/base64 @ ~1.4.0
stevemarple/MicroNMEA @ ^2.0.6
end2endzone/NonBlockingRTTTL@^1.3.0
adafruit/Adafruit DRV2605 Library @ ^1.2.4
@@ -127,7 +125,6 @@ build_src_filter = ${MeshTracker_X1.build_src_filter}
+<../examples/companion_radio/ui-orig/*.cpp>
lib_deps = ${MeshTracker_X1.lib_deps}
densaugeo/base64 @ ~1.4.0
stevemarple/MicroNMEA @ ^2.0.6
end2endzone/NonBlockingRTTTL@^1.3.0
adafruit/Adafruit DRV2605 Library @ ^1.2.4
+8 -19
View File
@@ -1,7 +1,7 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/sensors/AirohaGpsDriver.h>
#include <helpers/sensors/MicroNMEALocationProvider.h>
#include <helpers/sensors/AirohaSleep.h>
MeshTrackerX1Board board;
@@ -10,7 +10,8 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock rtc_clock;
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
AirohaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
MeshTrackerX1SensorManager sensors = MeshTrackerX1SensorManager(nmea);
#ifdef DISPLAY_CLASS
@@ -27,28 +28,16 @@ mesh::LocalIdentity radio_new_identity() {
}
void MeshTrackerX1SensorManager::start_gps() {
gps_active = true;
digitalWrite(GPS_EN, HIGH);
delay(10);
digitalWrite(GPS_RTC_INT, HIGH);
delay(5);
digitalWrite(GPS_RTC_INT, LOW);
_nmea->setGpsOn(true);
}
void MeshTrackerX1SensorManager::stop_gps() {
gps_active = false;
digitalWrite(GPS_VRTC_EN, HIGH); // keep GPS RTC alive for faster fix on wake
digitalWrite(GPS_RTC_INT, LOW); // make sure this is LOW so we can pulse it to wake
airohaEnterSleep(_nmea);
digitalWrite(GPS_EN, LOW);
_nmea->setGpsOn(false);
}
bool MeshTrackerX1SensorManager::begin() {
// init GPS
Serial1.begin(GPS_BAUD_RATE);
digitalWrite(GPS_RESET, HIGH);
delay(10);
digitalWrite(GPS_RESET, LOW);
gps_driver.initialize();
// init SPA06-003 barometer
baro_ok = spa06.begin(SPA06_003_DEFAULT_ADDR, &Wire) || spa06.begin(0x76, &Wire);
@@ -81,7 +70,7 @@ void MeshTrackerX1SensorManager::loop() {
_nmea->loop();
if (millis() > next_gps_update) {
if (gps_active && _nmea->isValid()) {
if (_nmea->isGpsOn() && _nmea->hasValidFix()) {
node_lat = ((double)_nmea->getLatitude())/1000000.;
node_lon = ((double)_nmea->getLongitude())/1000000.;
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
@@ -97,7 +86,7 @@ const char* MeshTrackerX1SensorManager::getSettingName(int i) const {
}
const char* MeshTrackerX1SensorManager::getSettingValue(int i) const {
if (i == 0) {
return gps_active ? "1" : "0";
return _nmea->isGpsOn() ? "1" : "0";
}
return NULL;
}
-2
View File
@@ -14,13 +14,11 @@
#endif
class MeshTrackerX1SensorManager: public SensorManager {
bool gps_active = false;
bool baro_ok = false;
Adafruit_SPA06_003 spa06;
LocationProvider * _nmea;
void start_gps();
void sleep_gps();
void stop_gps();
public:
MeshTrackerX1SensorManager(LocationProvider &nmea): _nmea(&nmea) { }
+2 -1
View File
@@ -10,7 +10,8 @@ VolatileRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
+12 -16
View File
@@ -13,7 +13,8 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
MuziBaseSensorManager sensors = MuziBaseSensorManager(nmea);
#else
MuziBaseSensorManager sensors;
@@ -38,13 +39,7 @@ static void muziPowerOff() {
bool MuziBaseSensorManager::begin() {
pwr_btn.begin();
bool ok = EnvironmentSensorManager::begin();
#if ENV_INCLUDE_GPS
pinMode(PIN_GPS_SWITCH, INPUT);
_last_gps_sw = digitalRead(PIN_GPS_SWITCH); // initial gps state from the switch
if (_last_gps_sw == HIGH) start_gps(); else stop_gps();
#endif
return ok;
return EnvironmentSensorManager::begin();
}
void MuziBaseSensorManager::loop() {
@@ -56,14 +51,15 @@ void MuziBaseSensorManager::loop() {
if (++_pwr_clicks >= USER_BTN_POWER_OFF_CLICKS) muziPowerOff();
}
#if ENV_INCLUDE_GPS
unsigned long now = millis();
if (now > _next_sw_check) { // check the mode switch ~once a sec
_next_sw_check = now + 1000;
int sw = digitalRead(PIN_GPS_SWITCH);
if (sw != _last_gps_sw) {
_last_gps_sw = sw;
if (sw == HIGH) start_gps(); else stop_gps();
}
// the ATGM336H keeps its nmea output config across power cycles (backup
// supply), and other firmware may have turned every sentence off. re-enable
// GGA + RMC after each power-up, once the module has booted.
bool gps_on = _location->isActive();
if (gps_on && !_gps_was_active) _gps_cfg_at = millis() + 1000;
_gps_was_active = gps_on;
if (_gps_cfg_at && gps_on && (long)(millis() - _gps_cfg_at) > 0) {
_gps_cfg_at = 0;
_location->sendSentence("$PCAS03,1,0,0,0,1,0,0,0,0,0,,,0,0");
}
#endif
EnvironmentSensorManager::loop();
+3 -3
View File
@@ -38,13 +38,13 @@ extern AutoDiscoverRTCClock rtc_clock;
// muzi sensor manager, polled from main loop via sensors.loop():
// - user button: USER_BTN_POWER_OFF_CLICKS quick presses -> power off (all builds)
// - gps mode switch on/off (superIO only, see thinknode_m1)
// gps mode is now handled by GpsDriver on superIO
class MuziBaseSensorManager : public EnvironmentSensorManager {
unsigned long _pwr_last_click = 0;
uint8_t _pwr_clicks = 0;
#if ENV_INCLUDE_GPS
int _last_gps_sw = -1;
unsigned long _next_sw_check = 0;
unsigned long _gps_cfg_at = 0;
bool _gps_was_active = false;
#endif
public:
#if ENV_INCLUDE_GPS
+6 -4
View File
@@ -54,8 +54,8 @@ static const uint8_t AREF = (PIN_AREF); // not used
////////////////////////////////////////////////////////////////////////////////
// UART pin definition
#define PIN_SERIAL1_RX (19) // P0.19 used for GPS RX
#define PIN_SERIAL1_TX (20) // P0.20 used for GPS TX
#define PIN_SERIAL1_RX (20) // P0.20, data from the gps
#define PIN_SERIAL1_TX (19) // P0.19, data to the gps
////////////////////////////////////////////////////////////////////////////////
// I2C pin definition
@@ -153,8 +153,8 @@ static const uint8_t AREF = (PIN_AREF); // not used
////////////////////////////////////////////////////////////////////////////////
// GPS
#define HAS_GPS 1
#define PIN_GPS_RX PIN_SERIAL1_RX
#define PIN_GPS_TX PIN_SERIAL1_TX
#define PIN_GPS_TX PIN_SERIAL1_RX // gps module's TX pin
#define PIN_GPS_RX PIN_SERIAL1_TX // gps module's RX pin
#define PIN_GPS_EN (32+1) // P1.01 PWR_IO2 on schematic. gps power, driven by the sensor manager.
// superIO 3-position mode switch (pins from the meshtastic muzi_base variant).
@@ -162,6 +162,8 @@ static const uint8_t AREF = (PIN_AREF); // not used
#define SWITCH_MODE1 (32+9) // P1.09
#define SWITCH_MODE2 (12) // P0.12
#define PIN_GPS_SWITCH SWITCH_MODE2
#define GPS_SWITCH_IS_HARDWARE (0)
#define GPS_SWITCH_TURNS_GPS_ON (1)
////////////////////////////////////////////////////////////////////////////////
// Buzzer
+2 -1
View File
@@ -20,7 +20,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -0,0 +1,31 @@
#pragma once
#include <helpers/sensors/NmeaGpsDriver.h>
class NanoG2UltraGpsDriver : public NmeaGpsDriver {
public:
NanoG2UltraGpsDriver(UART_TYPE& serial) : NmeaGpsDriver(serial) {
pinMode(PIN_GPS_STANDBY, OUTPUT);
digitalWrite(PIN_GPS_STANDBY, LOW);
}
void begin() override {
if (isActive()) return;
digitalWrite(PIN_GPS_STANDBY, HIGH);
NmeaGpsDriver::begin();
delay(1000);
}
void stop() override {
NmeaGpsDriver::stop();
digitalWrite(PIN_GPS_STANDBY, LOW);
}
bool detectAtBoot() {
begin();
const bool wasActive = detect(0);
if (!wasActive) stop();
return wasActive;
}
};
+11 -24
View File
@@ -3,6 +3,7 @@
#include <Arduino.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/MicroNMEALocationProvider.h>
#include "NanoG2UltraGpsDriver.h"
NanoG2Ultra board;
@@ -12,8 +13,10 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NanoG2UltraSensorManager sensors = NanoG2UltraSensorManager(nmea);
// NanoG2UltraGpsDriver now handles the special init needed for NanoG2
NanoG2UltraGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
NanoG2UltraSensorManager sensors = NanoG2UltraSensorManager(nmea, gps_driver);
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
@@ -27,35 +30,19 @@ bool radio_init() {
void NanoG2UltraSensorManager::start_gps() {
MESH_DEBUG_PRINTLN("Starting GPS");
if (!gps_active) {
digitalWrite(PIN_GPS_STANDBY, HIGH); // Wake GPS from standby
Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX);
Serial1.begin(9600);
MESH_DEBUG_PRINTLN("Waiting for gps to power up");
delay(1000);
gps_active = true;
}
_location->begin();
_location->setGpsOn(true);
}
void NanoG2UltraSensorManager::stop_gps() {
MESH_DEBUG_PRINTLN("Stopping GPS");
if (gps_active) {
digitalWrite(PIN_GPS_STANDBY, LOW); // sleep GPS
gps_active = false;
}
_location->stop();
_location->setGpsOn(false);
}
bool NanoG2UltraSensorManager::begin() {
digitalWrite(PIN_GPS_STANDBY, HIGH); // Wake GPS from standby
Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX);
Serial1.begin(9600);
MESH_DEBUG_PRINTLN("Checking GPS switch state");
delay(1000);
// Check initial switch state to determine if GPS should be active
if (Serial1.available() > 0) {
if (_gps_driver->detectAtBoot()) {
MESH_DEBUG_PRINTLN("GPS was on at boot, GPS enabled");
start_gps();
} else {
@@ -75,14 +62,14 @@ bool NanoG2UltraSensorManager::querySensors(uint8_t requester_permissions, Cayen
void NanoG2UltraSensorManager::loop() {
static long next_gps_update = 0;
if (!gps_active) {
if (!_location->isGpsOn()) {
return; // GPS is not active, skip further processing
}
_location->loop();
if (millis() > next_gps_update) {
if (_location->isValid()) {
if (_location->isGpsOn() && _location->hasValidFix()) {
node_lat = ((double)_location->getLatitude()) / 1000000.;
node_lon = ((double)_location->getLongitude()) / 1000000.;
node_altitude = ((double)_location->getAltitude()) / 1000.0;
@@ -105,7 +92,7 @@ const char *NanoG2UltraSensorManager::getSettingName(int i) const {
const char *NanoG2UltraSensorManager::getSettingValue(int i) const {
if (i == 0) {
return gps_active ? "1" : "0";
return _location->isGpsOn() ? "1" : "0";
}
return NULL;
}
+5 -3
View File
@@ -14,15 +14,18 @@
#endif
#include <helpers/sensors/LocationProvider.h>
class NanoG2UltraGpsDriver;
class NanoG2UltraSensorManager : public SensorManager {
bool gps_active = false;
LocationProvider *_location;
NanoG2UltraGpsDriver *_gps_driver;
void start_gps();
void stop_gps();
public:
NanoG2UltraSensorManager(LocationProvider &location) : _location(&location) {}
NanoG2UltraSensorManager(LocationProvider &location, NanoG2UltraGpsDriver &gps_driver)
: _location(&location), _gps_driver(&gps_driver) {}
bool begin() override;
bool querySensors(uint8_t requester_permissions, CayenneLPP &telemetry) override;
void loop() override;
@@ -44,4 +47,3 @@ extern MomentaryButton user_btn;
bool radio_init();
mesh::LocalIdentity radio_new_identity();
+57
View File
@@ -0,0 +1,57 @@
[nucleo_wl55jc]
extends = stm32_base
board = nucleo_wl55jc
; The upstream board manifest tags the part as STM32WLE5xx even though its
; product_line is STM32WL55xx. Pin both to WL55 so a single device header and
; startup file (startup_stm32wl55xx_cm4.s) are in play.
board_build.extra_flags = -DSTM32WL -DSTM32WLxx -DSTM32WL55xx
board_upload.maximum_size = 229376 ; 32kb at the top of flash reserved for LittleFS
build_flags = ${stm32_base.build_flags}
-D RADIO_CLASS=CustomSTM32WLx
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
-D LORA_TX_POWER=22
-D SPI_INTERFACES_COUNT=0
-D RX_BOOSTED_GAIN=true
-D STM32WL_TCXO_VOLTAGE=1.7
-D P_LORA_TX_LED=LED_BLUE
-D PIN_USER_BTN=USER_BTN
-D USER_BTN_PRESSED=LOW
-I variants/nucleo_wl55jc
build_src_filter = ${stm32_base.build_src_filter}
+<../variants/nucleo_wl55jc>
[env:nucleo_wl55jc_repeater]
extends = nucleo_wl55jc
build_flags = ${nucleo_wl55jc.build_flags}
-D ADVERT_NAME='"Nucleo WL55JC Repeater"'
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
build_src_filter = ${nucleo_wl55jc.build_src_filter}
+<../examples/simple_repeater/*.cpp>
[env:nucleo_wl55jc_companion_radio_usb]
extends = nucleo_wl55jc
build_flags = ${nucleo_wl55jc.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D ENABLE_USB_INTERFACE ; binds to Serial, i.e. the ST-LINK virtual COM port
build_src_filter = ${nucleo_wl55jc.build_src_filter}
+<../examples/companion_radio/*.cpp>
lib_deps = ${nucleo_wl55jc.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:nucleo_wl55jc_kiss_modem]
extends = nucleo_wl55jc
build_src_filter = ${nucleo_wl55jc.build_src_filter}
+<../examples/kiss_modem/>
[env:nucleo_wl55jc_room_server]
extends = nucleo_wl55jc
build_flags = ${nucleo_wl55jc.build_flags}
-D ADVERT_NAME='"Nucleo WL55JC Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
build_src_filter = ${nucleo_wl55jc.build_src_filter}
+<../examples/simple_room_server>
+65
View File
@@ -0,0 +1,65 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/ArduinoHelpers.h>
NucleoWL55JCBoard board;
RADIO_CLASS radio = new STM32WLx_Module();
WRAPPER_CLASS radio_driver(radio, board);
// The NUCLEO-WL55JC1 drives an SP3T front-end switch from FE_CTRL1..3 (PC4, PC5, PC3),
// routing the single SMA between RX, RFO_LP and RFO_HP. Pin order and levels are taken
// straight from the core's board definition (variant_NUCLEO_WL55JC1.h) so they stay in
// sync with upstream.
static const uint32_t rfswitch_pins[] = {LORAWAN_RFSWITCH_PINS, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
{STM32WLx::MODE_IDLE, {LORAWAN_RFSWITCH_OFF_VALUES}},
{STM32WLx::MODE_RX, {LORAWAN_RFSWITCH_RX_VALUES}},
{STM32WLx::MODE_TX_LP, {LORAWAN_RFSWITCH_RFO_LP_VALUES}},
{STM32WLx::MODE_TX_HP, {LORAWAN_RFSWITCH_RFO_HP_VALUES}},
END_OF_MODE_TABLE,
};
VolatileRTCClock rtc_clock;
SensorManager sensors;
#ifndef LORA_CR
#define LORA_CR 5
#endif
#ifndef STM32WL_TCXO_VOLTAGE
// The board is fitted with a 32MHz TCXO powered from the radio's DIO3 at 1.7V
#define STM32WL_TCXO_VOLTAGE 1.7
#endif
#ifndef LORA_TX_POWER
#define LORA_TX_POWER 22
#endif
bool radio_init() {
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
// Both PA paths are registered above, so RadioLib picks RFO_HP whenever the
// requested power is above 14dBm, and RFO_LP below that.
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, STM32WL_TCXO_VOLTAGE, 0);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
#ifdef RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
#endif
radio.setCRC(1);
return true; // success
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+47
View File
@@ -0,0 +1,47 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/stm32/STM32Board.h>
#include <helpers/radiolib/CustomSTM32WLxWrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/SensorManager.h>
class NucleoWL55JCBoard : public STM32Board {
public:
void begin() override {
STM32Board::begin();
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(P_LORA_TX_LED, LOW); // see note on LED polarity below
pinMode(PIN_USER_BTN, INPUT_PULLUP);
}
const char* getManufacturerName() const override {
return "ST Nucleo WL55JC1";
}
// LD1..LD3 on the Nucleo are driven active HIGH, whereas STM32Board's
// default TX-LED handling assumes the active LOW wiring used by the
// Wio-E5 boards. Invert both halves here.
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
// No battery on this dev board, it is USB/ST-LINK powered.
uint16_t getBattMilliVolts() override {
return 0;
}
};
extern NucleoWL55JCBoard board;
extern WRAPPER_CLASS radio_driver;
extern VolatileRTCClock rtc_clock;
extern SensorManager sensors;
bool radio_init();
mesh::LocalIdentity radio_new_identity();
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include <variant_NUCLEO_WL55JC1.h>
#undef RNG
-1
View File
@@ -5,7 +5,6 @@
void PromicroBoard::begin() {
NRF52Board::begin();
btn_prev_state = HIGH;
pinMode(PIN_VBAT_READ, INPUT);
-12
View File
@@ -9,7 +9,6 @@
class PromicroBoard : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
float adc_mult = ADC_MULTIPLIER;
public:
@@ -48,15 +47,4 @@ public:
const char* getManufacturerName() const override {
return "ProMicro DIY";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
};
+7 -2
View File
@@ -12,7 +12,13 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
#ifdef GPS_BAUD_PROBE_LIST // e.g. -D GPS_BAUD_PROBE_LIST=9600,38400,115200
static const uint32_t gps_probe_bauds[] = { GPS_BAUD_PROBE_LIST };
NmeaGpsDriver gps_driver(Serial1, gps_probe_bauds, sizeof(gps_probe_bauds) / sizeof(gps_probe_bauds[0]));
#else
NmeaGpsDriver gps_driver(Serial1);
#endif
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -34,4 +40,3 @@ mesh::LocalIdentity radio_new_identity() {
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -2
View File
@@ -17,7 +17,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -43,4 +44,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+4 -4
View File
@@ -25,9 +25,10 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#include <helpers/sensors/RakLocationProvider.h>
RakI2cGpsDriver gps_driver;
RakLocationProvider location(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors(location);
#else
EnvironmentSensorManager sensors;
#endif
@@ -41,4 +42,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+21 -10
View File
@@ -28,11 +28,14 @@ build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/rak4631>
+<helpers/sensors>
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/SH1106Display.cpp>
+<helpers/ui/AutoDetectDisplay.cpp>
+<helpers/ui/MomentaryButton.cpp>
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13
adafruit/Adafruit SH110X @ ^2.1.13
sparkfun/SparkFun u-blox GNSS Arduino Library@^2.2.27
boschsensortec/BSEC Software Library @ ^1.8.1492
@@ -40,7 +43,7 @@ lib_deps =
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D ADVERT_NAME='"RAK4631 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -52,11 +55,19 @@ build_src_filter = ${rak4631.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
; Lets `gps off`, periodic mode and shutdown cut the power to a serial GPS (RAK12501).
; WB_IO2 switches the shared 3V3_S slot rail, so this also powers down any other slot module.
[env:RAK_4631_repeater_gps_power]
extends = env:RAK_4631_repeater
build_flags =
${env:RAK_4631_repeater.build_flags}
-D GPS_RAIL_POWER_CONTROL
[env:RAK_4631_repeater_ethernet]
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D ADVERT_NAME='"RAK4631 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -75,7 +86,7 @@ lib_deps =
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D ADVERT_NAME='"RS232 Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -98,7 +109,7 @@ build_src_filter = ${rak4631.build_src_filter}
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D ADVERT_NAME='"RS232 Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -121,7 +132,7 @@ build_src_filter = ${rak4631.build_src_filter}
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D ADVERT_NAME='"Test Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -137,7 +148,7 @@ build_src_filter = ${rak4631.build_src_filter}
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D ADVERT_NAME='"RAK4631 Room Server"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -161,7 +172,7 @@ build_flags =
-I examples/companion_radio/ui-new
-D PIN_USER_BTN=9
-D PIN_USER_BTN_ANA=31
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ENABLE_USB_INTERFACE
@@ -186,7 +197,7 @@ build_flags =
-I examples/companion_radio/ui-new
-D PIN_USER_BTN=9
-D PIN_USER_BTN_ANA=31
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D ETHERNET_ENABLED=1
@@ -215,7 +226,7 @@ build_flags =
-I examples/companion_radio/ui-new
-D PIN_USER_BTN=9
-D PIN_USER_BTN_ANA=31
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
@@ -251,7 +262,7 @@ lib_deps =
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_CLASS=AutoDetectDisplay
-D ADVERT_NAME='"RAK4631 Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
+13 -3
View File
@@ -25,9 +25,19 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#include <helpers/sensors/RakLocationProvider.h>
RakI2cGpsDriver gps_driver;
#ifdef GPS_RAIL_POWER_CONTROL
#ifdef ETHERNET_ENABLED
#error "GPS_RAIL_POWER_CONTROL would cut the RAK13800's power, which also comes from WB_IO2"
#endif
// WB_IO2 switches 3V3_S, which powers the serial GPS and every other slot module.
RefCountedDigitalPin gps_rail(WB_IO2);
RakLocationProvider location(gps_driver, &rtc_clock, Serial1, &gps_rail);
#else
RakLocationProvider location(gps_driver, &rtc_clock);
#endif
EnvironmentSensorManager sensors(location);
#else
EnvironmentSensorManager sensors;
#endif
+1 -1
View File
@@ -9,7 +9,7 @@
#include <helpers/sensors/EnvironmentSensorManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
#include <helpers/ui/AutoDetectDisplay.h>
extern DISPLAY_CLASS display;
#include <helpers/ui/MomentaryButton.h>
extern MomentaryButton user_btn;
+2 -2
View File
@@ -22,7 +22,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -37,4 +38,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+4
View File
@@ -42,7 +42,11 @@ public:
}
const char* getManufacturerName() const override {
#if defined(PICO_RP2350)
return "Pico 2 W";
#else
return "Pico W";
#endif
}
void reboot() override {
+91 -44
View File
@@ -56,8 +56,8 @@ build_src_filter = ${rpi_picow.build_src_filter}
[env:PicoW_companion_radio_usb]
extends = rpi_picow
build_flags = ${rpi_picow.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-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
@@ -70,33 +70,14 @@ lib_ignore = BLE
[env:PicoW_companion_radio_ble]
extends = rpi_picow
build_flags = ${rpi_picow.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D PIO_FRAMEWORK_ARDUINO_ENABLE_BLUETOOTH
-D ENABLE_WIFI_INTERFACE
-D BLE_PIN_CODE=123456
-D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rpi_picow.build_src_filter}
+<helpers/rp2040/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
lib_deps = ${rpi_picow.lib_deps}
densaugeo/base64 @ ~1.4.0
; USB + WiFi + BLE together; the interface manager fans frames out to all of them
[env:PicoW_companion_radio]
extends = rpi_picow
build_flags = ${rpi_picow.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D ENABLE_USB_INTERFACE
-D ENABLE_WIFI_INTERFACE
-D PIO_FRAMEWORK_ARDUINO_ENABLE_BLUETOOTH
-D BLE_PIN_CODE=123456
; NOTE: DO NOT ENABLE --> -D BLE_DEBUG_LOGGING=1 (shares Serial with the USB interface)
; NOTE: DO NOT ENABLE --> -D WIFI_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rpi_picow.build_src_filter}
+<helpers/rp2040/SerialBLEInterface.cpp>
+<helpers/wifi/*.cpp>
@@ -104,29 +85,11 @@ build_src_filter = ${rpi_picow.build_src_filter}
lib_deps = ${rpi_picow.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:PicoW_companion_radio_wifi]
extends = rpi_picow
build_flags = ${rpi_picow.build_flags}
-D ENABLE_WIFI_INTERFACE
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='""' ; no default network, configure with 'set wifi.ssid' / 'set wifi.pwd'
-D WIFI_PWD='""'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rpi_picow.build_src_filter}
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
lib_deps = ${rpi_picow.lib_deps}
densaugeo/base64 @ ~1.4.0
lib_ignore = BLE
[env:PicoW_terminal_chat]
extends = rpi_picow
build_flags = ${rpi_picow.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=1
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rpi_picow.build_src_filter}
@@ -138,3 +101,87 @@ lib_deps = ${rpi_picow.lib_deps}
extends = rpi_picow
build_src_filter = ${rpi_picow.build_src_filter}
+<../examples/kiss_modem/>
[rpi_pico2w]
extends = rp2040_base
board = rpipico2w
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m
build_flags = ${rpi_picow.build_flags}
build_src_filter = ${rpi_picow.build_src_filter}
lib_deps = ${rpi_picow.lib_deps}
[env:Pico2W_repeater]
extends = rpi_pico2w
build_flags = ${rpi_pico2w.build_flags}
-D ADVERT_NAME='"Pico2W Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rpi_pico2w.build_src_filter}
+<../examples/simple_repeater>
[env:Pico2W_room_server]
extends = rpi_pico2w
build_flags = ${rpi_pico2w.build_flags}
-D ADVERT_NAME='"Test Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rpi_pico2w.build_src_filter}
+<../examples/simple_room_server>
[env:Pico2W_companion_radio_usb]
extends = rpi_pico2w
build_flags = ${rpi_pico2w.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 = ${rpi_pico2w.build_src_filter}
+<../examples/companion_radio/*.cpp>
lib_deps = ${rpi_pico2w.lib_deps}
densaugeo/base64 @ ~1.4.0
lib_ignore = BLE
[env:Pico2W_companion_radio_ble]
extends = rpi_pico2w
build_flags = ${rpi_pico2w.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D PIO_FRAMEWORK_ARDUINO_ENABLE_BLUETOOTH
-D ENABLE_WIFI_INTERFACE
-D BLE_PIN_CODE=123456
-D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rpi_pico2w.build_src_filter}
+<helpers/rp2040/SerialBLEInterface.cpp>
+<helpers/wifi/*.cpp>
+<../examples/companion_radio/*.cpp>
lib_deps = ${rpi_pico2w.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Pico2W_terminal_chat]
extends = rpi_pico2w
build_flags = ${rpi_pico2w.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rpi_pico2w.build_src_filter}
+<../examples/simple_secure_chat/main.cpp>
lib_deps = ${rpi_pico2w.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Pico2W_kiss_modem]
extends = rpi_pico2w
build_src_filter = ${rpi_pico2w.build_src_filter}
+<../examples/kiss_modem/>
@@ -8,7 +8,8 @@ ESPNOWRadio radio_driver;
ESP32RTCClock rtc_clock;
#if defined(ENV_INCLUDE_GPS)
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, (mesh::RTCClock*)&rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, (mesh::RTCClock*)&rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -1,5 +1,6 @@
#include <Arduino.h>
#include <Wire.h>
#include <HardwarePWM.h>
#include "SenseCapSolarBoard.h"
@@ -50,6 +51,9 @@ void SenseCapSolarBoard::begin() {
#ifdef LED_WHITE
pinMode(LED_WHITE, OUTPUT);
digitalWrite(LED_WHITE, LOW);
#ifdef SENSECAP_SOLAR_WHITE_LED
white_led_last_pulse_at_ = millis(); // first heartbeat pulse 5 s after boot
#endif
#endif
#ifdef LED_BLUE
pinMode(LED_BLUE, OUTPUT);
@@ -67,3 +71,76 @@ void SenseCapSolarBoard::begin() {
delay(10); // give sx1262 some time to power up
}
#ifdef SENSECAP_SOLAR_WHITE_LED
// Dimmed WHITE heartbeat using hardware PWM (repeater builds only).
//
// Peripheral audit for this firmware: no analogWrite()/tone() callers, no
// NeoPixel/Servo, Bluefruit52Lib uses no PWM, SoftDevice S140 does not own
// any PWM instance -> NRF_PWM0 (HwPWM0) is free. takeOwnership() fences the
// instance so a future analogWrite() caller cannot claim it.
//
// Timing: base clock 16 MHz (DIV_1), COUNTERTOP 16000 -> exactly 1 kHz.
// Duty: HardwarePWM non-inverted values place bit15 (active-HIGH polarity),
// so compare 1600 => HIGH for [0,1600)/16000 => 10% duty, active-high.
static const uint32_t WHITE_LED_PWM_TOKEN = 0x5031574C; // 'P1WL'
static const uint16_t WHITE_LED_PWM_TOP = 16000; // 16 MHz / 16000 = 1 kHz
static const uint16_t WHITE_LED_PWM_DUTY = 1600; // 1600 / 16000 = 10 %
static_assert(WHITE_LED_PWM_TOP <= 0x7FFF, "PWM compare values are 15-bit");
static_assert(WHITE_LED_PWM_DUTY < WHITE_LED_PWM_TOP, "duty must stay below COUNTERTOP");
void SenseCapSolarBoard::whiteLedHeartbeatOn() {
HwPWM0.takeOwnership(WHITE_LED_PWM_TOKEN); // no-op once owned; keeps analogWrite away
HwPWM0.setClockDiv(PWM_PRESCALER_PRESCALER_DIV_1); // 16 MHz base clock
HwPWM0.setMaxValue(WHITE_LED_PWM_TOP); // 1 kHz period
HwPWM0.addPin(LED_WHITE); // drives pin LOW, connects PSEL
HwPWM0.writePin(LED_WHITE, WHITE_LED_PWM_DUTY); // enables + starts 10% PWM
}
void SenseCapSolarBoard::whiteLedHeartbeatOff() {
HwPWM0.stop(); // ENABLE=0: waveform and its HFCLK demand stop
if (HwPWM0.checkPin(LED_WHITE)) {
HwPWM0.removePin(LED_WHITE); // disconnect PSEL; GPIO block drives again
}
pinMode(LED_WHITE, OUTPUT);
digitalWrite(LED_WHITE, LOW); // deterministic LOW during the 4900 ms off phase
}
// 100 ms pulse every 5000 ms, non-blocking millis() with wrap-safe unsigned
// arithmetic. Called from loop(); frozen while the OTA steady-on owns the LED.
void SenseCapSolarBoard::updateWhiteStatusLed() {
if (white_led_ota_active_) return;
const uint32_t now = millis();
const uint32_t elapsed = (uint32_t)(now - white_led_last_pulse_at_);
if (white_led_pulse_active_ && elapsed >= 100U) {
whiteLedHeartbeatOff(); // stop PWM, pin LOW
white_led_pulse_active_ = false;
}
if (!white_led_pulse_active_ && elapsed >= 5000U) {
whiteLedHeartbeatOn(); // 1 kHz hardware PWM, 10% duty
white_led_pulse_active_ = true;
white_led_last_pulse_at_ = now;
}
}
void SenseCapSolarBoard::loop() {
mesh::MainBoard::loop(); // keep base housekeeping (watchdog etc.) if it ever gains any
updateWhiteStatusLed();
}
// `start ota` keeps WHITE on for as long as the application is advertising
// its BLE OTA service. The heartbeat PWM is stopped and the pin released
// first, so steady-on is a plain full-brightness GPIO drive (no PWM vs
// digitalWrite conflict). On a failed start nothing changes: the heartbeat
// keeps its normal blinking.
bool SenseCapSolarBoard::startOTAUpdate(const char *id, char reply[]) {
const bool started = NRF52Board::startOTAUpdate(id, reply);
if (started) {
white_led_ota_active_ = true;
whiteLedHeartbeatOff();
digitalWrite(LED_WHITE, LED_STATE_ON);
}
return started;
}
#endif // SENSECAP_SOLAR_WHITE_LED
@@ -5,6 +5,19 @@
#include <helpers/NRF52Board.h>
class SenseCapSolarBoard : public NRF52BoardDCDC {
#ifdef SENSECAP_SOLAR_WHITE_LED
// Dimmed white-LED heartbeat state (repeater builds only; enabled with
// -D SENSECAP_SOLAR_WHITE_LED in the PlatformIO env, so room-server and
// companion firmwares sharing this board class are unaffected).
bool white_led_ota_active_ = false;
bool white_led_pulse_active_ = false;
uint32_t white_led_last_pulse_at_ = 0;
void whiteLedHeartbeatOn(); // start 1 kHz PWM at 10% duty on LED_WHITE
void whiteLedHeartbeatOff(); // stop/release PWM, hold LED_WHITE LOW
void updateWhiteStatusLed(); // non-blocking 100 ms pulse every 5000 ms
#endif
protected:
#ifdef NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
@@ -14,6 +27,13 @@ public:
SenseCapSolarBoard() : NRF52Board("SENSECAP_SOLAR_OTA") {}
void begin();
#ifdef SENSECAP_SOLAR_WHITE_LED
// Runs the white-LED heartbeat; invoked by the example main loops via the
// existing board.loop() call (mesh::MainBoard::loop() is a no-op by default).
void loop() override;
bool startOTAUpdate(const char *id, char reply[]) override;
#endif
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
@@ -38,6 +58,9 @@ public:
}
void powerOff() override {
#ifdef SENSECAP_SOLAR_WHITE_LED
whiteLedHeartbeatOff(); // stop/release the heartbeat PWM before shutdown
#endif
digitalWrite(LED_WHITE, LOW);
digitalWrite(LED_BLUE, LOW);
+2
View File
@@ -45,6 +45,8 @@ build_flags =
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
; dimmed white-LED heartbeat + OTA steady-on (repeater builds only)
-D SENSECAP_SOLAR_WHITE_LED=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${SenseCap_Solar.build_src_filter}
+2 -2
View File
@@ -13,7 +13,8 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -29,4 +30,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -2
View File
@@ -17,7 +17,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
@@ -44,4 +45,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+4 -4
View File
@@ -65,14 +65,14 @@ bool StationG3Board::handleCommand(const char* command, uint32_t sender_timestam
strcpy(reply, "Error: unsupported");
} else if (memcmp(&command[21], "on", 2) == 0) {
if (setLoRaFemLnaEnabled(true)) {
_prefs->setByKey("fem_rxgain", "1");
if (_prefs) _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");
if (_prefs) _prefs->setByKey("fem_rxgain", "0");
strcpy(reply, "OK - LoRa FEM RX gain off");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM RX gain");
@@ -96,14 +96,14 @@ bool StationG3Board::handleCommand(const char* command, uint32_t sender_timestam
strcpy(reply, "Error: unsupported");
} else if (memcmp(&command[21], "on", 2) == 0) {
if (setLoRaFemPaGainEnabled(true)) {
_prefs->setByKey("fem_txgain", "1");
if (_prefs) _prefs->setByKey("fem_txgain", "1");
strcpy(reply, "OK - LoRa FEM TX gain on");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM TX gain");
}
} else if (memcmp(&command[21], "off", 3) == 0) {
if (setLoRaFemPaGainEnabled(false)) {
_prefs->setByKey("fem_txgain", "0");
if (_prefs) _prefs->setByKey("fem_txgain", "0");
strcpy(reply, "OK - LoRa FEM TX gain off");
} else {
strcpy(reply, "Error: failed to apply LoRa FEM TX gain");
+2 -1
View File
@@ -17,7 +17,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
-1
View File
@@ -5,7 +5,6 @@
void T1000eBoard::begin() {
NRF52BoardDCDC::begin();
btn_prev_state = HIGH;
#ifdef BUTTON_PIN
pinMode(BATTERY_PIN, INPUT);
-14
View File
@@ -5,9 +5,6 @@
#include <helpers/NRF52Board.h>
class T1000eBoard : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
T1000eBoard() : NRF52Board("T1000E_OTA") {}
void begin();
@@ -38,17 +35,6 @@ public:
return "Seeed Tracker T1000-E";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == USER_BTN_PRESSED) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
#ifdef HAS_GPS
digitalWrite(GPS_VRTC_EN, LOW);
+1
View File
@@ -106,6 +106,7 @@ build_flags = ${t1000-e.build_flags}
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
; -D GPS_NMEA_DEBUG
-D OFFLINE_QUEUE_SIZE=256
-D DISPLAY_CLASS=NullDisplayDriver
-D PIN_BUZZER=25
+9 -21
View File
@@ -1,8 +1,8 @@
#include <Arduino.h>
#include "t1000e_sensors.h"
#include "target.h"
#include <helpers/sensors/AirohaGpsDriver.h>
#include <helpers/sensors/MicroNMEALocationProvider.h>
#include <helpers/sensors/AirohaSleep.h>
T1000eBoard board;
@@ -11,8 +11,9 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock rtc_clock;
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
T1000SensorManager sensors = T1000SensorManager(nmea);
AirohaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
T1000SensorManager sensors(nmea, gps_driver);
#ifdef DISPLAY_CLASS
NullDisplayDriver display;
@@ -81,29 +82,16 @@ mesh::LocalIdentity radio_new_identity() {
}
void T1000SensorManager::start_gps() {
gps_active = true;
digitalWrite(GPS_EN, HIGH);
delay(10);
digitalWrite(GPS_RTC_INT, HIGH);
delay(5);
digitalWrite(GPS_RTC_INT, LOW);
_nmea->setGpsOn(true);
}
void T1000SensorManager::stop_gps() {
gps_active = false;
digitalWrite(GPS_VRTC_EN, HIGH); // keep GPS RTC alive for faster fix on wake
digitalWrite(GPS_RTC_INT, LOW); // make sure this is LOW so we can pulse it to wake
airohaEnterSleep(_nmea); // send command to put the GPS into RTC backup sleep
digitalWrite(GPS_EN, LOW);
_nmea->setGpsOn(false);
}
bool T1000SensorManager::begin() {
// init GPS
Serial1.begin(115200);
digitalWrite(GPS_RESET, HIGH);
delay(10);
digitalWrite(GPS_RESET, LOW);
_gps_driver->initialize();
return true;
}
@@ -125,7 +113,7 @@ void T1000SensorManager::loop() {
_nmea->loop();
if (millis() > next_gps_update) {
if (gps_active && _nmea->isValid()) {
if (_nmea->isGpsOn() && _nmea->hasValidFix()) {
node_lat = ((double)_nmea->getLatitude())/1000000.;
node_lon = ((double)_nmea->getLongitude())/1000000.;
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
@@ -141,7 +129,7 @@ const char* T1000SensorManager::getSettingName(int i) const {
}
const char* T1000SensorManager::getSettingValue(int i) const {
if (i == 0) {
return gps_active ? "1" : "0";
return _nmea->isGpsOn() ? "1" : "0";
}
return NULL;
}
+5 -2
View File
@@ -12,15 +12,18 @@
#include "NullDisplayDriver.h"
#endif
class AirohaGpsDriver;
class T1000SensorManager: public SensorManager {
bool gps_active = false;
LocationProvider * _nmea;
AirohaGpsDriver* _gps_driver;
void start_gps();
void sleep_gps();
void stop_gps();
public:
T1000SensorManager(LocationProvider &nmea): _nmea(&nmea) { }
T1000SensorManager(LocationProvider &nmea, AirohaGpsDriver& gps_driver)
: _nmea(&nmea), _gps_driver(&gps_driver) { }
bool begin() override;
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
void loop() override;
+2
View File
@@ -117,6 +117,8 @@
#define GPS_RTC_INT (15) // P0.15
#define GPS_RESETB (46) // P1.14
#define GPS_BAUDRATE 115200
////////////////////////////////////////////////////////////////////////////////
// Temp+Lux Sensor
+11
View File
@@ -24,6 +24,17 @@ build_flags = ${nrf52_base.build_flags}
-D SX126X_RX_BOOSTED_GAIN=1
-D LORA_TX_POWER=22
-D P_LORA_TX_LED=13
-D UI_RECENT_LIST_SIZE=9
-D UI_MSG_PREVIEW_SIZE=165
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
-D EINK_SCALE_X=1.5625f
-D EINK_SCALE_Y=1.5625f
-D EINK_X_OFFSET=0
-D EINK_Y_OFFSET=10
-D BACKLIGHT_BTN=PIN_BUTTON2
-D AUTO_OFF_MILLIS=300000 ; 5 minutes
-D UI_NO_HIBERNATE
-D DISABLE_DIAGNOSTIC_OUTPUT
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<ThinkNodeM1Board.cpp>
+9 -51
View File
@@ -2,6 +2,7 @@
#include "target.h"
#include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/MicroNMEALocationProvider.h>
#include <helpers/sensors/NmeaGpsDriver.h>
ThinkNodeM1Board board;
@@ -11,12 +12,14 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(gps_driver, &rtc_clock);
ThinkNodeM1SensorManager sensors = ThinkNodeM1SensorManager(nmea);
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
MomentaryButton backlight_btn(BACKLIGHT_BTN, 1000, true);
#endif
bool radio_init() {
@@ -30,34 +33,15 @@ mesh::LocalIdentity radio_new_identity() {
}
void ThinkNodeM1SensorManager::start_gps() {
if (!gps_active) {
gps_active = true;
_location->begin();
}
_location->setGpsOn(true);
}
void ThinkNodeM1SensorManager::stop_gps() {
if (gps_active) {
gps_active = false;
_location->stop();
}
_location->setGpsOn(false);
}
bool ThinkNodeM1SensorManager::begin() {
Serial1.begin(9600);
// Initialize GPS switch pin
pinMode(PIN_GPS_SWITCH, INPUT);
last_gps_switch_state = digitalRead(PIN_GPS_SWITCH);
// Initialize GPS power pin
pinMode(GPS_EN, OUTPUT);
// Check initial switch state to determine if GPS should be active
if (last_gps_switch_state == HIGH) { // Switch is HIGH when ON
start_gps();
}
start_gps();
return true;
}
@@ -70,36 +54,11 @@ bool ThinkNodeM1SensorManager::querySensors(uint8_t requester_permissions, Cayen
void ThinkNodeM1SensorManager::loop() {
static long next_gps_update = 0;
static long last_switch_check = 0;
// Check GPS switch state every second
if (millis() - last_switch_check > 1000) {
bool current_switch_state = digitalRead(PIN_GPS_SWITCH);
// Detect switch state change
if (current_switch_state != last_gps_switch_state) {
last_gps_switch_state = current_switch_state;
if (current_switch_state == HIGH) { // Switch is ON
MESH_DEBUG_PRINTLN("GPS switch ON");
start_gps();
} else { // Switch is OFF
MESH_DEBUG_PRINTLN("GPS switch OFF");
stop_gps();
}
}
last_switch_check = millis();
}
if (!gps_active) {
return; // GPS is not active, skip further processing
}
_location->loop();
if (millis() > next_gps_update) {
if (_location->isValid()) {
if (_location->isGpsOn() && _location->hasValidFix()) {
node_lat = ((double)_location->getLatitude())/1000000.;
node_lon = ((double)_location->getLongitude())/1000000.;
node_altitude = ((double)_location->getAltitude()) / 1000.0;
@@ -119,7 +78,7 @@ const char* ThinkNodeM1SensorManager::getSettingName(int i) const {
const char* ThinkNodeM1SensorManager::getSettingValue(int i) const {
if (i == 0) {
return gps_active ? "1" : "0";
return _location->isGpsOn() ? "1" : "0";
}
return NULL;
}
@@ -135,4 +94,3 @@ bool ThinkNodeM1SensorManager::setSettingValue(const char* name, const char* val
}
return false; // not supported
}
+1 -3
View File
@@ -14,8 +14,6 @@
#endif
class ThinkNodeM1SensorManager : public SensorManager {
bool gps_active = false;
bool last_gps_switch_state = false;
LocationProvider* _location;
void start_gps();
@@ -40,8 +38,8 @@ extern ThinkNodeM1SensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern MomentaryButton backlight_btn;
#endif
bool radio_init();
mesh::LocalIdentity radio_new_identity();
+8 -1
View File
@@ -81,7 +81,7 @@
#define BUTTON_PIN PIN_BUTTON1
#define PIN_USER_BTN BUTTON_PIN
#define PIN_BUTTON2 (11)
#define PIN_BUTTON2 (39)
#define BUTTON_PIN2 PIN_BUTTON2
#define EXTERNAL_FLASH_DEVICES MX25R1635F
@@ -131,6 +131,11 @@ extern const int SCK;
#define DISP_BUSY (3)
#define DISP_BACKLIGHT (43)
#define PIN_DISPLAY_CS DISP_CS
#define PIN_DISPLAY_DC DISP_DC
#define PIN_DISPLAY_RST DISP_RST
#define PIN_DISPLAY_BUSY DISP_BUSY
////////////////////////////////////////////////////////////////////////////////
// GPS
@@ -141,3 +146,5 @@ extern const int SCK;
#define PIN_GPS_PPS (36)
#define PIN_GPS_STANDBY (34)
#define PIN_GPS_SWITCH (33)
#define GPS_SWITCH_IS_HARDWARE (0)
#define GPS_SWITCH_TURNS_GPS_ON (1)
@@ -6,7 +6,6 @@
void ThinkNodeM3Board::begin() {
NRF52Board::begin();
btn_prev_state = HIGH;
Wire.begin();
-12
View File
@@ -11,7 +11,6 @@ protected:
#if NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
uint8_t btn_prev_state;
public:
ThinkNodeM3Board() : NRF52Board("THINKNODE_M3_OTA") {}
@@ -31,17 +30,6 @@ public:
return "Elecrow ThinkNode M3";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
// turn off all leds, sd_power_system_off will not do this for us
digitalWrite(PIN_LED_BLUE, !LED_STATE_ON);
+2 -1
View File
@@ -11,7 +11,8 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -6,7 +6,6 @@
void ThinkNodeM4Board::begin() {
NRF52Board::begin();
btn_prev_state = HIGH;
Wire.begin();
battery_serial->begin(4800);
-12
View File
@@ -9,7 +9,6 @@ protected:
#if NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
uint8_t btn_prev_state;
HardwareSerial * battery_serial;
uint16_t bat_level_mv = 0;
uint8_t bat_level_percent =0;
@@ -32,17 +31,6 @@ public:
return "Elecrow ThinkNode M4";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == USER_BTN_PRESSED) ? 1 : -1;
}
#endif
return 0;
}
void shutdownPeripherals() override {
// shutdown common peripherals
NRF52Board::shutdownPeripherals();
+2 -1
View File
@@ -11,7 +11,8 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
+6 -2
View File
@@ -26,8 +26,11 @@ build_flags = ${esp32_base.build_flags}
-D EINK_SCALE_Y=1.5625f
-D EINK_X_OFFSET=0
-D EINK_Y_OFFSET=10
-D UI_RECENT_LIST_SIZE=9
-D UI_MSG_PREVIEW_SIZE=165
-D BACKLIGHT_BTN=PIN_BUTTON2
-D AUTO_OFF_MILLIS=0
-D AUTO_OFF_MILLIS=300000
-D UI_NO_HIBERNATE
-D DISABLE_DIAGNOSTIC_OUTPUT
-D SX126X_DIO2_AS_RF_SWITCH=true
-D SX126X_DIO3_TCXO_VOLTAGE=3.3
@@ -150,7 +153,6 @@ build_flags =
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
-D UI_RECENT_LIST_SIZE=9
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D GPS_NMEA_DEBUG
@@ -174,12 +176,14 @@ build_flags =
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
-D ENABLE_USB_INTERFACE
-D ENABLE_WIFI_INTERFACE
build_src_filter = ${ThinkNode_M5.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
+<helpers/ui/buzzer.cpp>
+<helpers/wifi/*.cpp>
lib_deps =
${ThinkNode_M5.lib_deps}
densaugeo/base64 @ ~1.4.0
+3 -3
View File
@@ -17,7 +17,8 @@ ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -26,6 +27,7 @@ EnvironmentSensorManager sensors = EnvironmentSensorManager();
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
MomentaryButton backlight_btn(BACKLIGHT_BTN, 1000, true);
#endif
bool radio_init() {
@@ -45,5 +47,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+1
View File
@@ -24,6 +24,7 @@ extern PCA9557 expander;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
extern MomentaryButton backlight_btn;
#endif
bool radio_init();
+2 -1
View File
@@ -25,4 +25,5 @@
#define PIN_GPS_RESET (13)
#define PIN_GPS_RX (20)
#define PIN_GPS_TX (19)
#define PIN_GPS_SWITCH (10)
#define PIN_GPS_SWITCH (10)
#define GPS_SWITCH_IS_HARDWARE (1)
+2 -2
View File
@@ -12,7 +12,8 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -32,4 +33,3 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+2 -2
View File
@@ -12,7 +12,8 @@ ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
NmeaGpsDriver gps_driver(Serial1);
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
@@ -81,4 +82,3 @@ mesh::LocalIdentity radio_new_identity() {
return mesh::LocalIdentity(&rng); // create new random identity
}
+5 -9
View File
@@ -18,12 +18,14 @@ build_flags = ${nrf52_base.build_flags}
-D P_LORA_SCLK=19
-D P_LORA_MISO=22
-D P_LORA_MOSI=20
-D UI_SHOW_CLOCK=1
-D DISPLAY_ROTATION=4
-D UI_HAS_ROTARY_INPUT=1
-D UI_HAS_NAV_INPUT=1
-D UI_RECENT_LIST_SIZE=9
-D UI_MSG_PREVIEW_SIZE=165
-D EINK_MAX_PARTIAL_REFRESH=60
-D AUTO_OFF_MILLIS=300000
-D BACKLIGHT_BTN=PIN_BUTTON2
-D UI_SHOW_CLOCK=1
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
; -D EINK_DISPLAY_MODEL=GxEPD2_154_GDEY0154D67
; -D EINK_DISPLAY_MODEL=GxEPD2_150_BN
@@ -40,6 +42,7 @@ build_flags = ${nrf52_base.build_flags}
-D LORA_TX_POWER=22
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<ThinkNodeM8Board.cpp>
+<../variants/thinknode_m8>
lib_deps =
@@ -92,10 +95,7 @@ build_flags =
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
# -D BLE_DEBUG_LOGGING=1
-D DISPLAY_ROTATION=4
-D DISPLAY_CLASS=GxEPDDisplay
-D BACKLIGHT_BTN=PIN_BUTTON2
-D AUTO_OFF_MILLIS=0
-D OFFLINE_QUEUE_SIZE=256
-D PIN_BUZZER=33
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
@@ -110,7 +110,6 @@ build_src_filter = ${ThinkNode_M8.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/RotaryInputGPIO.cpp>
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
@@ -133,8 +132,6 @@ build_flags =
-D DISPLAY_ROTATION=4
-D QSPIFLASH=1
-D DISPLAY_CLASS=GxEPDDisplay
-D BACKLIGHT_BTN=PIN_BUTTON2
-D AUTO_OFF_MILLIS=0
-D OFFLINE_QUEUE_SIZE=256
-D PIN_BUZZER=6
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
@@ -144,7 +141,6 @@ build_src_filter = ${ThinkNode_M8.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/RotaryInputGPIO.cpp>
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
Loaded 100 of 178 files, more files were not shown because too many files have changed in this diff. Show more