mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-29 19:03:52 +00:00
fix #397 from @a-f-G-U-C - bogus GPS positions during locking could be reported
btw - from my read of the NMEA, the lowest value that means 'has a valid position' is 1 not 2. But I only know this because you pointed me at it ;-) Thanks!
This commit is contained in:
parent
8c240b59f6
commit
8e988cc926
@ -44,6 +44,9 @@ void NEMAGPS::loop()
|
|||||||
isConnected = true; // we seem to have a real GPS (but not necessarily a lock)
|
isConnected = true; // we seem to have a real GPS (but not necessarily a lock)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t fixtype = reader.fixQuality();
|
||||||
|
hasValidLocation = ((fixtype >= 1) && (fixtype <= 5));
|
||||||
|
|
||||||
if (reader.location.isUpdated()) {
|
if (reader.location.isUpdated()) {
|
||||||
if (reader.altitude.isValid())
|
if (reader.altitude.isValid())
|
||||||
altitude = reader.altitude.meters();
|
altitude = reader.altitude.meters();
|
||||||
@ -58,18 +61,21 @@ void NEMAGPS::loop()
|
|||||||
dop = reader.hdop.value();
|
dop = reader.hdop.value();
|
||||||
}
|
}
|
||||||
if (reader.course.isValid()) {
|
if (reader.course.isValid()) {
|
||||||
heading = reader.course.value() * 1e3; //Scale the heading (in degrees * 10^-2) to match the expected degrees * 10^-5
|
heading =
|
||||||
|
reader.course.value() * 1e3; // Scale the heading (in degrees * 10^-2) to match the expected degrees * 10^-5
|
||||||
}
|
}
|
||||||
if (reader.satellites.isValid()) {
|
if (reader.satellites.isValid()) {
|
||||||
numSatellites = reader.satellites.value();
|
numSatellites = reader.satellites.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// expect gps pos lat=37.520825, lon=-122.309162, alt=158
|
// expect gps pos lat=37.520825, lon=-122.309162, alt=158
|
||||||
DEBUG_MSG("new NEMA GPS pos lat=%f, lon=%f, alt=%d, hdop=%f, heading=%f\n", latitude * 1e-7, longitude * 1e-7, altitude, dop * 1e-2, heading * 1e-5);
|
DEBUG_MSG("new NEMA GPS pos lat=%f, lon=%f, alt=%d, hdop=%f, heading=%f\n", latitude * 1e-7, longitude * 1e-7,
|
||||||
|
altitude, dop * 1e-2, heading * 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify any status instances that are observing us
|
// Notify any status instances that are observing us
|
||||||
const meshtastic::GPSStatus status = meshtastic::GPSStatus(hasLock(), isConnected, latitude, longitude, altitude, dop, heading, numSatellites);
|
const meshtastic::GPSStatus status =
|
||||||
|
meshtastic::GPSStatus(hasLock(), isConnected, latitude, longitude, altitude, dop, heading, numSatellites);
|
||||||
newStatus.notifyObservers(&status);
|
newStatus.notifyObservers(&status);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -299,8 +299,8 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *unused)
|
|||||||
p->decoded.which_payload = SubPacket_position_tag;
|
p->decoded.which_payload = SubPacket_position_tag;
|
||||||
|
|
||||||
Position &pos = p->decoded.position;
|
Position &pos = p->decoded.position;
|
||||||
// !zero or !zero lat/long means valid
|
|
||||||
if (gps->latitude != 0 || gps->longitude != 0) {
|
if (gps->hasLock()) {
|
||||||
if (gps->altitude != 0)
|
if (gps->altitude != 0)
|
||||||
pos.altitude = gps->altitude;
|
pos.altitude = gps->altitude;
|
||||||
pos.latitude_i = gps->latitude;
|
pos.latitude_i = gps->latitude;
|
||||||
|
Loading…
Reference in New Issue
Block a user