sforkowany z mirror/meshtastic-firmware
update MeshService to use Position struct
rodzic
70b80e600d
commit
f69c8dddad
|
@ -213,27 +213,32 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
||||||
{
|
{
|
||||||
// Update our local node info with our position (even if we don't decide to update anyone else)
|
// Update our local node info with our position (even if we don't decide to update anyone else)
|
||||||
NodeInfo *node = refreshMyNodeInfo();
|
NodeInfo *node = refreshMyNodeInfo();
|
||||||
Position pos = node->position;
|
Position pos = Position_init_default;
|
||||||
|
|
||||||
if (newStatus->getHasLock()) {
|
if (newStatus->getHasLock()) {
|
||||||
if (gps->altitude != 0)
|
// load data from GPS object, will add timestamp + battery further down
|
||||||
pos.altitude = gps->altitude;
|
pos = gps->p;
|
||||||
pos.latitude_i = gps->latitude;
|
|
||||||
pos.longitude_i = gps->longitude;
|
|
||||||
} else {
|
} else {
|
||||||
// The GPS has lost lock, if we are fixed position we should just keep using
|
// The GPS has lost lock, if we are fixed position we should just keep using
|
||||||
// the old position
|
// the old position
|
||||||
|
#if GPS_EXTRAVERBOSE
|
||||||
|
DEBUG_MSG("onGPSchanged() - lost validLocation\n");
|
||||||
|
#endif
|
||||||
if (radioConfig.preferences.fixed_position) {
|
if (radioConfig.preferences.fixed_position) {
|
||||||
DEBUG_MSG("WARNING: Using fixed position\n");
|
DEBUG_MSG("WARNING: Using fixed position\n");
|
||||||
} else {
|
pos = node->position;
|
||||||
// throw away old position
|
|
||||||
pos.latitude_i = 0;
|
|
||||||
pos.longitude_i = 0;
|
|
||||||
pos.altitude = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_MSG("got gps notify time=%u, lat=%d, bat=%d\n", pos.time, pos.latitude_i, pos.battery_level);
|
// Finally add a fresh timestamp and battery level reading
|
||||||
|
// I KNOW this is redundant with refreshMyNodeInfo() above, but these are
|
||||||
|
// inexpensive nonblocking calls and can be refactored in due course
|
||||||
|
pos.time = getValidTime(RTCQualityGPS);
|
||||||
|
pos.battery_level = powerStatus->getBatteryChargePercent();
|
||||||
|
|
||||||
|
// In debug logs, identify position by @timestamp:stage (stage 4 = nodeDB)
|
||||||
|
DEBUG_MSG("onGPSChanged() pos@%x:4, time=%u, lat=%d, bat=%d\n",
|
||||||
|
pos.pos_timestamp, pos.time, pos.latitude_i, pos.battery_level);
|
||||||
|
|
||||||
// Update our current position in the local DB
|
// Update our current position in the local DB
|
||||||
nodeDB.updatePosition(nodeDB.getNodeNum(), pos, RX_SRC_LOCAL);
|
nodeDB.updatePosition(nodeDB.getNodeNum(), pos, RX_SRC_LOCAL);
|
||||||
|
|
Ładowanie…
Reference in New Issue