Merge upstream/dev (80 commits) [upstream-sync]
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
8d0b0dd164
140 files changed
+3573
-853
No files matched your search
@@ -0,0 +1,20 @@
|
||||
#include "DFRobotLoRaBoard.h"
|
||||
|
||||
void DFRobotLoRaBoard::begin() {
|
||||
// SX1262 module power. Held high for the whole boot; Companion does not
|
||||
// drop into deep sleep, so the pin does not need an RTC hold.
|
||||
pinMode(LORA_POWER_EN, OUTPUT);
|
||||
digitalWrite(LORA_POWER_EN, HIGH);
|
||||
delay(10);
|
||||
|
||||
periph_power.begin();
|
||||
|
||||
pinMode(PIN_LED, OUTPUT);
|
||||
digitalWrite(PIN_LED, HIGH);
|
||||
|
||||
ESP32Board::begin();
|
||||
}
|
||||
|
||||
const char* DFRobotLoRaBoard::getManufacturerName() const {
|
||||
return "DFRobot LoRaWAN ESP32-S3";
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
|
||||
class DFRobotLoRaBoard : public ESP32Board {
|
||||
public:
|
||||
RefCountedDigitalPin periph_power;
|
||||
|
||||
DFRobotLoRaBoard() : periph_power(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE) { }
|
||||
|
||||
void begin();
|
||||
const char* getManufacturerName() const override;
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
; DFRobot LoRaWAN ESP32-S3 (DFR1195)
|
||||
; ESP32-S3-WROOM-1-N4 (4 MB flash, no PSRAM), SX1262, SPI ST7735S 80x160.
|
||||
; Pin map follows variants/esp32s3/DFRobot_LoRaWAN_ESP32-S3 in the Meshtastic tree.
|
||||
; LoRa is on FSPI. The display is on HSPI (SPI3), matching ST7735_SPI_HOST.
|
||||
[DFRobot_LoRaWAN_ESP32S3]
|
||||
extends = esp32_base
|
||||
board = dfrobot_lorawan_esp32s3
|
||||
; 4 MB module: app slots are 1.9 MB. The default 4 MB table only leaves 1.25 MB.
|
||||
board_build.partitions = min_spiffs.csv
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/dfrobot_lorawan_esp32s3
|
||||
-D DFROBOT_LORAWAN_ESP32S3
|
||||
-D ESP32_CPU_FREQ=80
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_NSS=10
|
||||
-D P_LORA_DIO_1=4
|
||||
-D P_LORA_RESET=41
|
||||
-D P_LORA_BUSY=40
|
||||
-D P_LORA_SCLK=7
|
||||
-D P_LORA_MISO=5
|
||||
-D P_LORA_MOSI=6
|
||||
-D LORA_POWER_EN=42
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=3.3
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D PIN_USER_BTN=18
|
||||
-D PIN_LED=21
|
||||
-D PIN_VEXT_EN=48
|
||||
-D PIN_VEXT_EN_ACTIVE=LOW
|
||||
-D PIN_BOARD_SDA=8
|
||||
-D PIN_BOARD_SCL=9
|
||||
-D PIN_TFT_CS=17
|
||||
-D PIN_TFT_DC=14
|
||||
-D PIN_TFT_RST=15
|
||||
-D PIN_TFT_SDA=11
|
||||
-D PIN_TFT_SCL=12
|
||||
-D PIN_TFT_LEDA_CTL=16
|
||||
-D PIN_TFT_LEDA_CTL_ACTIVE=HIGH
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/dfrobot_lorawan_esp32s3>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
bodmer/TFT_eSPI @ ^2.4.31
|
||||
|
||||
; Landscape UI on the 80x160 panel. Use 3 if the picture is upside down.
|
||||
[env:DFRobot_LoRaWAN_ESP32S3_companion_radio_ble]
|
||||
extends = DFRobot_LoRaWAN_ESP32S3
|
||||
build_flags =
|
||||
${DFRobot_LoRaWAN_ESP32S3.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_ROTATION=3
|
||||
-D DISPLAY_CLASS=ST7735Display
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${DFRobot_LoRaWAN_ESP32S3.build_src_filter}
|
||||
+<helpers/esp32/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<helpers/ui/ST7735Display.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${DFRobot_LoRaWAN_ESP32S3.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
#include "target.h"
|
||||
|
||||
DFRobotLoRaBoard board;
|
||||
|
||||
// FSPI is SPI2. The ST7735 driver takes HSPI (SPI3); the default SPIClass
|
||||
// constructor on ESP32-S3 is HSPI and would collide with the display.
|
||||
static SPIClass spi(FSPI);
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display(&board.periph_power);
|
||||
// Active-low button, internal pull-up.
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true);
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
return radio.std_init(&spi);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <DFRobotLoRaBoard.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/ST7735Display.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
extern DFRobotLoRaBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#endif
|
||||
|
||||
class SolarSensorManager : public SensorManager {
|
||||
bool gps_active = false;
|
||||
bool gps_detected = false;
|
||||
LocationProvider* _location;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#endif
|
||||
|
||||
class HWTSensorManager : public SensorManager {
|
||||
bool gps_active = false;
|
||||
LocationProvider * _location;
|
||||
|
||||
void start_gps();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -212,6 +212,7 @@ build_flags =
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D ENABLE_WIFI_INTERFACE
|
||||
-D ENABLE_ESP_MDNS
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${heltec_v4_oled.build_src_filter}
|
||||
@@ -231,6 +232,7 @@ build_flags =
|
||||
${heltec_v4_oled.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D ENABLE_WIFI_INTERFACE
|
||||
-D ENABLE_ESP_MDNS
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# LilyGO T3 STM32 V1.0
|
||||
|
||||
MVP support for the STM32WL55CCU6 board with its integrated Sub-GHz radio and
|
||||
128×64 SSD1315 SPI OLED. Supports a USB companion and a repeater, with a default
|
||||
transmit power of **20 dBm**. The companion uses USB serial; the board has no BLE.
|
||||
|
||||
## Build
|
||||
|
||||
```sh
|
||||
pio run -e LilyGo_T3_STM32_companion_radio_usb
|
||||
pio run -e LilyGo_T3_STM32_repeater
|
||||
```
|
||||
|
||||
The companion supports 100 contacts and eight channels. Radio settings inherit
|
||||
the repository defaults; select settings appropriate to the board's RF band.
|
||||
Existing saved preferences override build defaults.
|
||||
|
||||
## Optional INA219 telemetry
|
||||
|
||||
The INA219 builds use MeshCore's existing environment sensor driver to report
|
||||
voltage, current, and power. Build either role with:
|
||||
|
||||
```sh
|
||||
pio run -e LilyGo_T3_STM32_repeater_ina219
|
||||
pio run -e LilyGo_T3_STM32_companion_radio_usb_ina219
|
||||
```
|
||||
|
||||
Connect the sensor's logic supply to **3.3 V** and use a common ground:
|
||||
|
||||
| INA219 connection | T3 STM32 connection |
|
||||
| --- | --- |
|
||||
| VCC / logic supply | 3.3 V |
|
||||
| GND | GND |
|
||||
| SDA | PB7 (JP2 pin 9) |
|
||||
| SCL | PB8 (JP2 pin 10) |
|
||||
|
||||
PB7/PB8 are the alternate I2C1 pins exposed on the board headers. The default
|
||||
STM32 I2C pins, PA9/PA10, are reserved for USB serial. The OLED uses SPI.
|
||||
The sensor is detected at startup at address **0x40**; to use another address,
|
||||
override `TELEM_INA219_ADDRESS` in the build flags. An absent sensor produces no
|
||||
additional telemetry. The base builds do not initialize I2C or include the driver.
|
||||
|
||||
The measurement terminals (VIN+ and VIN-) go in series with the positive supply
|
||||
of the circuit being measured; these are separate from the sensor's logic supply.
|
||||
See the [INA219 wiring guide](https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout/wiring).
|
||||
USB power can bypass a sensor placed only in the battery lead.
|
||||
|
||||
Readings use environment telemetry permissions. Existing telemetry encodes current
|
||||
in 1 mA steps and power in whole watts; it does not provide accumulated mAh or
|
||||
battery percentage. INA219 telemetry has been confirmed on hardware with the
|
||||
repeater build; the USB companion sensor build has been compile-tested only.
|
||||
|
||||
## Flash and connect
|
||||
|
||||
Connect the USB serial port. Hold BOOT, press and release RST, then release BOOT:
|
||||
|
||||
```sh
|
||||
pio run -e LilyGo_T3_STM32_companion_radio_usb -t upload --upload-port /dev/ttyACM0
|
||||
```
|
||||
|
||||
Choose your actual serial port, then press RST after programming. The repeater
|
||||
CLI and USB companion protocol both use USART1 at **115200 baud**.
|
||||
|
||||
The bundled `stm32flash` 0.7 may reject device ID `0x497` due to an
|
||||
[upstream packaging issue](https://github.com/platformio/platform-ststm32/issues/899).
|
||||
Use an updated [stm32flash](https://sourceforge.net/p/stm32flash/code/ci/master/tree/)
|
||||
with STM32WL support, or STM32CubeProgrammer in UART mode. For CubeProgrammer,
|
||||
use `.pio/build/<environment>/firmware.hex`, or `firmware.bin` at `0x08000000`.
|
||||
ST-Link and J-Link uploads are also available through the board's SWD connector.
|
||||
|
||||
Application flash is limited to **224 KiB**. InternalFS occupies the final
|
||||
32 KiB at `0x08038000`–`0x0803FFFF`; preserve it when updating to retain the
|
||||
identity and settings.
|
||||
|
||||
## Hardware mapping
|
||||
|
||||
| Function | Pins / setting |
|
||||
| --- | --- |
|
||||
| USART1 | TX PA9, RX PA10 |
|
||||
| Radio RF switch | PB2/PB6: idle 0/0, RX 1/0, HP TX 0/1 |
|
||||
| Radio oscillator | 32 MHz crystal; TCXO mode disabled |
|
||||
| SPI1 | SCK PA5, MISO PA6, MOSI PA7 |
|
||||
| OLED | CS PB12, DC PA8, no software reset pin |
|
||||
| SD card | CS PA4, held high |
|
||||
| User button | PH3/BOOT, active high |
|
||||
| LEDs | PA0/PA1, left off |
|
||||
|
||||
Initialization follows the manufacturer's
|
||||
[hardware files](https://github.com/Xinyuan-LilyGO/T3-STM32/tree/master/hardware)
|
||||
and [reference firmware](https://github.com/Xinyuan-LilyGO/T3-STM32/tree/master/examples/6_SubGHz_TXRX).
|
||||
|
||||
## MVP validation and limitations
|
||||
|
||||
Hardware checks covered OLED startup, USB companion communication, advertisement
|
||||
reception, Public message transmission, and matching repeater trace replies at
|
||||
20 dBm. Public packets were captured and decrypted independently. Some repeater
|
||||
pings timed out; long-term reliability has not been established. Higher transmit
|
||||
powers are outside the validated MVP setting.
|
||||
|
||||
The repeater builds successfully; forwarding has not been hardware-tested.
|
||||
Built-in battery telemetry, SD storage, and low-power optimization are not implemented.
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
// Include the device headers first so subsequent Arduino includes cannot
|
||||
// reintroduce the peripheral macro. It conflicts with both mesh::RNG and
|
||||
// Crypto's global RNG object. Leave C HAL sources' register macros intact.
|
||||
#include <Arduino.h>
|
||||
#ifdef RNG
|
||||
#undef RNG
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
[lilygo_t3_stm32]
|
||||
extends = stm32_base
|
||||
board = lilygo_t3_stm32
|
||||
board_upload.maximum_size = 229376 ; final 32 KiB reserved for InternalFS
|
||||
build_flags = ${stm32_base.build_flags}
|
||||
-include variants/lilygo_t3_stm32/STM32ArduinoCompat.h
|
||||
-I variants/lilygo_t3_stm32
|
||||
-D RADIO_CLASS=CustomSTM32WLx
|
||||
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
|
||||
-D LORA_TX_POWER=20
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D STM32WL_TCXO_VOLTAGE=0 ; crystal oscillator; manufacturer sets IS_TCXO_SUPPORTED=0
|
||||
-D PIN_SERIAL_TX=PA9
|
||||
-D PIN_SERIAL_RX=PA10
|
||||
-D SERIAL_UART_INSTANCE=1
|
||||
-D PIN_SPI_SCK=PA5
|
||||
-D PIN_SPI_MISO=PA6
|
||||
-D PIN_SPI_MOSI=PA7
|
||||
-D PIN_OLED_CS=PB12
|
||||
-D PIN_OLED_DC=PA8
|
||||
-D PIN_OLED_RESET=-1
|
||||
-D PIN_USER_BTN=PH3
|
||||
-D USER_BTN_PRESSED=HIGH
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
build_src_filter = ${stm32_base.build_src_filter}
|
||||
+<../variants/lilygo_t3_stm32>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
lib_deps = ${stm32_base.lib_deps}
|
||||
adafruit/Adafruit SSD1306 @ ^2.5.13
|
||||
|
||||
[env:LilyGo_T3_STM32_repeater]
|
||||
extends = lilygo_t3_stm32
|
||||
build_flags = ${lilygo_t3_stm32.build_flags}
|
||||
-D ADVERT_NAME='"T3 STM32 Repeater"'
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
build_src_filter = ${lilygo_t3_stm32.build_src_filter}
|
||||
+<../examples/simple_repeater/*.cpp>
|
||||
|
||||
[env:LilyGo_T3_STM32_companion_radio_usb]
|
||||
extends = lilygo_t3_stm32
|
||||
build_flags = ${lilygo_t3_stm32.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D ENABLE_USB_INTERFACE
|
||||
build_src_filter = ${lilygo_t3_stm32.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps = ${lilygo_t3_stm32.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
; Optional INA219 telemetry on I2C1. Keep the base builds sensor-free.
|
||||
[lilygo_t3_stm32_ina219]
|
||||
build_flags =
|
||||
-D ENV_INCLUDE_INA219=1
|
||||
-D PIN_WIRE_SDA=PB7
|
||||
-D PIN_WIRE_SCL=PB8
|
||||
build_src_filter =
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
lib_deps =
|
||||
adafruit/Adafruit INA219 @ ^1.2.3
|
||||
|
||||
[env:LilyGo_T3_STM32_repeater_ina219]
|
||||
extends = env:LilyGo_T3_STM32_repeater
|
||||
build_flags = ${env:LilyGo_T3_STM32_repeater.build_flags}
|
||||
${lilygo_t3_stm32_ina219.build_flags}
|
||||
build_src_filter = ${env:LilyGo_T3_STM32_repeater.build_src_filter}
|
||||
${lilygo_t3_stm32_ina219.build_src_filter}
|
||||
lib_deps = ${lilygo_t3_stm32.lib_deps}
|
||||
${lilygo_t3_stm32_ina219.lib_deps}
|
||||
|
||||
[env:LilyGo_T3_STM32_companion_radio_usb_ina219]
|
||||
extends = env:LilyGo_T3_STM32_companion_radio_usb
|
||||
build_flags = ${env:LilyGo_T3_STM32_companion_radio_usb.build_flags}
|
||||
${lilygo_t3_stm32_ina219.build_flags}
|
||||
build_src_filter = ${env:LilyGo_T3_STM32_companion_radio_usb.build_src_filter}
|
||||
${lilygo_t3_stm32_ina219.build_src_filter}
|
||||
lib_deps = ${env:LilyGo_T3_STM32_companion_radio_usb.lib_deps}
|
||||
${lilygo_t3_stm32_ina219.lib_deps}
|
||||
@@ -0,0 +1,94 @@
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
#if ENV_INCLUDE_INA219
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
#include "target.h"
|
||||
|
||||
LilyGoT3STM32Board board;
|
||||
RADIO_CLASS radio = new STM32WLx_Module();
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
VolatileRTCClock rtc_clock;
|
||||
#if ENV_INCLUDE_INA219
|
||||
EnvironmentSensorManager sensors;
|
||||
#else
|
||||
SensorManager sensors;
|
||||
#endif
|
||||
DISPLAY_CLASS display;
|
||||
// PH3 is also BOOT0: the board's button is active high with an external pull-down.
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, false);
|
||||
|
||||
static const uint32_t rfswitch_pins[] = {
|
||||
PB2, PB6, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC
|
||||
};
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
{STM32WLx::MODE_IDLE, {LOW, LOW}},
|
||||
{STM32WLx::MODE_RX, {HIGH, LOW}},
|
||||
{STM32WLx::MODE_TX_HP, {LOW, HIGH}},
|
||||
END_OF_MODE_TABLE,
|
||||
};
|
||||
|
||||
void LilyGoT3STM32Board::begin() {
|
||||
STM32Board::begin();
|
||||
|
||||
#if ENV_INCLUDE_INA219
|
||||
// These builds remap Wire to PB7/PB8; PA9/PA10 are used by USART1.
|
||||
Wire.begin();
|
||||
#endif
|
||||
|
||||
// The SD card shares SPI1 with the OLED; keep it deselected.
|
||||
digitalWrite(PA4, HIGH);
|
||||
pinMode(PA4, OUTPUT);
|
||||
digitalWrite(PIN_OLED_CS, HIGH);
|
||||
pinMode(PIN_OLED_CS, OUTPUT);
|
||||
pinMode(PIN_USER_BTN, INPUT);
|
||||
// Both onboard LEDs are active high. Leave them off until explicitly needed.
|
||||
digitalWrite(PA0, LOW);
|
||||
pinMode(PA0, OUTPUT);
|
||||
digitalWrite(PA1, LOW);
|
||||
pinMode(PA1, OUTPUT);
|
||||
|
||||
SPI.setSCLK(PIN_SPI_SCK);
|
||||
SPI.setMISO(PIN_SPI_MISO);
|
||||
SPI.setMOSI(PIN_SPI_MOSI);
|
||||
SPI.begin();
|
||||
delay(200); // OLED power-on settling time used by the manufacturer's example.
|
||||
}
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
static bool check_radio_status(int status, const char* stage) {
|
||||
if (status == RADIOLIB_ERR_NONE) return true;
|
||||
|
||||
Serial.print("ERROR: ");
|
||||
Serial.print(stage);
|
||||
Serial.print(": ");
|
||||
Serial.println(status);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool radio_init() {
|
||||
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
||||
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 (!check_radio_status(status, "radio.begin")) return false;
|
||||
|
||||
// Match the manufacturer's 3.3 V power-LDO trim (REG_DRV_CTRL).
|
||||
const uint8_t power_ldo_3v3 = 0x0E;
|
||||
status = radio.writeRegister(0x091F, &power_ldo_3v3, 1);
|
||||
if (!check_radio_status(status, "power LDO trim")) return false;
|
||||
|
||||
status = radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
|
||||
if (!check_radio_status(status, "current limit")) return false;
|
||||
status = radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
|
||||
if (!check_radio_status(status, "RX gain")) return false;
|
||||
return check_radio_status(radio.setCRC(1), "CRC");
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/stm32/STM32Board.h>
|
||||
#include <helpers/radiolib/CustomSTM32WLxWrapper.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#if ENV_INCLUDE_INA219
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
#else
|
||||
#include <helpers/SensorManager.h>
|
||||
#endif
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
|
||||
class LilyGoT3STM32Board : public STM32Board {
|
||||
public:
|
||||
void begin() override;
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "LilyGO T3 STM32";
|
||||
}
|
||||
};
|
||||
|
||||
extern LilyGoT3STM32Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
#if ENV_INCLUDE_INA219
|
||||
extern EnvironmentSensorManager sensors;
|
||||
#else
|
||||
extern SensorManager sensors;
|
||||
#endif
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -93,6 +93,7 @@ build_flags =
|
||||
${LilyGo_T-Echo.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D EINK_REFRESH_LOOP
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D QSPIFLASH=1
|
||||
@@ -120,6 +121,7 @@ build_flags =
|
||||
${LilyGo_T-Echo.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D EINK_REFRESH_LOOP
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
|
||||
@@ -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();
|
||||
@@ -36,5 +37,3 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
#endif
|
||||
|
||||
class MASensorManager : public SensorManager {
|
||||
bool gps_active = false;
|
||||
LocationProvider * _location;
|
||||
LocationProvider* _location;
|
||||
|
||||
void start_gps();
|
||||
void stop_gps();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) { }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
@@ -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
|
||||
}
|
||||
@@ -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();
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <variant_NUCLEO_WL55JC1.h>
|
||||
|
||||
#undef RNG
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace rak3401 {
|
||||
|
||||
enum class OnboardRadioState { Absent, Asleep, BusyTimeout, SleepFailed };
|
||||
|
||||
// Board startup only, before the primary radio starts SPI.
|
||||
OnboardRadioState sleepOnboardRadio();
|
||||
|
||||
// IO owns the temporary SPI pin assignment; every outcome must release it.
|
||||
template <typename IO>
|
||||
OnboardRadioState sleepOnboardRadio(IO& io, const char* expectedVersion) {
|
||||
io.begin();
|
||||
io.reset();
|
||||
const auto state = [&]() {
|
||||
// A missing chip also times out: BUSY is pulled high until a radio drives it low.
|
||||
if (!io.waitBusy(false, 20)) return OnboardRadioState::BusyTimeout;
|
||||
|
||||
char version[6];
|
||||
io.readVersion(version);
|
||||
if (memcmp(version, expectedVersion, sizeof(version)) != 0) {
|
||||
return OnboardRadioState::Absent;
|
||||
}
|
||||
io.releaseProbePulls();
|
||||
if (!io.waitBusy(false, 20)) return OnboardRadioState::BusyTimeout;
|
||||
|
||||
io.sleep();
|
||||
// Reading over SPI here would wake the radio again. BUSY is a passive check.
|
||||
return io.waitBusy(true, 20) ? OnboardRadioState::Asleep : OnboardRadioState::SleepFailed;
|
||||
}();
|
||||
io.end();
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <Wire.h>
|
||||
|
||||
#include "RAK3401Board.h"
|
||||
#include "OnboardRadioSleep.h"
|
||||
|
||||
#ifdef NRF52_POWER_MANAGEMENT
|
||||
// Static configuration for power management
|
||||
@@ -30,6 +31,8 @@ void RAK3401Board::initiateShutdown(uint8_t reason) {
|
||||
|
||||
void RAK3401Board::begin() {
|
||||
NRF52BoardDCDC::begin();
|
||||
// Voltage protection can enter SYSTEMOFF before radio_init() is reached.
|
||||
rak3401::sleepOnboardRadio();
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
#ifdef PIN_USER_BTN
|
||||
pinMode(PIN_USER_BTN, INPUT_PULLUP);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include "OnboardRadioSleep.h"
|
||||
#include <nrf_gpio.h>
|
||||
|
||||
RAK3401Board board;
|
||||
|
||||
@@ -25,13 +27,100 @@ 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
|
||||
|
||||
namespace {
|
||||
class OnboardRadioIO {
|
||||
public:
|
||||
void begin() {
|
||||
digitalWrite(ONBOARD_LORA_NSS, HIGH);
|
||||
pinMode(ONBOARD_LORA_NSS, OUTPUT);
|
||||
digitalWrite(ONBOARD_LORA_RESET, HIGH);
|
||||
pinMode(ONBOARD_LORA_RESET, OUTPUT);
|
||||
digitalWrite(ONBOARD_LORA_ANT_SW, LOW);
|
||||
pinMode(ONBOARD_LORA_ANT_SW, OUTPUT);
|
||||
// BUSY is weakly pulled high during startup; never override it with a pull-down.
|
||||
pinMode(ONBOARD_LORA_BUSY, INPUT_PULLUP);
|
||||
SPI.setPins(ONBOARD_LORA_MISO, ONBOARD_LORA_SCLK, ONBOARD_LORA_MOSI);
|
||||
SPI.begin();
|
||||
pinMode(ONBOARD_LORA_MISO, INPUT_PULLDOWN);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
digitalWrite(ONBOARD_LORA_RESET, LOW);
|
||||
delay(1);
|
||||
digitalWrite(ONBOARD_LORA_RESET, HIGH);
|
||||
delay(5);
|
||||
}
|
||||
|
||||
bool waitBusy(bool high, uint32_t timeout) {
|
||||
uint32_t start = millis();
|
||||
while ((digitalRead(ONBOARD_LORA_BUSY) != LOW) != high) {
|
||||
if (millis() - start >= timeout) return false;
|
||||
delay(1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void readVersion(char* version) {
|
||||
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(ONBOARD_LORA_NSS, LOW);
|
||||
SPI.transfer(RADIOLIB_SX126X_CMD_READ_REGISTER);
|
||||
SPI.transfer(RADIOLIB_SX126X_REG_VERSION_STRING >> 8);
|
||||
SPI.transfer(RADIOLIB_SX126X_REG_VERSION_STRING & 0xFF);
|
||||
SPI.transfer(0);
|
||||
for (unsigned i = 0; i < 6; i++) version[i] = SPI.transfer(0);
|
||||
digitalWrite(ONBOARD_LORA_NSS, HIGH);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
void releaseProbePulls() {
|
||||
pinMode(ONBOARD_LORA_BUSY, INPUT);
|
||||
pinMode(ONBOARD_LORA_MISO, INPUT);
|
||||
}
|
||||
|
||||
void sleep() {
|
||||
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(ONBOARD_LORA_NSS, LOW);
|
||||
SPI.transfer(RADIOLIB_SX126X_CMD_SET_SLEEP);
|
||||
SPI.transfer(RADIOLIB_SX126X_SLEEP_START_COLD | RADIOLIB_SX126X_SLEEP_RTC_OFF);
|
||||
digitalWrite(ONBOARD_LORA_NSS, HIGH);
|
||||
SPI.endTransaction();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void end() {
|
||||
SPI.end();
|
||||
// INPUT leaves buffers enabled on floating pins; restore Nordic's disconnected default.
|
||||
nrf_gpio_cfg_default(g_ADigitalPinMap[ONBOARD_LORA_SCLK]);
|
||||
nrf_gpio_cfg_default(g_ADigitalPinMap[ONBOARD_LORA_MOSI]);
|
||||
nrf_gpio_cfg_default(g_ADigitalPinMap[ONBOARD_LORA_MISO]);
|
||||
nrf_gpio_cfg_default(g_ADigitalPinMap[ONBOARD_LORA_BUSY]);
|
||||
// An NSS falling edge wakes the radio, so leave it driven high.
|
||||
digitalWrite(ONBOARD_LORA_NSS, HIGH);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
rak3401::OnboardRadioState rak3401::sleepOnboardRadio() {
|
||||
OnboardRadioIO onboard;
|
||||
const uint32_t started = millis();
|
||||
// The SX1262 version register shares the "SX1261" prefix used by RadioLib.
|
||||
const auto state = rak3401::sleepOnboardRadio(onboard, RADIOLIB_SX1262_CHIP_TYPE);
|
||||
const char* outcome = state == rak3401::OnboardRadioState::Absent ? "absent" :
|
||||
state == rak3401::OnboardRadioState::Asleep ? "asleep" :
|
||||
state == rak3401::OnboardRadioState::BusyTimeout ? "busy-timeout" : "sleep-failed";
|
||||
MESH_DEBUG_PRINTLN("onboard SX1262: %s elapsed=%lu ms", outcome,
|
||||
(unsigned long)(millis() - started));
|
||||
return state;
|
||||
}
|
||||
|
||||
bool radio_init() {
|
||||
rtc_clock.begin(Wire);
|
||||
return radio.std_init(&SPI);
|
||||
@@ -41,4 +130,3 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
@@ -175,6 +175,16 @@ static const uint8_t AREF = PIN_AREF;
|
||||
#define P_LORA_BUSY SX126X_BUSY
|
||||
#define P_LORA_RESET SX126X_RESET
|
||||
|
||||
// Optional RAK4631 onboard radio; these internal pins are unused on RAK3401.
|
||||
#define ONBOARD_LORA_NSS (42) // P1.10
|
||||
#define ONBOARD_LORA_SCLK (43) // P1.11
|
||||
#define ONBOARD_LORA_MOSI (44) // P1.12
|
||||
#define ONBOARD_LORA_MISO (45) // P1.13
|
||||
#define ONBOARD_LORA_BUSY (46) // P1.14
|
||||
#define ONBOARD_LORA_DIO_1 (47) // P1.15
|
||||
#define ONBOARD_LORA_RESET (38) // P1.06
|
||||
#define ONBOARD_LORA_ANT_SW (37) // P1.05, powers the onboard RF switch
|
||||
|
||||
// enables 3.3V periphery like GPS or IO Module
|
||||
// Do not toggle this for GPS power savings
|
||||
#define PIN_3V3_EN (34)
|
||||
|
||||
@@ -55,6 +55,14 @@ 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 =
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ build_flags =
|
||||
-D PIN_USER_BTN=38
|
||||
-D PIN_GPS_RX=15
|
||||
-D PIN_GPS_TX=7
|
||||
-D GPS_BAUD_PROBE_LIST=9600,115200,38400 ; Grove UART GPS units (e.g. M5Stack Unit GPS v1.1) default to 115200
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ build_flags =
|
||||
-D PIN_USER_BTN=38
|
||||
-D PIN_GPS_RX=15
|
||||
-D PIN_GPS_TX=7
|
||||
-D GPS_BAUD_PROBE_LIST=9600,115200,38400 ; Grove UART GPS units (e.g. M5Stack Unit GPS v1.1) default to 115200
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
+13
-25
@@ -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,20 +82,11 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,8 +95,8 @@ void T1000SensorManager::stop_gps() {
|
||||
// biggest consumer on the node (46 mA measured), and a node that runs it only
|
||||
// to keep its RTC set does not need a continuous fix.
|
||||
//
|
||||
// The off-state is stop_gps(), which (since upstream merged the old sleep_gps()
|
||||
// into it) keeps GPS_VRTC_EN asserted and puts the AG3335 into RTC backup sleep,
|
||||
// The off-state is stop_gps(), which (AirohaGpsDriver::stop() since the upstream
|
||||
// GPS refactor) keeps GPS_VRTC_EN asserted and puts the AG3335 into RTC backup sleep,
|
||||
// so the receiver retains its almanac and the next window gets a warm fix
|
||||
// instead of a cold start every 30 minutes.
|
||||
void T1000SensorManager::gpsDutyLoop() {
|
||||
@@ -112,7 +104,7 @@ void T1000SensorManager::gpsDutyLoop() {
|
||||
|
||||
// int32_t deltas, so the 49-day millis() wrap does not park GPS on (or off)
|
||||
// forever.
|
||||
if (!gps_active) {
|
||||
if (!_nmea->isGpsOn()) {
|
||||
if ((int32_t)(millis() - gps_wake_at) >= 0) {
|
||||
start_gps();
|
||||
_nmea->syncTime(); // clears the parser + arms the sync request
|
||||
@@ -134,11 +126,7 @@ void T1000SensorManager::gpsDutyLoop() {
|
||||
}
|
||||
|
||||
bool T1000SensorManager::begin() {
|
||||
// init GPS
|
||||
Serial1.begin(115200);
|
||||
digitalWrite(GPS_RESET, HIGH);
|
||||
delay(10);
|
||||
digitalWrite(GPS_RESET, LOW);
|
||||
_gps_driver->initialize();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -161,7 +149,7 @@ void T1000SensorManager::loop() {
|
||||
gpsDutyLoop();
|
||||
|
||||
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;
|
||||
@@ -174,7 +162,7 @@ void T1000SensorManager::loop() {
|
||||
// with `gps on` the receiver is already up, and with `gps off` the user asked for
|
||||
// silence and a telemetry request must not override that.
|
||||
void T1000SensorManager::requestLocationRefresh() {
|
||||
if (gps_duty && !gps_active) {
|
||||
if (gps_duty && !_nmea->isGpsOn()) {
|
||||
gps_wake_at = millis();
|
||||
}
|
||||
}
|
||||
@@ -190,7 +178,7 @@ const char* T1000SensorManager::getSettingValue(int i) const {
|
||||
// between syncs is not the same thing as `gps off`, and something that
|
||||
// round-trips this value must not silently downgrade the mode.
|
||||
if (gps_duty) return "2";
|
||||
return gps_active ? "1" : "0";
|
||||
return _nmea->isGpsOn() ? "1" : "0";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@
|
||||
#include "NullDisplayDriver.h"
|
||||
#endif
|
||||
|
||||
class AirohaGpsDriver;
|
||||
|
||||
class T1000SensorManager: public SensorManager {
|
||||
bool gps_active = false;
|
||||
LocationProvider * _nmea;
|
||||
AirohaGpsDriver* _gps_driver;
|
||||
|
||||
// Duty-cycle state, mirroring EnvironmentSensorManager: `gps_duty` is the
|
||||
// MODE, `gps_active` stays the truth about the receiver's power right now.
|
||||
// MODE, the provider's isGpsOn() stays the truth about the receiver's power.
|
||||
// This board has its own manager, so the state machine cannot simply be
|
||||
// inherited -- see gpsDutyLoop() for the one T1000-specific difference.
|
||||
bool gps_duty = false;
|
||||
@@ -28,7 +30,8 @@ class T1000SensorManager: public SensorManager {
|
||||
void stop_gps();
|
||||
void gpsDutyLoop();
|
||||
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;
|
||||
|
||||
@@ -117,6 +117,8 @@
|
||||
#define GPS_RTC_INT (15) // P0.15
|
||||
#define GPS_RESETB (46) // P1.14
|
||||
|
||||
#define GPS_BAUDRATE 115200
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Temp+Lux Sensor
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ build_flags = ${nrf52_base.build_flags}
|
||||
-D AUTO_OFF_MILLIS=300000 ; 5 minutes
|
||||
-D UI_NO_HIBERNATE
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
-D EINK_REFRESH_LOOP
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<ThinkNodeM1Board.cpp>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
#include <helpers/sensors/NmeaGpsDriver.h>
|
||||
|
||||
ThinkNodeM1Board board;
|
||||
|
||||
@@ -11,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 = MicroNMEALocationProvider(gps_driver, &rtc_clock);
|
||||
ThinkNodeM1SensorManager sensors = ThinkNodeM1SensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
@@ -31,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;
|
||||
}
|
||||
|
||||
@@ -71,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;
|
||||
@@ -120,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;
|
||||
}
|
||||
@@ -136,4 +94,3 @@ bool ThinkNodeM1SensorManager::setSettingValue(const char* name, const char* val
|
||||
}
|
||||
return false; // not supported
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#endif
|
||||
|
||||
class ThinkNodeM1SensorManager : public SensorManager {
|
||||
bool gps_active = false;
|
||||
bool last_gps_switch_state = false;
|
||||
LocationProvider* _location;
|
||||
|
||||
void start_gps();
|
||||
@@ -45,4 +43,3 @@ extern ThinkNodeM1SensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
||||
@@ -146,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)
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -44,6 +44,7 @@ build_flags = ${esp32_base.build_flags}
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D PERSISTANT_GPS=1
|
||||
-D ENV_SKIP_GPS_DETECT=1
|
||||
-D EINK_REFRESH_LOOP
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
|
||||
@@ -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();
|
||||
@@ -46,5 +47,3 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ build_flags = ${nrf52_base.build_flags}
|
||||
-D EINK_SCALE_X=1.5625f
|
||||
-D EINK_SCALE_Y=1.5625f
|
||||
-D EINK_X_OFFSET=0
|
||||
-D EINK_Y_OFFSET=10
|
||||
-D EINK_Y_OFFSET=10
|
||||
-D EINK_REFRESH_LOOP
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
-D SX126X_POWER_EN=37
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -11,7 +11,8 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
#ifdef 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 = EnvironmentSensorManager();
|
||||
|
||||
@@ -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();
|
||||
@@ -37,4 +38,3 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ build_flags = ${nrf52_base.build_flags}
|
||||
-D GPS_BAUD_RATE=9600
|
||||
-D ENV_PIN_SDA=PIN_WIRE1_SDA
|
||||
-D ENV_PIN_SCL=PIN_WIRE1_SCL
|
||||
-D EINK_REFRESH_LOOP
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<WioTrackerL1Board.cpp>
|
||||
+<../variants/wio-tracker-l1>
|
||||
@@ -69,6 +70,21 @@ lib_deps = ${WioTrackerL1Eink.lib_deps}
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
debug_tool=stlink
|
||||
|
||||
[env:WioTrackerL1Eink_repeater]
|
||||
extends = WioTrackerL1Eink
|
||||
build_src_filter = ${WioTrackerL1Eink.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
build_flags =
|
||||
${WioTrackerL1Eink.build_flags}
|
||||
-D ADVERT_NAME='"WioTrackerL1 Eink Repeater"'
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
-D DISPLAY_CLASS=GxEPDDisplay
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps = ${WioTrackerL1Eink.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
|
||||
[env:WioTrackerL1Eink_kiss_modem]
|
||||
extends = WioTrackerL1Eink
|
||||
build_src_filter = ${WioTrackerL1Eink.build_src_filter}
|
||||
|
||||
@@ -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();
|
||||
@@ -37,4 +38,3 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -39,4 +40,3 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user