Skip to content

Commit b53f899

Browse files
committed
getCellularTime return UNIX epoch if NTP sync fails
1 parent cf8c0e3 commit b53f899

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Diff for: src/ArduinoCellular.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,16 @@ Time ArduinoCellular::getGPSTime(){
122122
}
123123

124124
Time ArduinoCellular::getCellularTime(){
125-
int year, month, day, hour, minute, second;
125+
int year = 1970;
126+
int month = 1;
127+
int day = 1;
128+
int hour = 0;
129+
int minute = 0;
130+
int second = 0;
126131
float tz;
127-
modem.NTPServerSync();
128-
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
132+
if (modem.NTPServerSync() != -1) {
133+
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
134+
}
129135
return Time(year, month, day, hour, minute, second);
130136
}
131137

0 commit comments

Comments
 (0)