使用GPS进行时间同步,AndroidonNmeaReceived回调中的时间戳代表什么?

Using GPS for time synchronization, what does the timestamp in the Android onNmeaReceived callback represent?

在 Android 开发(最新的 SDK)中,我正在使用 GpsStatus.NmeaListener 解析 NMEA 消息以实现时间同步。

onNmeaReceived(long timestamp, String nmea) 回调中,我解析了 GPRMC 消息的 nmea 字符串。然后我计算系统时钟和从 GPRMC 消息解析的时间之间的偏移量。

现在在 Android 框架工作中收到 NMEA 消息的时刻与处理回调之间存在延迟。这会导致我正在计算的实际偏移量发生变化。

我的猜测是随 NMEA 消息发送的 timestamp 是收到 NMEA 消息时的系统时钟时间。如果这是真的,我可以使用这个时间戳来补偿回调处理中的延迟。

根据我的测量,timestamp 时间与 onNmeaReceived 回调中捕获的系统时钟时间有大约 10 ~ 30 毫秒的差异。
timestamp 与从解析的 GPRMC 消息派生的时间之间的 difference/offset 大约为 7200092 毫秒(GPS 和系统时间相差 2 小时)。

因此我会说 timestamp 不是基于 GPS 的时间,而是收到消息时的系统时钟时间。

我在网上搜索了很多,但我似乎无法找到有关此时间戳的任何信息。有没有人有资源告诉我们更多关于这个时间戳的信息?这个时间戳到底代表什么?它是在什么时间记录的?

感谢 Hanno Binder 的评论,我得到了以下答案。

NMEA 回调描述如下: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

使用 gettimeofday() 方法将 timestamp 记录为 struct timeval(在 sys/time.h> 中指定)。

在十台 Nexus 7 (2012) 设备上测量 timestamp 和 GPRMC 时间之间的 200 个偏移的标准偏差,导致记录偏移的平均标准偏差为 6.95 毫秒。