@@ -133,12 +133,12 @@ void menuPointPerfectKeys()
133133 1 ; // Next key starts after current key
134134 settings.pointPerfectNextKeyDuration = settings.pointPerfectCurrentKeyDuration ;
135135
136- if (ENABLE_DEVELOPER )
137- {
138- systemPrintf (" settings.pointPerfectNextKeyStart : %lld\r\n " , settings.pointPerfectNextKeyStart );
139- systemPrintf (" settings.pointPerfectNextKeyDuration : %lld\r\n " ,
140- settings.pointPerfectNextKeyDuration );
141- }
136+ if (settings. debugLBand == true )
137+ {
138+ systemPrintf (" settings.pointPerfectCurrentKeyStart : %lld - %s \r\n " , settings.pointPerfectCurrentKeyStart , printDateFromUnixEpoch (settings. pointPerfectCurrentKeyStart ) );
139+ systemPrintf (" settings.pointPerfectCurrentKeyDuration : %lld - %s \r\n " , settings. pointPerfectCurrentKeyDuration , printDaysFromDuration (settings. pointPerfectCurrentKeyDuration ));
140+ systemPrintf ( " settings.pointPerfectNextKeyStart: %lld - %s \r\n " , settings. pointPerfectNextKeyStart , printDateFromUnixEpoch ( settings.pointPerfectNextKeyStart ) );
141+ systemPrintf ( " settings.pointPerfectNextKeyDuration: %lld - %s \r\n " , settings. pointPerfectNextKeyDuration , printDaysFromDuration (settings. pointPerfectNextKeyDuration ));
142142 }
143143 }
144144 else if (incoming == 4 )
@@ -173,6 +173,50 @@ void menuPointPerfectKeys()
173173 clearBuffer (); // Empty buffer of any newline chars
174174}
175175
176+ // Given a GPS Epoch, return a DD/MM/YYYY string
177+ char *printDateFromGPSEpoch (long long gpsEpoch)
178+ {
179+ uint16_t keyGPSWeek;
180+ uint32_t keyGPSToW;
181+ epochToWeekToW (gpsEpoch, &keyGPSWeek, &keyGPSToW);
182+
183+ long expDay;
184+ long expMonth;
185+ long expYear;
186+ gpsWeekToWToDate (keyGPSWeek, keyGPSToW, &expDay, &expMonth, &expYear);
187+
188+ char *response = (char *)malloc (strlen (" 01/01/1010" ));
189+
190+ sprintf (response, " %02ld/%02ld/%ld" , expDay, expMonth, expYear);
191+ return (response);
192+ }
193+
194+ // Given a Unix Epoch, return a DD/MM/YYYY string
195+ // https://www.epochconverter.com/programming/c
196+ char *printDateFromUnixEpoch (long long unixEpoch)
197+ {
198+ char *buf = (char *)malloc (strlen (" 01/01/1010" ));
199+ time_t rawtime = unixEpoch;
200+
201+ struct tm ts;
202+ ts = *localtime (&rawtime);
203+
204+ // Format time, "dd/mm/yyyy"
205+ strftime (buf, strlen (" 01/01/1010" ), " %d/%m/%Y" , &ts);
206+ return (buf);
207+ }
208+
209+ // Given a duration in ms, print days
210+ char *printDaysFromDuration (long long duration)
211+ {
212+ duration /= (1000L * 60L * 60 * 24 ); // Convert ms to days
213+
214+ char *response = (char *)malloc (strlen (" 34.9" ));
215+ sprintf (response, " %0.2f" , duration);
216+ return (response);
217+ }
218+
219+
176220// Connect to 'home' WiFi and then ThingStream API. This will attach this unique device to the ThingStream network.
177221bool pointperfectProvisionDevice ()
178222{
@@ -324,6 +368,16 @@ bool pointperfectProvisionDevice()
324368 strcpy (settings.pointPerfectCurrentKey , (const char *)((*jsonZtp)[" dynamickeys" ][" current" ][" value" ]));
325369 settings.pointPerfectCurrentKeyDuration = (*jsonZtp)[" dynamickeys" ][" current" ][" duration" ];
326370 settings.pointPerfectCurrentKeyStart = (*jsonZtp)[" dynamickeys" ][" current" ][" start" ];
371+
372+ if (settings.debugLBand == true )
373+ {
374+ systemPrintf (" pointPerfectCurrentKey: %s\r\n " , settings.pointPerfectCurrentKey );
375+ systemPrintf (" pointPerfectCurrentKeyStart: %lld - %s\r\n " , settings.pointPerfectCurrentKeyStart , printDateFromUnixEpoch (settings.pointPerfectCurrentKeyStart ));
376+ systemPrintf (" pointPerfectCurrentKeyDuration: %lld - %s\r\n " , settings.pointPerfectCurrentKeyDuration , printDaysFromDuration (settings.pointPerfectCurrentKeyDuration ));
377+ systemPrintf (" pointPerfectNextKey: %s\r\n " , settings.pointPerfectNextKey );
378+ systemPrintf (" pointPerfectNextKeyStart: %lld - %s\r\n " , settings.pointPerfectNextKeyStart , printDateFromUnixEpoch (settings.pointPerfectNextKeyStart ));
379+ systemPrintf (" pointPerfectNextKeyDuration: %lld - %s\r\n " , settings.pointPerfectNextKeyDuration , printDaysFromDuration (settings.pointPerfectNextKeyDuration ));
380+ }
327381 }
328382 } // HTTP Response was 200
329383
@@ -631,6 +685,16 @@ void mqttCallback(char *topic, byte *message, unsigned int length)
631685 settings.pointPerfectNextKeyDuration =
632686 settings.pointPerfectCurrentKeyDuration ; // We assume next key duration is the same as current key duration
633687 // because we have to
688+ if (settings.debugLBand == true )
689+ {
690+ systemPrintln ();
691+ systemPrintf (" pointPerfectCurrentKey: %s\r\n " , settings.pointPerfectCurrentKey );
692+ systemPrintf (" pointPerfectCurrentKeyStart: %lld - %s\r\n " , settings.pointPerfectCurrentKeyStart , printDateFromUnixEpoch (settings.pointPerfectCurrentKeyStart ));
693+ systemPrintf (" pointPerfectCurrentKeyDuration: %lld - %s\r\n " , settings.pointPerfectCurrentKeyDuration , printDaysFromDuration (settings.pointPerfectCurrentKeyDuration ));
694+ systemPrintf (" pointPerfectNextKey: %s\r\n " , settings.pointPerfectNextKey );
695+ systemPrintf (" pointPerfectNextKeyStart: %lld - %s\r\n " , settings.pointPerfectNextKeyStart , printDateFromUnixEpoch (settings.pointPerfectNextKeyStart ));
696+ systemPrintf (" pointPerfectNextKeyDuration: %lld - %s\r\n " , settings.pointPerfectNextKeyDuration , printDaysFromDuration (settings.pointPerfectNextKeyDuration ));
697+ }
634698 }
635699
636700 mqttMessageReceived = true ;
@@ -732,7 +796,7 @@ uint8_t getLeapSeconds()
732796 return (18 ); // Default to 18 if GNSS is offline
733797}
734798
735- // Covert a given the key's expiration date to a GPS Epoch, so that we can calculate GPS Week and ToW
799+ // Covert a given key's expiration date to a GPS Epoch, so that we can calculate GPS Week and ToW
736800// Add a millisecond to roll over from 11:59UTC to midnight of the following day
737801// Convert from unix epoch (time lib outputs unix) to GPS epoch (the NED-D9S expects)
738802long long dateToGPSEpoch (uint8_t day, uint8_t month, uint16_t year)
@@ -812,12 +876,15 @@ void dateToKeyStartDuration(uint8_t expDay, uint8_t expMonth, uint16_t expYear,
812876 uint32_t keyGPSToW;
813877 long long gpsEpoch = thingstreamEpochToGPSEpoch (*settingsKeyStart);
814878
815- if (ENABLE_DEVELOPER)
816879 epochToWeekToW (gpsEpoch, &keyGPSWeek, &keyGPSToW);
817880
881+ // Print ToW and Week for debugging
882+ if (settings.debugLBand == true )
818883 {
819- systemPrintf (" KeyStart: %lld\r\n " , *settingsKeyStart);
820- systemPrintf (" KeyDuration: %lld\r\n " , *settingsKeyDuration);
884+ systemPrintf (" expireUnixEpoch: %lld - %s\r\n " , expireUnixEpoch, printDateFromUnixEpoch (expireUnixEpoch));
885+ systemPrintf (" startUnixEpoch: %lld - %s\r\n " , startUnixEpoch, printDateFromUnixEpoch (startUnixEpoch));
886+ systemPrintf (" gpsEpoch: %lld - %s\r\n " , gpsEpoch, printDateFromGPSEpoch (gpsEpoch));
887+ systemPrintf (" KeyStart: %lld - %s\r\n " , *settingsKeyStart, printDateFromUnixEpoch (*settingsKeyStart));
821888 systemPrintf (" keyGPSWeek: %d\r\n " , keyGPSWeek);
822889 systemPrintf (" keyGPSToW: %d\r\n " , keyGPSToW);
823890 }
@@ -1086,7 +1153,6 @@ void menuPointPerfect()
10861153 }
10871154 else
10881155 {
1089-
10901156 int daysRemaining =
10911157 daysFromEpoch (settings.pointPerfectNextKeyStart + settings.pointPerfectNextKeyDuration + 1 );
10921158
@@ -1247,7 +1313,7 @@ void updateLBand()
12471313 lbandLastReport = millis ();
12481314
12491315 if (settings.debugLBand == true )
1250- systmePrintf (" ZED restarts: %d Time remaining before L-Band forced restart: %ds\r\n " , lbandRestarts,
1316+ systemPrintf (" ZED restarts: %d Time remaining before L-Band forced restart: %ds\r\n " , lbandRestarts,
12511317 settings.lbandFixTimeout_seconds - ((millis () - lbandTimeFloatStarted) / 1000 ));
12521318 }
12531319
@@ -1277,7 +1343,7 @@ void updateLBand()
12771343 {
12781344 // If we have not received RTCM in a certain amount of time,
12791345 // and if communication was disabled because RTCM was being received at some point,
1280- // re-enableL -Band communcation
1346+ // re-enable L -Band communcation
12811347 if (lBandCommunicationEnabled == false )
12821348 {
12831349 log_d (" Enabling L-Band communication due to RTCM timeout" );
0 commit comments