Skip to content

Commit 34c49f4

Browse files
authored
Merge pull request #22 from pennam/ntp-sync
Add NTPServerSync before getNetworkTime
2 parents 50c8d9b + 94aeac0 commit 34c49f4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: src/ArduinoCellular.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -122,9 +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.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
132+
if (modem.NTPServerSync() == 0) {
133+
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
134+
}
128135
return Time(year, month, day, hour, minute, second);
129136
}
130137

0 commit comments

Comments
 (0)