mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-11-22 03:17:07 +00:00
GPS guard: save gps fence in the GPS prefs
This commit is contained in:
1 parent
fbd20ac64b
commit
d72f67d37b
5 files changed
+28
-2
No files matched your search
@@ -1087,7 +1087,7 @@ Covers serial NMEA receivers (`MicroNMEALocationProvider`).
|
||||
**Usage:**
|
||||
- `gps guard`: status, e.g. `> ok 7sat time ok +1s`, `> rej region time rej nofix`, or `... ALERT gps-clk +3600s 75m` when a trusted fix has disagreed with the clock by the same offset for `GPS_GUARD_ALERT_MIN` minutes. While the alert is active, the offset in hours is also reported in telemetry on the next free channel.
|
||||
- `gps guard accept`: while an alert is active, confirm that the GPS time is right and apply it to the clock.
|
||||
- `gps fence`, `gps fence <metres>`: fence radius around the configured `lat`/`lon` (`0` = off). Default `GPS_GUARD_FENCE_M` (1000), not saved.
|
||||
- `gps fence`, `gps fence <metres>`: fence radius around the configured `lat`/`lon` (`0` = off). Default `GPS_GUARD_FENCE_M` (1000); a value set here is saved.
|
||||
- `gps ref`: the reference position; follows `set lat`, `set lon` and `gps setloc`.
|
||||
|
||||
---
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
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 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)
|
||||
@@ -166,6 +167,9 @@ private:
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
GPSPrefs(NodePrefs* parent) : _parent(parent) { }
|
||||
@@ -173,6 +177,12 @@ private:
|
||||
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(); }
|
||||
};
|
||||
GPSPrefs gps;
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
uint8_t gps_enabled = 0;
|
||||
uint32_t gps_interval = 0; // 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 advert_loc_policy = 0;
|
||||
uint32_t discovery_mod_timestamp = 0;
|
||||
float adc_multiplier = 0;
|
||||
@@ -162,6 +163,9 @@ private:
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
GPSPrefs(NodePrefs* parent) : _parent(parent) { }
|
||||
@@ -169,6 +173,12 @@ private:
|
||||
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 getGuardReference(double& lat, double& lon) const override {
|
||||
lat = _parent->node_lat;
|
||||
lon = _parent->node_lon;
|
||||
|
||||
@@ -26,6 +26,8 @@ void CommonGpsPrefs::applyGuardReference(SensorManager& sensors) const {
|
||||
GpsGuard* guard = location != nullptr ? location->getGuard() : nullptr;
|
||||
double lat, lon;
|
||||
if (guard != nullptr && getGuardReference(lat, lon)) guard->setReference(lat, lon);
|
||||
uint32_t fence;
|
||||
if (guard != nullptr && getGuardFence(fence)) guard->setFence(fence);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -247,10 +249,11 @@ bool CommonGpsPrefs::handleCommand(const char* command, SensorManager& sensors,
|
||||
} else if (memcmp(command, "gps fence ", 10) == 0) {
|
||||
char* end;
|
||||
unsigned long metres = strtoul(command + 10, &end, 10);
|
||||
if (command[10] == ' | ||||