Skip to content

Commit

Permalink
Merge pull request #22 from pennam/ntp-sync
Browse files Browse the repository at this point in the history
Add NTPServerSync before getNetworkTime
  • Loading branch information
sebromero authored Jun 4, 2024
2 parents 50c8d9b + 94aeac0 commit 34c49f4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ArduinoCellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,16 @@ Time ArduinoCellular::getGPSTime(){
}

Time ArduinoCellular::getCellularTime(){
int year, month, day, hour, minute, second;
int year = 1970;
int month = 1;
int day = 1;
int hour = 0;
int minute = 0;
int second = 0;
float tz;
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
if (modem.NTPServerSync() == 0) {
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
}
return Time(year, month, day, hour, minute, second);
}

Expand Down

0 comments on commit 34c49f4

Please sign in to comment.