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
@@ -1008,6 +1008,8 @@ void MyMesh::begin() {
|
||||
_prefs.tx_power_dbm = constrain(_prefs.tx_power_dbm, -9, MAX_LORA_TX_POWER);
|
||||
_prefs.gps_enabled = constrain(_prefs.gps_enabled, 0, 2); // 0 off, 1 on, 2 duty cycle
|
||||
_prefs.gps_interval = constrain(_prefs.gps_interval, 0, 86400); // Max 24 hours
|
||||
_prefs.adc_multiplier = constrain(_prefs.adc_multiplier, 0.0f, 10.0f);
|
||||
if (!board.setAdcMultiplier(_prefs.adc_multiplier)) _prefs.adc_multiplier = 0.0f;
|
||||
|
||||
_active_ble_pin = _prefs.ble_pin;
|
||||
|
||||
@@ -2136,6 +2138,11 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_prefs.getGpsPrefs()->handleCommand(command, sensors, reply)) {
|
||||
if (_prefs.getGpsPrefs()->isDirty()) { savePrefs(); }
|
||||
return true;
|
||||
}
|
||||
|
||||
// hook for variant-specific CLI processing
|
||||
if (board.handleCommand(command, sender_timestamp, reply)) {
|
||||
if (_prefs.isDirty()) { savePrefs(); }
|
||||
@@ -2266,6 +2273,33 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
||||
return true;
|
||||
}
|
||||
|
||||
if (memcmp(command, "set adc.multiplier ", 19) == 0) { // same as CommonCLI
|
||||
float mult = atof(&command[19]);
|
||||
if (mult < 0.0f || mult > 10.0f) {
|
||||
strcpy(reply, "Error, must be from 0 to 10");
|
||||
} else if (board.setAdcMultiplier(mult)) {
|
||||
_prefs.adc_multiplier = mult;
|
||||
savePrefs();
|
||||
if (mult == 0.0f) {
|
||||
strcpy(reply, "OK - using default board multiplier");
|
||||
} else {
|
||||
sprintf(reply, "OK - multiplier set to %.3f", mult);
|
||||
}
|
||||
} else {
|
||||
strcpy(reply, "Error: unsupported");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (strcmp(command, "get adc.multiplier") == 0) {
|
||||
float mult = board.getAdcMultiplier();
|
||||
if (mult == 0.0f) {
|
||||
strcpy(reply, "Error: unsupported");
|
||||
} else {
|
||||
sprintf(reply, "> %.3f", mult);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcmp(command, "get tz.offset") == 0) {
|
||||
float q = _prefs.tz_offset * 4;
|
||||
sprintf(reply, (q == (int)q && ((int)q & 1)) ? "> %.2f" : "> %.1f", _prefs.tz_offset);
|
||||
@@ -2342,6 +2376,18 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
||||
sprintf(reply, "> ui.nd_name is now %d", _prefs.ui_nd_name);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ui.gps_action", 17) == 0) {
|
||||
const char* v = &command[17];
|
||||
while (*v == ' ') v++;
|
||||
_prefs.ui_gps_action = (memcmp(v, "once", 4) == 0 || memcmp(v, "trigger", 7) == 0 || *v == '1') ? 1 : 0; // anything else: toggle
|
||||
savePrefs();
|
||||
sprintf(reply, "> now %s", _prefs.ui_gps_action ? "once" : "toggle");
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.gps_action", 17) == 0) {
|
||||
sprintf(reply, "> %s", _prefs.ui_gps_action ? "once" : "toggle");
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "get ui.show_clock", 17) == 0) {
|
||||
sprintf(reply, "> %d", _prefs.ui_show_clock);
|
||||
return true;
|
||||
|
||||
@@ -208,13 +208,16 @@ public:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
// 0 off / 1 on / 2 duty cycle (see EnvironmentSensorManager::gpsDutyLoop)
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled == 2 ? "2" : (_prefs.gps_enabled ? "1" : "0"));
|
||||
if (_prefs.gps_interval > 0) {
|
||||
char interval_str[12]; // Max: 24 hours = 86400 seconds (5 digits + null)
|
||||
sprintf(interval_str, "%u", _prefs.gps_interval);
|
||||
sensors.setSettingValue("gps_interval", interval_str);
|
||||
if (_prefs.gps_interval > 0 &&
|
||||
sensors.getSettingByKey("gps_interval") != nullptr) {
|
||||
char interval[11];
|
||||
snprintf(interval, sizeof(interval), "%lu", (unsigned long)_prefs.gps_interval);
|
||||
sensors.setSettingValue("gps_interval", interval);
|
||||
}
|
||||
_prefs.getGpsPrefs()->apply(sensors);
|
||||
// 2 = duty cycle (see EnvironmentSensorManager::gpsDutyLoop); apply() only
|
||||
// knows on/off, so switch the sensor manager into duty after it
|
||||
if (_prefs.gps_enabled == 2) sensors.setSettingValue("gps", "2");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <cstdint> // For uint8_t, uint32_t
|
||||
#include <helpers/ConfigSerializer.h>
|
||||
#include <helpers/CommonRadioPrefs.h>
|
||||
#include <helpers/CommonGpsPrefs.h>
|
||||
#include <helpers/DynamicConfigSerializer.h>
|
||||
|
||||
#define TELEM_MODE_DENY 0
|
||||
@@ -35,6 +36,9 @@ public:
|
||||
uint8_t vibe_quiet = 0;
|
||||
uint8_t gps_enabled = 0; // GPS enabled flag (0=disabled, 1=enabled)
|
||||
uint32_t gps_interval = 0; // GPS read interval in seconds
|
||||
uint32_t gps_period = 0; // periodic acquisition interval in seconds
|
||||
int32_t gps_fence = -1; // GPS_GUARD fence in metres, 0 = off, -1 = build default
|
||||
uint8_t gps_guard = 1; // GPS_GUARD on/off
|
||||
uint8_t autoadd_config = 0; // bitmask for auto-add contacts config
|
||||
uint8_t rx_boosted_gain = 0; // SX126x RX boosted gain mode (0=power saving, 1=boosted)
|
||||
uint8_t radio_fem_rxgain = 0; // external LoRa FEM RX gain (LNA)
|
||||
@@ -48,6 +52,7 @@ public:
|
||||
char default_scope_name[31];
|
||||
uint8_t default_scope_key[16];
|
||||
float tz_offset = 0;
|
||||
float adc_multiplier = 0; // battery ADC multiplier, 0 = board default
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
#ifndef WIFI_SSID
|
||||
#define WIFI_SSID ""
|
||||
@@ -85,6 +90,11 @@ public:
|
||||
uint8_t ui_auto_off_keep_msgs = 1;
|
||||
uint8_t ui_max_partial = EINK_MAX_PARTIAL_REFRESH;
|
||||
uint8_t ui_nd_name = 1;
|
||||
#ifdef PIN_GPS_SWITCH
|
||||
uint8_t ui_gps_action = 1;
|
||||
#else
|
||||
uint8_t ui_gps_action = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
private:
|
||||
@@ -151,16 +161,36 @@ private:
|
||||
};
|
||||
RadioPrefs radio;
|
||||
|
||||
class GPSPrefs : public ConfigSerializer { // COPIED from CommonCLI (for now)
|
||||
class GPSPrefs : public CommonGpsPrefs {
|
||||
NodePrefs* _parent;
|
||||
protected:
|
||||
void structure() override {
|
||||
def("en", _parent->gps_enabled); // boolean
|
||||
def("int", _parent->gps_interval); // interval in seconds
|
||||
def("period", _parent->gps_period); // periodic acquisition interval in seconds
|
||||
def("adv_loc", _parent->advert_loc_policy);
|
||||
#ifdef GPS_GUARD
|
||||
def("fence", _parent->gps_fence);
|
||||
def("guard", _parent->gps_guard);
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
GPSPrefs(NodePrefs* parent) : _parent(parent) { }
|
||||
bool isGpsEnabled() const override { return _parent->gps_enabled; }
|
||||
void setGpsEnabled(bool enabled) override { _parent->gps_enabled = enabled; markDirty(); }
|
||||
uint32_t getGpsPeriod() const override { return _parent->gps_period; }
|
||||
void setGpsPeriod(uint32_t seconds) override { _parent->gps_period = seconds; markDirty(); }
|
||||
bool getGuardFence(uint32_t& metres) const override {
|
||||
if (_parent->gps_fence < 0) return false;
|
||||
metres = (uint32_t)_parent->gps_fence;
|
||||
return true;
|
||||
}
|
||||
void setGuardFence(uint32_t metres) override { _parent->gps_fence = (int32_t)metres; markDirty(); }
|
||||
bool getGuardEnabled(bool& enabled) const override {
|
||||
enabled = _parent->gps_guard != 0;
|
||||
return true;
|
||||
}
|
||||
void setGuardEnabled(bool enabled) override { _parent->gps_guard = enabled ? 1 : 0; markDirty(); }
|
||||
};
|
||||
GPSPrefs gps;
|
||||
|
||||
@@ -194,6 +224,7 @@ private:
|
||||
def("tel_loc", _parent->telemetry_mode_loc);
|
||||
def("tel_env", _parent->telemetry_mode_env);
|
||||
def("tz_offset", _parent->tz_offset);
|
||||
def("adc_mult", _parent->adc_multiplier);
|
||||
}
|
||||
public:
|
||||
CompanionPrefs(NodePrefs* parent) : _parent(parent) { }
|
||||
@@ -231,6 +262,7 @@ private:
|
||||
def("off_blank", _parent->ui_auto_off_blank);
|
||||
def("off_keep_msgs", _parent->ui_auto_off_keep_msgs);
|
||||
def("nd_name", _parent->ui_nd_name);
|
||||
def("gps_act", _parent->ui_gps_action);
|
||||
}
|
||||
public:
|
||||
UI_Prefs(NodePrefs* parent) : _parent(parent) {}
|
||||
@@ -275,8 +307,9 @@ public:
|
||||
void setRepeatEn(bool en) { repeat.disable_fwd = en ? 0 : 1; }
|
||||
|
||||
CommonRadioPrefs* getRadioPrefs() { return &radio; }
|
||||
CommonGpsPrefs* getGpsPrefs() { return &gps; }
|
||||
KeyValueStore* getCustom() { return &custom; }
|
||||
|
||||
bool isDirty() const override { return ConfigSerializer::isDirty() || radio.isDirty() || custom.isDirty(); }
|
||||
void clearDirty() override { ConfigSerializer::clearDirty(); radio.clearDirty(); custom.clearDirty(); }
|
||||
bool isDirty() const override { return ConfigSerializer::isDirty() || radio.isDirty() || gps.isDirty() || custom.isDirty(); }
|
||||
void clearDirty() override { ConfigSerializer::clearDirty(); radio.clearDirty(); gps.clearDirty(); custom.clearDirty(); }
|
||||
};
|
||||
@@ -2,6 +2,11 @@
|
||||
#include <Mesh.h>
|
||||
#include "MyMesh.h"
|
||||
|
||||
#if defined(ENABLE_WIFI_INTERFACE) && defined(ENABLE_ESP_MDNS)
|
||||
#define HAS_ESP_MDNS
|
||||
#include <ESPmDNS.h>
|
||||
#endif
|
||||
|
||||
// Believe it or not, this std C function is busted on some platforms!
|
||||
static uint32_t _atoi(const char* sp) {
|
||||
uint32_t n = 0;
|
||||
@@ -132,6 +137,10 @@ void halt() {
|
||||
bool wifi_enabled = false; // set at boot from prefs; false also when the effective SSID is blank
|
||||
#endif
|
||||
|
||||
#if defined(DISPLAY_CLASS) && defined(EINK_REFRESH_LOOP)
|
||||
static void loopDuringDisplayRefresh();
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
board.begin();
|
||||
@@ -266,6 +275,36 @@ void setup() {
|
||||
interface_manager.addInterface(InterfaceType::Ethernet, ðernet_interface);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_ESP_MDNS
|
||||
const char* nodeName = the_mesh.getNodeName();
|
||||
|
||||
// "meshcore_" prefix + sanitized node name, capped at 63 chars (max DNS label length)
|
||||
char mdnsName[64];
|
||||
const size_t prefixLen = snprintf(mdnsName, sizeof(mdnsName), "meshcore_");
|
||||
size_t pos = prefixLen;
|
||||
for (size_t i = 0; nodeName[i] != '\0' && pos < sizeof(mdnsName) - 1; ++i) {
|
||||
const char c = nodeName[i];
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') || c == '-' || c == '_') {
|
||||
mdnsName[pos++] = c;
|
||||
}
|
||||
}
|
||||
mdnsName[pos] = '\0';
|
||||
|
||||
if (!MDNS.begin(mdnsName)) {
|
||||
WIFI_DEBUG_PRINTLN("mDNS failed to start!");
|
||||
} else {
|
||||
MDNS.addService("meshcore", "tcp", TCP_PORT);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "node-name", nodeName);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "firmware-version", FIRMWARE_VERSION);
|
||||
char protocol[12];
|
||||
snprintf(protocol, sizeof(protocol), "%d", (int)FIRMWARE_VER_CODE);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "protocol-version", (const char*)protocol);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "build-date", __DATE__);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "build-time", __TIME__);
|
||||
}
|
||||
#endif
|
||||
|
||||
// add hardware serial interface
|
||||
#if defined(SERIAL_RX)
|
||||
companion_serial.setPins(SERIAL_RX, SERIAL_TX);
|
||||
@@ -284,15 +323,36 @@ void setup() {
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
|
||||
the_mesh.setListener(&ui_task);
|
||||
#ifdef EINK_REFRESH_LOOP
|
||||
if (disp != NULL) disp->setBusyHook(loopDuringDisplayRefresh);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
board.onBootComplete();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Work that must keep running even while the UI is blocked (e.g. by an e-ink refresh).
|
||||
// Called from loop() and from the display busy hook, so both always run the same set.
|
||||
static void loopCore() {
|
||||
the_mesh.loop();
|
||||
interface_manager.loop();
|
||||
sensors.loop();
|
||||
}
|
||||
|
||||
#if defined(DISPLAY_CLASS) && defined(EINK_REFRESH_LOOP)
|
||||
// Runs from inside the e-ink busy wait, so radio/BLE/sensors keep going during a panel refresh.
|
||||
// Must not touch the display: UI listener callbacks only update state and schedule the next frame.
|
||||
static void loopDuringDisplayRefresh() {
|
||||
static bool active = false;
|
||||
if (active) return;
|
||||
active = true;
|
||||
loopCore();
|
||||
active = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void loop() {
|
||||
loopCore();
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.loop();
|
||||
#endif
|
||||
|
||||
@@ -86,6 +86,30 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
// exact period with the largest unit that divides it: "30s", "5m", "2h"
|
||||
static void formatGpsPeriod(char* buf, size_t size, uint32_t seconds) {
|
||||
if (seconds % 3600 == 0) {
|
||||
snprintf(buf, size, "%luh", (unsigned long)(seconds / 3600));
|
||||
} else if (seconds % 60 == 0) {
|
||||
snprintf(buf, size, "%lum", (unsigned long)(seconds / 60));
|
||||
} else {
|
||||
snprintf(buf, size, "%lus", (unsigned long)seconds);
|
||||
}
|
||||
}
|
||||
|
||||
// age of the last fix, rounded down to a single unit: "45s", "12m", "3h"
|
||||
static void formatFixAge(char* buf, size_t size, uint32_t seconds) {
|
||||
if (seconds < 60) {
|
||||
snprintf(buf, size, "%lus", (unsigned long)seconds);
|
||||
} else if (seconds < 3600) {
|
||||
snprintf(buf, size, "%lum", (unsigned long)(seconds / 60));
|
||||
} else {
|
||||
snprintf(buf, size, "%luh", (unsigned long)(seconds / 3600));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class HomeScreen : public UIScreen {
|
||||
enum HomePage {
|
||||
FIRST,
|
||||
@@ -394,16 +418,28 @@ public:
|
||||
char buf[50];
|
||||
int y = 18;
|
||||
bool gps_state = _task->getGPSState();
|
||||
#ifdef PIN_GPS_SWITCH
|
||||
bool hw_gps_state = digitalRead(PIN_GPS_SWITCH);
|
||||
if (gps_state != hw_gps_state) {
|
||||
strcpy(buf, gps_state ? "gps off(hw)" : "gps off(sw)");
|
||||
} else {
|
||||
strcpy(buf, gps_state ? "gps on" : "gps off");
|
||||
bool hw_gps_state = nmea != NULL && nmea->isHardwareEnabled();
|
||||
uint32_t period = nmea != NULL ? nmea->getGpsPeriod() : 0;
|
||||
char fix_buf[12] = "";
|
||||
if (nmea != NULL) {
|
||||
uint32_t fix_age = nmea->getLastFixAge();
|
||||
if (fix_age == UINT32_MAX) {
|
||||
strcpy(fix_buf, "no fix");
|
||||
} else {
|
||||
formatFixAge(fix_buf, sizeof(fix_buf), fix_age);
|
||||
}
|
||||
}
|
||||
if (nmea != NULL && nmea->hasHardwareEnableState() && gps_state != hw_gps_state) {
|
||||
strcpy(buf, gps_state ? "gps off(hw)" : "gps off(sw)");
|
||||
} else if (!gps_state) {
|
||||
strcpy(buf, "gps off");
|
||||
} else if (period == 0) {
|
||||
strcpy(buf, "gps on");
|
||||
} else {
|
||||
char per[12];
|
||||
formatGpsPeriod(per, sizeof(per), period);
|
||||
snprintf(buf, sizeof(buf), "%s (%s)", nmea != NULL && nmea->isActive() ? "active" : "sleep", per);
|
||||
}
|
||||
#else
|
||||
strcpy(buf, gps_state ? "gps on" : "gps off");
|
||||
#endif
|
||||
display.setColor(UIColor::primary_txt);
|
||||
display.drawTextLeftAlign(0, y, buf);
|
||||
if (nmea == NULL) {
|
||||
@@ -412,8 +448,7 @@ public:
|
||||
display.drawTextLeftAlign(0, y, "Can't access GPS");
|
||||
} else {
|
||||
display.setColor(UIColor::primary_txt);
|
||||
strcpy(buf, nmea->isValid()?"fix":"no fix");
|
||||
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||
display.drawTextRightAlign(display.width()-1, y, fix_buf);
|
||||
y = y + 12;
|
||||
display.setColor(UIColor::secondary_txt);
|
||||
display.drawTextLeftAlign(0, y, "sat");
|
||||
@@ -599,7 +634,7 @@ public:
|
||||
}
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
if (c == KEY_ENTER && _page == HomePage::GPS) {
|
||||
_task->toggleGPS();
|
||||
if (_node_prefs->ui_gps_action == 1) _task->triggerGPS(); else _task->toggleGPS();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -1184,16 +1219,14 @@ void UITask::toggleGPS() {
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (strcmp(_sensors->getSettingName(i), "gps") == 0) {
|
||||
if (strcmp(_sensors->getSettingValue(i), "1") == 0) {
|
||||
_sensors->setSettingValue("gps", "0");
|
||||
_node_prefs->gps_enabled = 0;
|
||||
_node_prefs->getGpsPrefs()->setGpsEnabled(*_sensors, false);
|
||||
notify(UIEventType::ack);
|
||||
} else {
|
||||
_sensors->setSettingValue("gps", "1");
|
||||
_node_prefs->gps_enabled = 1;
|
||||
_node_prefs->getGpsPrefs()->setGpsEnabled(*_sensors, true);
|
||||
notify(UIEventType::ack);
|
||||
}
|
||||
the_mesh.savePrefs();
|
||||
showAlert(_node_prefs->gps_enabled ? "GPS: Enabled" : "GPS: Disabled", 800);
|
||||
showAlert(_node_prefs->getGpsPrefs()->isGpsEnabled() ? "GPS: Enabled" : "GPS: Disabled", 800);
|
||||
_next_refresh = 0;
|
||||
break;
|
||||
}
|
||||
@@ -1201,6 +1234,15 @@ void UITask::toggleGPS() {
|
||||
}
|
||||
}
|
||||
|
||||
void UITask::triggerGPS() {
|
||||
LocationProvider* location = _sensors != NULL ? _sensors->getLocationProvider() : NULL;
|
||||
if (location != NULL && !(location->hasHardwareEnableState() && !location->isHardwareEnabled())
|
||||
&& location->startOnce()) {
|
||||
notify(UIEventType::ack);
|
||||
}
|
||||
_next_refresh = 0;
|
||||
}
|
||||
|
||||
void UITask::toggleBuzzer() {
|
||||
// Toggle buzzer quiet mode
|
||||
#ifdef PIN_BUZZER
|
||||
|
||||
@@ -114,6 +114,7 @@ public:
|
||||
void toggleBuzzer();
|
||||
bool getGPSState();
|
||||
void toggleGPS();
|
||||
void triggerGPS();
|
||||
|
||||
// MyMesh::Listener
|
||||
void onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, const char* text) override;
|
||||
|
||||
@@ -609,14 +609,15 @@ void UITask::handleButtonQuadruplePress() {
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (strcmp(_sensors->getSettingName(i), "gps") == 0) {
|
||||
if (strcmp(_sensors->getSettingValue(i), "1") == 0) {
|
||||
_sensors->setSettingValue("gps", "0");
|
||||
_node_prefs->getGpsPrefs()->setGpsEnabled(*_sensors, false);
|
||||
notify(UIEventType::ack);
|
||||
sprintf(_alert, "GPS: Disabled");
|
||||
} else {
|
||||
_sensors->setSettingValue("gps", "1");
|
||||
_node_prefs->getGpsPrefs()->setGpsEnabled(*_sensors, true);
|
||||
notify(UIEventType::ack);
|
||||
sprintf(_alert, "GPS: Enabled");
|
||||
}
|
||||
the_mesh.savePrefs();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,16 +254,16 @@ public:
|
||||
char buf[50];
|
||||
int y = 8;
|
||||
bool gps_state = _task->getGPSState();
|
||||
#ifdef PIN_GPS_SWITCH
|
||||
bool hw_gps_state = digitalRead(PIN_GPS_SWITCH);
|
||||
bool hw_gps_state = nmea != NULL && nmea->isHardwareEnabled();
|
||||
if (nmea != NULL && nmea->hasHardwareEnableState()) {
|
||||
if (gps_state != hw_gps_state) {
|
||||
strcpy(buf, gps_state ? "gps off(hw)" : "gps off(sw)");
|
||||
} else {
|
||||
strcpy(buf, gps_state ? "gps on" : "gps off");
|
||||
}
|
||||
#else
|
||||
} else {
|
||||
strcpy(buf, gps_state ? "gps on" : "gps off");
|
||||
#endif
|
||||
}
|
||||
display.setColor(UIColor::primary_txt);
|
||||
display.drawTextLeftAlign(0, y, buf);
|
||||
if (nmea == NULL) {
|
||||
@@ -833,16 +833,14 @@ void UITask::toggleGPS() {
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (strcmp(_sensors->getSettingName(i), "gps") == 0) {
|
||||
if (strcmp(_sensors->getSettingValue(i), "1") == 0) {
|
||||
_sensors->setSettingValue("gps", "0");
|
||||
_node_prefs->gps_enabled = 0;
|
||||
_node_prefs->getGpsPrefs()->setGpsEnabled(*_sensors, false);
|
||||
notify(UIEventType::ack);
|
||||
} else {
|
||||
_sensors->setSettingValue("gps", "1");
|
||||
_node_prefs->gps_enabled = 1;
|
||||
_node_prefs->getGpsPrefs()->setGpsEnabled(*_sensors, true);
|
||||
notify(UIEventType::ack);
|
||||
}
|
||||
the_mesh.savePrefs();
|
||||
showAlert(_node_prefs->gps_enabled ? "GPS: Enabled" : "GPS: Disabled", 800);
|
||||
showAlert(_node_prefs->getGpsPrefs()->isGpsEnabled() ? "GPS: Enabled" : "GPS: Disabled", 800);
|
||||
_next_refresh = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1167,7 +1167,8 @@ void MyMesh::onPeerDataRecv(mesh::Packet *packet, uint8_t type, int sender_idx,
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t temp[166];
|
||||
// 5-byte datagram header + 3-byte reflected CLI prefix + 160-byte reply text + NUL
|
||||
uint8_t temp[169];
|
||||
char *command = (char *)&data[5];
|
||||
char *reply = (char *)&temp[5];
|
||||
if (is_retry) {
|
||||
|
||||
@@ -415,10 +415,17 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
// 0 off / 1 on / 2 duty cycle -- pass the mode through, not a boolean, or
|
||||
// a duty-cycled node comes back from a reboot with GPS powered forever.
|
||||
const char* mode = _prefs.gps_enabled == 2 ? "2" : (_prefs.gps_enabled ? "1" : "0");
|
||||
sensors.setSettingValue("gps", mode);
|
||||
if (sensors.getSettingByKey("gps_interval") != nullptr) {
|
||||
// gps_interval was introduced only for EnvironmentSensorManager
|
||||
// and has little interest ... kept only as a legacy
|
||||
char interval[11];
|
||||
snprintf(interval, sizeof(interval), "%lu", (unsigned long)_prefs.gps_interval);
|
||||
sensors.setSettingValue("gps_interval", interval);
|
||||
}
|
||||
_prefs.getGpsPrefs()->apply(sensors);
|
||||
// 2 = duty cycle -- apply() only knows on/off, and a duty-cycled node must
|
||||
// not come back from a reboot with GPS powered forever
|
||||
if (_prefs.gps_enabled == 2) sensors.setSettingValue("gps", "2");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ mesh::Packet *MyMesh::createSelfAdvert() {
|
||||
}
|
||||
|
||||
File MyMesh::openAppend(const char *fname) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
return _fs->open(fname, FILE_O_WRITE);
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
return _fs->open(fname, "a");
|
||||
@@ -462,7 +462,8 @@ void MyMesh::onPeerDataRecv(mesh::Packet *packet, uint8_t type, int sender_idx,
|
||||
mesh::Utils::sha256((uint8_t *)&ack_hash, 4, data, 5 + strlen((char *)&data[5]), client->id.pub_key,
|
||||
PUB_KEY_SIZE);
|
||||
|
||||
uint8_t temp[166];
|
||||
// 5-byte datagram header + 3-byte reflected CLI prefix + 160-byte reply text + NUL
|
||||
uint8_t temp[169];
|
||||
bool send_ack;
|
||||
if (flags == TXT_TYPE_CLI_DATA || flags == TXT_TYPE_CLI_COMMAND) {
|
||||
if (client->isAdmin()) {
|
||||
@@ -791,7 +792,7 @@ void MyMesh::applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr,
|
||||
}
|
||||
|
||||
bool MyMesh::formatFileSystem() {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
return InternalFS.format();
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
return LittleFS.format();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <Arduino.h> // needed for PlatformIO
|
||||
#include <Mesh.h>
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
#include <InternalFileSystem.h>
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
#include <LittleFS.h>
|
||||
@@ -173,7 +173,14 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
if (sensors.getSettingByKey("gps_interval") != nullptr) {
|
||||
// gps_interval was introduced only for EnvironmentSensorManager
|
||||
// and has little interest ... kept only as a legacy
|
||||
char interval[11];
|
||||
snprintf(interval, sizeof(interval), "%lu", (unsigned long)_prefs.gps_interval);
|
||||
sensors.setSettingValue("gps_interval", interval);
|
||||
}
|
||||
_prefs.getGpsPrefs()->apply(sensors);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ void setup() {
|
||||
fast_rng.begin(radio_driver.getRngSeed());
|
||||
|
||||
FILESYSTEM* fs;
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
InternalFS.begin();
|
||||
fs = &InternalFS;
|
||||
IdentityStore store(InternalFS, "");
|
||||
|
||||
@@ -671,7 +671,8 @@ void SensorMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_i
|
||||
// len can be > original length, but 'text' will be padded with zeroes
|
||||
data[len] = 0; // need to make a C string again, with null terminator
|
||||
|
||||
uint8_t temp[166];
|
||||
// 5-byte datagram header + 3-byte reflected CLI prefix + 160-byte reply text + NUL
|
||||
uint8_t temp[169];
|
||||
char *command = (char *) &data[5];
|
||||
char *reply = (char *) &temp[5];
|
||||
handleCommand(from, sender_timestamp, command, reply);
|
||||
|
||||
@@ -178,7 +178,12 @@ private:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
if (sensors.getSettingByKey("gps_interval") != nullptr) {
|
||||
char interval[11];
|
||||
snprintf(interval, sizeof(interval), "%lu", (unsigned long)_prefs.gps_interval);
|
||||
sensors.setSettingValue("gps_interval", interval);
|
||||
}
|
||||
_prefs.getGpsPrefs()->apply(sensors);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
Reference in new issue
Block a user