mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-11-22 14:07:05 +00:00
gps: move the gps CLI to GpsPrefs and convert all targets
This commit is contained in:
1 parent
df5a768c5d
commit
fe6a47d0c9
69 files changed
+381
-301
No files matched your search
@@ -2093,6 +2093,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(); }
|
||||
|
||||
@@ -203,12 +203,13 @@ public:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
sensors.setSettingValue("gps", _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);
|
||||
}
|
||||
#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,7 @@ 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
|
||||
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)
|
||||
@@ -151,16 +153,21 @@ 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);
|
||||
}
|
||||
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(); }
|
||||
};
|
||||
GPSPrefs gps;
|
||||
|
||||
@@ -275,8 +282,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(); }
|
||||
};
|
||||
@@ -1182,16 +1182,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -159,10 +159,14 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
char period[11];
|
||||
snprintf(period, sizeof(period), "%lu", (unsigned long)_prefs.gps_period);
|
||||
sensors.setSettingValue("gps_period", period);
|
||||
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
|
||||
|
||||
|
||||
@@ -168,10 +168,14 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
char period[11];
|
||||
snprintf(period, sizeof(period), "%lu", (unsigned long)_prefs.gps_period);
|
||||
sensors.setSettingValue("gps_period", period);
|
||||
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
|
||||
|
||||
|
||||
@@ -173,10 +173,12 @@ private:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
char period[11];
|
||||
snprintf(period, sizeof(period), "%lu", (unsigned long)_prefs.gps_period);
|
||||
sensors.setSettingValue("gps_period", period);
|
||||
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
|
||||
};
|
||||
@@ -349,65 +349,11 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
*(dp-1) = 0; // remove last CR
|
||||
}
|
||||
}
|
||||
} else if (_prefs->getGpsPrefs()->handleCommand(command, *_sensors, reply)) {
|
||||
if (_prefs->getGpsPrefs()->isDirty()) savePrefs();
|
||||
} else if (memcmp(command, "region", 6) == 0) {
|
||||
handleRegionCmd(command, reply);
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
} else if (memcmp(command, "gps on", 6) == 0) {
|
||||
if (_sensors->setSettingValue("gps", "1")) {
|
||||
_prefs->gps_enabled = 1;
|
||||
savePrefs();
|
||||
strcpy(reply, "ok");
|
||||
} else {
|
||||
strcpy(reply, "gps toggle not found");
|
||||
}
|
||||
} else if (memcmp(command, "gps off", 7) == 0) {
|
||||
if (_sensors->setSettingValue("gps", "0")) {
|
||||
_prefs->gps_enabled = 0;
|
||||
savePrefs();
|
||||
strcpy(reply, "ok");
|
||||
} else {
|
||||
strcpy(reply, "gps toggle not found");
|
||||
}
|
||||
} else if (memcmp(command, "gps period ", 11) == 0) {
|
||||
char* end = nullptr;
|
||||
unsigned long period = strtoul(command + 11, &end, 10);
|
||||
if (command[11] == '\0' || *end != '\0' || period > 86400) {
|
||||
strcpy(reply, "gps period must be 0-86400 seconds");
|
||||
} else {
|
||||
char period_value[11];
|
||||
snprintf(period_value, sizeof(period_value), "%lu", period);
|
||||
if (_sensors->setSettingValue("gps_period", period_value) &&
|
||||
_sensors->setSettingValue("gps", "1")) {
|
||||
_prefs->gps_period = (uint32_t)period;
|
||||
_prefs->gps_enabled = 1;
|
||||
savePrefs();
|
||||
strcpy(reply, "ok");
|
||||
} else {
|
||||
strcpy(reply, "gps provider not found");
|
||||
}
|
||||
}
|
||||
} else if (memcmp(command, "gps sync", 8) == 0) {
|
||||
LocationProvider * l = _sensors->getLocationProvider();
|
||||
if (l != NULL) {
|
||||
l->syncTime();
|
||||
strcpy(reply, "ok");
|
||||
} else {
|
||||
strcpy(reply, "gps provider not found");
|
||||
}
|
||||
} else if (strcmp(command, "gps diag") == 0) {
|
||||
LocationProvider * l = _sensors->getLocationProvider();
|
||||
if (l != NULL) {
|
||||
const char* setting = _sensors->getSettingByKey("gps");
|
||||
bool requested = setting != NULL && strcmp(setting, "1") == 0;
|
||||
int prefix_len = snprintf(reply, 160, "req:%u ", requested ? 1U : 0U);
|
||||
if (prefix_len < 0 || prefix_len >= 160) {
|
||||
reply[159] = 0;
|
||||
} else {
|
||||
l->formatDiagnostics(reply + prefix_len, 160 - prefix_len);
|
||||
}
|
||||
} else {
|
||||
strcpy(reply, "gps provider not found");
|
||||
}
|
||||
} else if (memcmp(command, "gps setloc", 10) == 0) {
|
||||
_prefs->node_lat = _sensors->node_lat;
|
||||
_prefs->node_lon = _sensors->node_lon;
|
||||
@@ -443,24 +389,6 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
} else {
|
||||
strcpy(reply, "error");
|
||||
}
|
||||
} else if (memcmp(command, "gps", 3) == 0) {
|
||||
LocationProvider * l = _sensors->getLocationProvider();
|
||||
if (l != NULL) {
|
||||
bool enabled = l->isEnabled(); // is EN pin on ?
|
||||
bool fix = l->isValid(); // has fix ?
|
||||
int sats = l->satellitesCount();
|
||||
bool active = !strcmp(_sensors->getSettingByKey("gps"), "1");
|
||||
if (enabled) {
|
||||
sprintf(reply, "on, %s, %s, %d sats",
|
||||
active?"active":"deactivated",
|
||||
fix?"fix":"no fix",
|
||||
sats);
|
||||
} else {
|
||||
strcpy(reply, "off");
|
||||
}
|
||||
} else {
|
||||
strcpy(reply, "Can't find GPS");
|
||||
}
|
||||
#endif
|
||||
} else if (memcmp(command, "powersaving on", 14) == 0) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <helpers/RegionMap.h>
|
||||
#include <helpers/ConfigSerializer.h>
|
||||
#include <helpers/CommonRadioPrefs.h>
|
||||
#include <helpers/CommonGpsPrefs.h>
|
||||
#include <helpers/DynamicConfigSerializer.h>
|
||||
|
||||
#if defined(WITH_RS232_BRIDGE) || defined(WITH_ESPNOW_BRIDGE)
|
||||
@@ -153,7 +154,7 @@ private:
|
||||
};
|
||||
BridgePrefs bridge;
|
||||
|
||||
class GPSPrefs : public ConfigSerializer {
|
||||
class GPSPrefs : public CommonGpsPrefs {
|
||||
NodePrefs* _parent;
|
||||
protected:
|
||||
void structure() override {
|
||||
@@ -164,6 +165,10 @@ private:
|
||||
}
|
||||
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(); }
|
||||
};
|
||||
GPSPrefs gps;
|
||||
|
||||
@@ -236,10 +241,11 @@ public:
|
||||
}
|
||||
|
||||
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(); }
|
||||
};
|
||||
|
||||
class CommonCLICallbacks {
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
#include "CommonGpsPrefs.h"
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
|
||||
bool CommonGpsPrefs::setGpsEnabled(SensorManager& sensors, bool enabled) {
|
||||
LocationProvider* location = sensors.getLocationProvider();
|
||||
if (location == nullptr) return false;
|
||||
location->setGpsOn(enabled);
|
||||
setGpsEnabled(enabled);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommonGpsPrefs::setGpsPeriod(SensorManager& sensors, uint32_t seconds) {
|
||||
LocationProvider* location = sensors.getLocationProvider();
|
||||
if (location == nullptr) return false;
|
||||
location->setGpsPeriod(seconds);
|
||||
setGpsPeriod(seconds);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommonGpsPrefs::apply(SensorManager& sensors) const {
|
||||
LocationProvider* location = sensors.getLocationProvider();
|
||||
if (location == nullptr) return false;
|
||||
location->setGpsPeriod(getGpsPeriod());
|
||||
location->setGpsOn(isGpsEnabled());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommonGpsPrefs::handleCommand(const char* command, SensorManager& sensors, char* reply) {
|
||||
if (strcmp(command, "gps") == 0) {
|
||||
LocationProvider* location = sensors.getLocationProvider();
|
||||
char mode[32];
|
||||
if (getGpsPeriod() == 0) {
|
||||
strcpy(mode, "tracking");
|
||||
} else {
|
||||
snprintf(mode, sizeof(mode), "periodic (%lus)",
|
||||
(unsigned long)getGpsPeriod());
|
||||
}
|
||||
if (location == nullptr) {
|
||||
strcpy(reply, "gps provider not found");
|
||||
} else if (location->isEnabled()) {
|
||||
sprintf(reply, "on, %s, %s, %d sats, mode: %s",
|
||||
isGpsEnabled() ? "active" : "deactivated",
|
||||
location->isValid() ? "fix" : "no fix",
|
||||
location->satellitesCount(), mode);
|
||||
} else {
|
||||
snprintf(reply, 160, "off, mode: %s", mode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "gps on", 6) == 0) {
|
||||
if (!setGpsEnabled(sensors, true)) {
|
||||
strcpy(reply, "gps toggle not found");
|
||||
} else {
|
||||
strcpy(reply, "ok");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "gps off", 7) == 0) {
|
||||
if (!setGpsEnabled(sensors, false)) {
|
||||
strcpy(reply, "gps toggle not found");
|
||||
} else {
|
||||
strcpy(reply, "ok");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (strcmp(command, "gps period") == 0) {
|
||||
if (getGpsPeriod() == 0) {
|
||||
strcpy(reply, "> 0 (continuous)");
|
||||
} else {
|
||||
sprintf(reply, "> %lu", (unsigned long)getGpsPeriod());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "gps period ", 11) == 0) {
|
||||
char* end = nullptr;
|
||||
unsigned long period = strtoul(command + 11, &end, 10);
|
||||
if (command[11] == '\0' || *end != '\0' || period > 86400) {
|
||||
strcpy(reply, "gps period must be 0-86400 seconds");
|
||||
} else {
|
||||
if (!setGpsPeriod(sensors, (uint32_t)period) ||
|
||||
!setGpsEnabled(sensors, true)) {
|
||||
strcpy(reply, "gps provider not found");
|
||||
} else {
|
||||
strcpy(reply, "ok");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "gps sync", 8) == 0) {
|
||||
LocationProvider* location = sensors.getLocationProvider();
|
||||
if (location == nullptr) {
|
||||
strcpy(reply, "gps provider not found");
|
||||
} else {
|
||||
location->syncTime();
|
||||
strcpy(reply, "ok");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (strcmp(command, "gps diag") == 0) {
|
||||
LocationProvider* location = sensors.getLocationProvider();
|
||||
if (location == nullptr) {
|
||||
strcpy(reply, "gps provider not found");
|
||||
} else {
|
||||
int prefix = snprintf(reply, 160, "req:%u ", isGpsEnabled() ? 1U : 0U);
|
||||
if (prefix >= 0 && prefix < 160) location->formatDiagnostics(reply + prefix, 160 - prefix);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "ConfigSerializer.h"
|
||||
#include "SensorManager.h"
|
||||
|
||||
class CommonGpsPrefs : public ConfigSerializer {
|
||||
bool _is_dirty = false;
|
||||
|
||||
protected:
|
||||
CommonGpsPrefs() = default;
|
||||
|
||||
public:
|
||||
void markDirty() { _is_dirty = true; }
|
||||
void clearDirty() { _is_dirty = false; }
|
||||
bool isDirty() const { return _is_dirty; }
|
||||
|
||||
virtual bool isGpsEnabled() const = 0;
|
||||
virtual void setGpsEnabled(bool enabled) = 0;
|
||||
virtual uint32_t getGpsPeriod() const = 0;
|
||||
virtual void setGpsPeriod(uint32_t seconds) = 0;
|
||||
|
||||
bool setGpsEnabled(SensorManager& sensors, bool enabled);
|
||||
bool setGpsPeriod(SensorManager& sensors, uint32_t seconds);
|
||||
bool apply(SensorManager& sensors) const;
|
||||
bool handleCommand(const char* command, SensorManager& sensors, char* reply);
|
||||
};
|
||||
@@ -650,7 +650,7 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
|
||||
int EnvironmentSensorManager::getNumSettings() const {
|
||||
int settings = 0;
|
||||
#if ENV_INCLUDE_GPS
|
||||
if (gps_detected) settings += 2; // GPS enablement and periodic acquisition
|
||||
if (gps_detected) settings += 1; // GPS enablement
|
||||
#endif
|
||||
return settings;
|
||||
}
|
||||
@@ -661,9 +661,6 @@ const char* EnvironmentSensorManager::getSettingName(int i) const {
|
||||
if (gps_detected && i == settings++) {
|
||||
return "gps";
|
||||
}
|
||||
if (gps_detected && i == settings++) {
|
||||
return "gps_period";
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
@@ -674,12 +671,6 @@ const char* EnvironmentSensorManager::getSettingValue(int i) const {
|
||||
if (gps_detected && i == settings++) {
|
||||
return _location->isGpsOn() ? "1" : "0";
|
||||
}
|
||||
if (gps_detected && i == settings++) {
|
||||
static char period[11];
|
||||
snprintf(period, sizeof(period), "%lu",
|
||||
(unsigned long)_location->getGpsPeriod());
|
||||
return period;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
@@ -694,13 +685,6 @@ bool EnvironmentSensorManager::setSettingValue(const char* name, const char* val
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (gps_detected && strcmp(name, "gps_period") == 0) {
|
||||
char* end = nullptr;
|
||||
unsigned long period = strtoul(value, &end, 10);
|
||||
if (*value == '\0' || *end != '\0' || period > 86400) return false;
|
||||
_location->setGpsPeriod((uint32_t)period);
|
||||
return true;
|
||||
}
|
||||
if (strcmp(name, "gps_interval") == 0) {
|
||||
uint32_t interval_seconds = atoi(value);
|
||||
gps_update_interval_sec = interval_seconds > 0 ? interval_seconds : 1;
|
||||
|
||||
@@ -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() {
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -17,7 +17,20 @@ 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 begin() override {
|
||||
NmeaGpsDriver::begin();
|
||||
sendNmeaSentence("$CFGSYS,h35155*68");
|
||||
}
|
||||
};
|
||||
|
||||
HeltecTrackerGpsDriver gps_driver;
|
||||
MicroNMEALocationProvider nmea(gps_driver, &rtc_clock);
|
||||
HWTSensorManager sensors = HWTSensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
@@ -43,18 +56,11 @@ 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() {
|
||||
@@ -76,7 +82,7 @@ void HWTSensorManager::loop() {
|
||||
_location->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
if (gps_active && _location->isValid()) {
|
||||
if (_location->isEnabled() && _location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude())/1000000.;
|
||||
node_lon = ((double)_location->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_location->getAltitude()) / 1000.0;
|
||||
@@ -93,7 +99,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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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,17 +38,13 @@ 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() {
|
||||
@@ -67,7 +64,7 @@ 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(millis() > next_gps_update && _location->isEnabled()) {
|
||||
if(_location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude()) / 1000000.;
|
||||
node_lon = ((double)_location->getLongitude()) / 1000000.;
|
||||
@@ -85,7 +82,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->isEnabled() && _nmea->isValid()) {
|
||||
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() {
|
||||
@@ -55,17 +50,6 @@ void MuziBaseSensorManager::loop() {
|
||||
_pwr_last_click = t;
|
||||
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();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
EnvironmentSensorManager::loop();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,14 +38,10 @@ 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;
|
||||
#endif
|
||||
public:
|
||||
#if ENV_INCLUDE_GPS
|
||||
MuziBaseSensorManager(LocationProvider& location) : EnvironmentSensorManager(location) {}
|
||||
|
||||
@@ -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(HardwareSerial& serial) : NmeaGpsDriver(serial) {
|
||||
pinMode(PIN_GPS_STANDBY, OUTPUT);
|
||||
digitalWrite(PIN_GPS_STANDBY, LOW);
|
||||
}
|
||||
|
||||
void begin() override {
|
||||
if (isEnabled()) 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->isEnabled()) {
|
||||
return; // GPS is not active, skip further processing
|
||||
}
|
||||
|
||||
_location->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
if (_location->isValid()) {
|
||||
if (_location->isEnabled() && _location->isValid()) {
|
||||
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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -82,13 +82,11 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
}
|
||||
|
||||
void T1000SensorManager::start_gps() {
|
||||
gps_active = true;
|
||||
_nmea->begin();
|
||||
_nmea->setGpsOn(true);
|
||||
}
|
||||
|
||||
void T1000SensorManager::stop_gps() {
|
||||
gps_active = false;
|
||||
_nmea->stop();
|
||||
_nmea->setGpsOn(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +113,7 @@ void T1000SensorManager::loop() {
|
||||
_nmea->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
if (gps_active && _nmea->isValid()) {
|
||||
if (_nmea->isEnabled() && _nmea->isValid()) {
|
||||
node_lat = ((double)_nmea->getLatitude())/1000000.;
|
||||
node_lon = ((double)_nmea->getLongitude())/1000000.;
|
||||
node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
|
||||
@@ -131,7 +129,7 @@ const char* T1000SensorManager::getSettingName(int i) const {
|
||||
}
|
||||
const char* T1000SensorManager::getSettingValue(int i) const {
|
||||
if (i == 0) {
|
||||
return gps_active ? "1" : "0";
|
||||
return _nmea->isGpsOn() ? "1" : "0";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
class AirohaGpsDriver;
|
||||
|
||||
class T1000SensorManager: public SensorManager {
|
||||
bool gps_active = false;
|
||||
LocationProvider * _nmea;
|
||||
AirohaGpsDriver* _gps_driver;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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