Handle URC's related to automatic time updates
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -165,6 +165,10 @@ class TinyGsmBG96 : public TinyGsmModem<TinyGsmBG96>,
|
|||||||
|
|
||||||
DBG(GF("### Modem:"), getModemName());
|
DBG(GF("### Modem:"), getModemName());
|
||||||
|
|
||||||
|
// Disable time and time zone URC's
|
||||||
|
sendAT(GF("+CTZR=0"));
|
||||||
|
if (waitResponse(10000L) != 1) { return false; }
|
||||||
|
|
||||||
// Enable automatic time zone update
|
// Enable automatic time zone update
|
||||||
sendAT(GF("+CTZU=1"));
|
sendAT(GF("+CTZU=1"));
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
if (waitResponse(10000L) != 1) { return false; }
|
||||||
|
|||||||
@@ -570,6 +570,10 @@ class TinyGsmM95 : public TinyGsmModem<TinyGsmM95>,
|
|||||||
}
|
}
|
||||||
data = "";
|
data = "";
|
||||||
DBG("### Closed: ", mux);
|
DBG("### Closed: ", mux);
|
||||||
|
} else if (data.endsWith(GF("+QNITZ:" GSM_NL))) {
|
||||||
|
streamSkipUntil('\n'); // URC for time sync
|
||||||
|
data = "";
|
||||||
|
DBG("### Network time has been updated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (millis() - startMillis < timeout_ms);
|
} while (millis() - startMillis < timeout_ms);
|
||||||
|
|||||||
@@ -539,6 +539,10 @@ class TinyGsmMC60 : public TinyGsmModem<TinyGsmMC60>,
|
|||||||
}
|
}
|
||||||
data = "";
|
data = "";
|
||||||
DBG("### Closed: ", mux);
|
DBG("### Closed: ", mux);
|
||||||
|
} else if (data.endsWith(GF("+QNITZ:" GSM_NL))) {
|
||||||
|
streamSkipUntil('\n'); // URC for time sync
|
||||||
|
DBG("### Network time has been updated.");
|
||||||
|
data = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (millis() - startMillis < timeout_ms);
|
} while (millis() - startMillis < timeout_ms);
|
||||||
|
|||||||
@@ -166,6 +166,10 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>,
|
|||||||
|
|
||||||
DBG(GF("### Modem:"), getModemName());
|
DBG(GF("### Modem:"), getModemName());
|
||||||
|
|
||||||
|
// Disable time and time zone URC's
|
||||||
|
sendAT(GF("+CTZR=0"));
|
||||||
|
if (waitResponse(10000L) != 1) { return false; }
|
||||||
|
|
||||||
// Enable automatic time zome update
|
// Enable automatic time zome update
|
||||||
sendAT(GF("+CTZU=1"));
|
sendAT(GF("+CTZU=1"));
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
if (waitResponse(10000L) != 1) { return false; }
|
||||||
|
|||||||
@@ -686,6 +686,23 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
|
|||||||
}
|
}
|
||||||
data = "";
|
data = "";
|
||||||
DBG("### Closed: ", mux);
|
DBG("### Closed: ", mux);
|
||||||
|
} else if (data.endsWith(GF("*PSNWID:" GSM_NL))) {
|
||||||
|
streamSkipUntil('\n'); // Refresh network name by network
|
||||||
|
data = "";
|
||||||
|
DBG("### Network name has been updated.");
|
||||||
|
} else if (data.endsWith(GF("*PSUTTZ:" GSM_NL))) {
|
||||||
|
streamSkipUntil('\n'); // Refresh time and time zone by network
|
||||||
|
data = "";
|
||||||
|
DBG("### Network time and time zone have been updated.");
|
||||||
|
} else if (data.endsWith(GF("+CTZV:" GSM_NL))) {
|
||||||
|
streamSkipUntil('\n'); // Refresh network time zone by network
|
||||||
|
data = "";
|
||||||
|
DBG("### Network time zone has been updated.");
|
||||||
|
} else if (data.endsWith(GF("DST:" GSM_NL))) {
|
||||||
|
streamSkipUntil(
|
||||||
|
'\n'); // Refresh Network Daylight Saving Time by network
|
||||||
|
data = "";
|
||||||
|
DBG("### Daylight savings time state been updated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (millis() - startMillis < timeout_ms);
|
} while (millis() - startMillis < timeout_ms);
|
||||||
|
|||||||
@@ -170,6 +170,10 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
|
|||||||
|
|
||||||
DBG(GF("### Modem:"), getModemName());
|
DBG(GF("### Modem:"), getModemName());
|
||||||
|
|
||||||
|
// Disable time and time zone URC's
|
||||||
|
sendAT(GF("+CTZR=0"));
|
||||||
|
if (waitResponse(10000L) != 1) { return false; }
|
||||||
|
|
||||||
// Enable automatic time zome update
|
// Enable automatic time zome update
|
||||||
sendAT(GF("+CTZU=1"));
|
sendAT(GF("+CTZU=1"));
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
if (waitResponse(10000L) != 1) { return false; }
|
||||||
|
|||||||
@@ -661,6 +661,23 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
|
|||||||
}
|
}
|
||||||
data = "";
|
data = "";
|
||||||
DBG("### Closed: ", mux);
|
DBG("### Closed: ", mux);
|
||||||
|
} else if (data.endsWith(GF("*PSNWID:" GSM_NL))) {
|
||||||
|
streamSkipUntil('\n'); // Refresh network name by network
|
||||||
|
data = "";
|
||||||
|
DBG("### Network name has been updated.");
|
||||||
|
} else if (data.endsWith(GF("*PSUTTZ:" GSM_NL))) {
|
||||||
|
streamSkipUntil('\n'); // Refresh time and time zone by network
|
||||||
|
data = "";
|
||||||
|
DBG("### Network time and time zone have been updated.");
|
||||||
|
} else if (data.endsWith(GF("+CTZV:" GSM_NL))) {
|
||||||
|
streamSkipUntil('\n'); // Refresh network time zone by network
|
||||||
|
data = "";
|
||||||
|
DBG("### Network time zone has been updated.");
|
||||||
|
} else if (data.endsWith(GF("DST:" GSM_NL))) {
|
||||||
|
streamSkipUntil(
|
||||||
|
'\n'); // Refresh Network Daylight Saving Time by network
|
||||||
|
data = "";
|
||||||
|
DBG("### Daylight savings time state been updated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (millis() - startMillis < timeout_ms);
|
} while (millis() - startMillis < timeout_ms);
|
||||||
|
|||||||
@@ -211,6 +211,10 @@ class TinyGsmSequansMonarch
|
|||||||
sendAT(GF("+CFUN=1"));
|
sendAT(GF("+CFUN=1"));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
|
|
||||||
|
// Disable time and time zone URC's
|
||||||
|
sendAT(GF("+CTZR=0"));
|
||||||
|
if (waitResponse(10000L) != 1) { return false; }
|
||||||
|
|
||||||
// Enable automatic time zome update
|
// Enable automatic time zome update
|
||||||
sendAT(GF("+CTZU=1"));
|
sendAT(GF("+CTZU=1"));
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
if (waitResponse(10000L) != 1) { return false; }
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ class TinyGsmTime {
|
|||||||
}
|
}
|
||||||
bool getNetworkTime(int* year, int* month, int* day, int* hour, int* minute,
|
bool getNetworkTime(int* year, int* month, int* day, int* hour, int* minute,
|
||||||
int* second, float* timezone) {
|
int* second, float* timezone) {
|
||||||
return thisModem().getNetworkTimeImpl(year, month, day, hour, minute, second, timezone);
|
return thisModem().getNetworkTimeImpl(year, month, day, hour, minute,
|
||||||
|
second, timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -61,12 +62,10 @@ class TinyGsmTime {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getNetworkTimeImpl(int* year, int* month, int* day, int* hour, int* minute,
|
bool getNetworkTimeImpl(int* year, int* month, int* day, int* hour,
|
||||||
int* second, float* timezone) {
|
int* minute, int* second, float* timezone) {
|
||||||
thisModem().sendAT(GF("+CCLK?"));
|
thisModem().sendAT(GF("+CCLK?"));
|
||||||
if (thisModem().waitResponse(2000L, GF("+CCLK: \"")) != 1) {
|
if (thisModem().waitResponse(2000L, GF("+CCLK: \"")) != 1) { return false; }
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int iyear = 0;
|
int iyear = 0;
|
||||||
int imonth = 0;
|
int imonth = 0;
|
||||||
@@ -85,9 +84,7 @@ class TinyGsmTime {
|
|||||||
isec = thisModem().streamGetIntLength(2);
|
isec = thisModem().streamGetIntLength(2);
|
||||||
char tzSign = thisModem().stream.read();
|
char tzSign = thisModem().stream.read();
|
||||||
itimezone = thisModem().streamGetIntBefore('\n');
|
itimezone = thisModem().streamGetIntBefore('\n');
|
||||||
if (strcmp(tzSign, '-') == 0) {
|
if (strcmp(tzSign, '-') == 0) { itimezone = itimezone * -1; }
|
||||||
itimezone = itimezone * -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set pointers
|
// Set pointers
|
||||||
if (iyear < 2000) iyear += 2000;
|
if (iyear < 2000) iyear += 2000;
|
||||||
|
|||||||
Reference in New Issue
Block a user