In Android development (latest SDK) I am using the GpsStatus.NmeaListener
to parse NMEA messages for time synchronization.
In the onNmeaReceived(long timestamp, String nmea)
callback I parse the nmea string for GPRMC messages. I then calculate the offset between the system clock and the time parsed from the GPRMC message.
Now there is a delay between the moment in time the NMEA message was received in the Android Frame work and the handling of the callback. This would cause a variation in the actual offset that I am calculating.
My guess is that the timestamp
that is send along the NMEA message is the system clock time of the moment that the NMEA message was received. If this is true, I can use this timestamp to compensate for the latency in the callback handling.
From my measurements, the timestamp
time has a difference from the System clock time captured in the onNmeaReceived
callback of approx 10 ~ 30 ms.
The difference/offset between the time between the timestamp
and the time derived from the parsed GPRMC message is in the order of 7200092ms (2hours difference between GPS and system time).
Therefore I would say the timestamp
is not the GPS-based time but the system clock time when the message was received.
I have searched the web for quite a bit but I can not seem to locate any information regarding this timestamp. Does anyone have a resource that tells us more about this timestamp? What exactly does this timestamp represent? At what moment in time is it recorded?
Thanks to Hanno Binder's comments I came to the following answer.
The NMEA callback is described in: Android Location Engine source code. Here it states that the timestamp
in the onNmeaReceived(long timestamp, String nmea)
callback is recorded when the android framework processes events received from the location engine (GL engine). For an overview of the Android GPS architecture see: greatanjum's overview of the GPS architecture on XDA.
The timestamp
is recorded as as struct timeval
(as specified in sys/time.h>) using the gettimeofday() method.
Measuring the standard deviation of 200 offsets between the timestamp
and the GPRMC-time over ten Nexus 7 (2012) devices, results in an average standard deviation in the recorded offsets of 6.95ms.