Skip to content

Commit 5a102bc

Browse files
committed
Add syncCellularTime() public method
1 parent 557a822 commit 5a102bc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ArduinoCellular.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ Time ArduinoCellular::getCellularTime(){
157157
return getTimeStruct(true);
158158
}
159159

160+
bool ArduinoCellular::syncCellularTime(){
161+
// Sync the time with the network NTP service
162+
return syncNTPServer(true) == 0 ? true : false;
163+
}
160164

161165
void ArduinoCellular::sendSMS(String number, String message){
162166
modem.sendAT("+CMGF=1");

src/ArduinoCellular.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,19 @@ class ArduinoCellular {
158158
* @return The GPS location. If the location is not retrieved, the latitude and longitude will be 0.0.
159159
*/
160160
Geolocation getGPSLocation(unsigned long timeout = 60000);
161-
161+
162162
/**
163163
* @brief Gets the current time from the network.
164164
* @return The current time.
165165
*/
166166
Time getCellularTime();
167167

168+
/**
169+
* @brief Sync the modem time using NTP service.
170+
* @return True on success false otherwise.
171+
*/
172+
bool syncCellularTime();
173+
168174
/**
169175
* @brief Gets the current time from the GPS module.
170176
* @return The current time.

0 commit comments

Comments
 (0)