Sodaq/sodaq-one-ttnmapper/Sodaq_UBlox_GPS.cpp
/*!
 * Read the UBlox device until a fix is seen, or until
 * a timeout has been reached.
 */
Read the UBlox device until a fix is seen, or until
a timeout has been reached.
Read the UBlox device until a fix is seen or until a timeout has been reached .
bool Sodaq_UBlox_GPS::scan(bool leave_on, uint32_t timeout)
{
    bool retval = false;
    uint32_t start = millis();
    resetValues();
    on();
    delay(500);         
    size_t fix_count = 0;
    while (!is_timedout(start, timeout)) {
        if (!readLine()) {
            continue;
        }
        parseLine(_inputBuffer);
        if (_seenLatLon
                && _seenTime
                && _seenAlt
                && (_minNumSatellites == 0 || _numSatellites >= _minNumSatellites)) {
            ++fix_count;
            if (fix_count >= _minNumOfLines) {
                retval = true;
                break;
            }
        }
    }
    if (_numSatellites > 0) {
        debugPrintLn(String("[scan] num sats = ") + _numSatellites);
    }
    if (_seenTime) {
        debugPrintLn(String("[scan] datetime = ") + getDateTimeString());
    }
    if (_seenLatLon) {
        debugPrintLn(String("[scan] lat = ") + String(_lat, 7));
        debugPrintLn(String("[scan] lon = ") + String(_lon, 7));
    }
    if (!leave_on) {
        off();
    }
    return retval;
}
bool Sodaq_UBlox_GPS :: scan ( bool leave_on , uint32_t timeout ) { bool retval = false ; uint32_t start = millis ( ) ; resetValues ( ) ; on ( ) ; delay ( 500 ) ; size_t fix_count = 0 ; while ( ! is_timedout ( start , timeout ) ) { if ( ! readLine ( ) ) { continue ; } parseLine ( _inputBuffer ) ; if ( _seenLatLon && _seenTime && _seenAlt && ( _minNumSatellites == 0 || _numSatellites >= _minNumSatellites ) ) { ++ fix_count ; if ( fix_count >= _minNumOfLines ) { retval = true ; break ; } } } if ( _numSatellites > 0 ) { debugPrintLn ( String ( " " ) + _numSatellites ) ; } if ( _seenTime ) { debugPrintLn ( String ( " " ) + getDateTimeString ( ) ) ; } if ( _seenLatLon ) { debugPrintLn ( String ( " " ) + String ( _lat , 7 ) ) ; debugPrintLn ( String ( " " ) + String ( _lon , 7 ) ) ; } if ( ! leave_on ) { off ( ) ; } return retval ; }
Read the UBlox device until a fix is seen, or until
 a timeout has been reached.
Read the UBlox device until a fix is seen or until a timeout has been reached .
// TODO Is this needed? // TODO Maybe quit? // Which conditions are required to quit the scan?