diff --git a/gps/GPS.cc b/gps/GPS.cc index 3d14fc7..6264d1d 100644 --- a/gps/GPS.cc +++ b/gps/GPS.cc @@ -228,7 +228,18 @@ void GPS::parse_GGA(const string& frame) while(getline(ss, data, ',')) s_data.push_back(data); // Is the data valid? - this->active = s_data[6] > "0"; + bool active = s_data[6] > "0"; + + if (this->active && ! active) + { + this->logger->log("Fix lost."); + this->active = false; + } + else if ( ! this->active && active) + { + this->logger->log("Fix acquired."); + this->active = true; + } if (this->active) { @@ -264,7 +275,18 @@ void GPS::parse_GSA(const string& frame) while(getline(ss, data, ',')) s_data.push_back(data); // Is the data valid? - this->active = s_data[2] != "1"; + bool active = s_data[2] != "1"; + + if (this->active && ! active) + { + this->logger->log("Fix lost."); + this->active = false; + } + else if ( ! this->active && active) + { + this->logger->log("Fix acquired."); + this->active = true; + } if (this->active) { @@ -285,7 +307,18 @@ void GPS::parse_RMC(const string& frame) while(getline(ss, data, ',')) s_data.push_back(data); // Is the data valid? - this->active = s_data[2] == "A"; + bool active = s_data[2] == "A"; + + if (this->active && ! active) + { + this->logger->log("Fix lost."); + this->active = false; + } + else if ( ! this->active && active) + { + this->logger->log("Fix acquired"); + this->active = true; + } if (this->active) {