@@ -789,6 +789,9 @@ boolean SFE_UBLOX_GNSS::checkAutomatic(uint8_t Class, uint8_t ID)
789
789
case UBX_NAV_CLOCK:
790
790
if (packetUBXNAVCLOCK != NULL ) result = true ;
791
791
break ;
792
+ case UBX_NAV_TIMELS:
793
+ if (packetUBXNAVTIMELS != NULL ) result = true ;
794
+ break ;
792
795
case UBX_NAV_SVIN:
793
796
if (packetUBXNAVSVIN != NULL ) result = true ;
794
797
break ;
@@ -916,6 +919,9 @@ uint16_t SFE_UBLOX_GNSS::getMaxPayloadSize(uint8_t Class, uint8_t ID)
916
919
case UBX_NAV_CLOCK:
917
920
maxSize = UBX_NAV_CLOCK_LEN;
918
921
break ;
922
+ case UBX_NAV_TIMELS:
923
+ maxSize = UBX_NAV_TIMELS_LEN;
924
+ break ;
919
925
case UBX_NAV_SVIN:
920
926
maxSize = UBX_NAV_SVIN_LEN;
921
927
break ;
@@ -1949,6 +1955,26 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
1949
1955
}
1950
1956
}
1951
1957
}
1958
+ else if (msg->id == UBX_NAV_TIMELS && msg->len == UBX_NAV_TIMELS_LEN)
1959
+ {
1960
+ // Parse various byte fields into storage - but only if we have memory allocated for it
1961
+ if (packetUBXNAVTIMELS != NULL )
1962
+ {
1963
+ packetUBXNAVTIMELS->data .iTOW = extractLong (msg, 0 );
1964
+ packetUBXNAVTIMELS->data .version = extractByte (msg, 4 );
1965
+ packetUBXNAVTIMELS->data .srcOfCurrLs = extractByte (msg, 8 );
1966
+ packetUBXNAVTIMELS->data .currLs = extractSignedChar (msg, 9 );
1967
+ packetUBXNAVTIMELS->data .srcOfLsChange = extractByte (msg, 10 );
1968
+ packetUBXNAVTIMELS->data .lsChange = extractSignedChar (msg, 11 );
1969
+ packetUBXNAVTIMELS->data .timeToLsEvent = extractSignedLong (msg, 12 );
1970
+ packetUBXNAVTIMELS->data .dateOfLsGpsWn = extractInt (msg, 16 );
1971
+ packetUBXNAVTIMELS->data .dateOfLsGpsDn = extractInt (msg, 18 );
1972
+ packetUBXNAVTIMELS->data .valid = extractSignedChar (msg, 23 );
1973
+
1974
+ // Mark all datums as fresh (not read before)
1975
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .all = 0xFFFFFFFF ;
1976
+ }
1977
+ }
1952
1978
else if (msg->id == UBX_NAV_SVIN && msg->len == UBX_NAV_SVIN_LEN)
1953
1979
{
1954
1980
// Parse various byte fields into storage - but only if we have memory allocated for it
@@ -6862,6 +6888,53 @@ void SFE_UBLOX_GNSS::logNAVCLOCK(boolean enabled)
6862
6888
packetUBXNAVCLOCK->automaticFlags .flags .bits .addToFileBuffer = (uint8_t )enabled;
6863
6889
}
6864
6890
6891
+ // ***** NAV TIMELS automatic support
6892
+
6893
+ // Reads leap second event information and sets the global variables
6894
+ // for future leap second change and number of leap seconds since GPS epoch
6895
+ // Returns true if commands was successful
6896
+ boolean SFE_UBLOX_GNSS::getLeapSecondEvent (uint16_t maxWait)
6897
+ {
6898
+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
6899
+ if (packetUBXNAVTIMELS == NULL ) // Abort if the RAM allocation failed
6900
+ return (false );
6901
+
6902
+ packetCfg.cls = UBX_CLASS_NAV;
6903
+ packetCfg.id = UBX_NAV_TIMELS;
6904
+ packetCfg.len = 0 ;
6905
+ packetCfg.startingSpot = 0 ;
6906
+
6907
+ // The data is parsed as part of processing the response
6908
+ sfe_ublox_status_e retVal = sendCommand (&packetCfg, maxWait);
6909
+
6910
+ if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
6911
+ return (true );
6912
+
6913
+ if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
6914
+ {
6915
+ return (true );
6916
+ }
6917
+
6918
+ return (false );
6919
+ }
6920
+
6921
+ // PRIVATE: Allocate RAM for packetUBXNAVTIMELS and initialize it
6922
+ boolean SFE_UBLOX_GNSS::initPacketUBXNAVTIMELS ()
6923
+ {
6924
+ packetUBXNAVTIMELS = new UBX_NAV_TIMELS_t; // Allocate RAM for the main struct
6925
+ if (packetUBXNAVTIMELS == NULL )
6926
+ {
6927
+ if ((_printDebug == true ) || (_printLimitedDebug == true )) // This is important. Print this if doing limited debugging
6928
+ _debugSerial->println (F (" initPacketUBXNAVTIMELS: PANIC! RAM allocation failed!" ));
6929
+ return (false );
6930
+ }
6931
+ packetUBXNAVTIMELS->automaticFlags .flags .all = 0 ;
6932
+ packetUBXNAVTIMELS->callbackPointer = NULL ;
6933
+ packetUBXNAVTIMELS->callbackData = NULL ;
6934
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .all = 0 ;
6935
+ return (true );
6936
+ }
6937
+
6865
6938
// ***** NAV SVIN automatic support
6866
6939
6867
6940
// Reads survey in status and sets the global variables
@@ -10178,6 +10251,45 @@ float SFE_UBLOX_GNSS::getSurveyInMeanAccuracy(uint16_t maxWait) // Returned as m
10178
10251
return (((float )tempFloat) / 10000.0 ); // Convert 0.1mm to m
10179
10252
}
10180
10253
10254
+ // ***** TIMELS Helper Functions
10255
+
10256
+ uint8_t SFE_UBLOX_GNSS::getLeapIndicator (int32_t & timeToLsEvent, uint16_t maxWait)
10257
+ {
10258
+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
10259
+ if (packetUBXNAVTIMELS == NULL ) // Bail if the RAM allocation failed
10260
+ return 3 ;
10261
+
10262
+ if (packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid == false )
10263
+ getLeapSecondEvent (maxWait);
10264
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid = false ; // Since we are about to give this to user, mark this data as stale
10265
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .lsChange = false ;
10266
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .timeToLsEvent = false ;
10267
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .all = false ;
10268
+ timeToLsEvent = packetUBXNAVTIMELS->data .timeToLsEvent ;
10269
+ // returns NTP Leap Indicator
10270
+ // 0 -no warning
10271
+ // 1 -last minute of the day has 61 seconds
10272
+ // 2 -last minute of the day has 59 seconds
10273
+ // 3 -unknown (clock unsynchronized)
10274
+ return ((boolean)packetUBXNAVTIMELS->data .valid ? (uint8_t )(packetUBXNAVTIMELS->data .lsChange == -1 ? 2 : packetUBXNAVTIMELS->data .lsChange ) : 3 );
10275
+ }
10276
+
10277
+ int8_t SFE_UBLOX_GNSS::getCurrentLeapSeconds (sfe_ublox_ls_src_e& source, uint16_t maxWait)
10278
+ {
10279
+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
10280
+ if (packetUBXNAVTIMELS == NULL ) // Bail if the RAM allocation failed
10281
+ return false ;
10282
+
10283
+ if (packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid == false )
10284
+ getLeapSecondEvent (maxWait);
10285
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid = false ; // Since we are about to give this to user, mark this data as stale
10286
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .srcOfCurrLs = false ;
10287
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .currLs = false ;
10288
+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .all = false ;
10289
+ source = ((sfe_ublox_ls_src_e)packetUBXNAVTIMELS->data .srcOfCurrLs );
10290
+ return ((int8_t )packetUBXNAVTIMELS->data .currLs );
10291
+ }
10292
+
10181
10293
// ***** RELPOSNED Helper Functions and automatic support
10182
10294
10183
10295
float SFE_UBLOX_GNSS::getRelPosN (uint16_t maxWait) // Returned as m
0 commit comments