vshymanskyy / TinyGSM

A small Arduino library for GSM modules, that just works
GNU Lesser General Public License v3.0
1.91k stars 709 forks source link

Fix NTPServerSync #652

Closed gonzabrusco closed 1 month ago

gonzabrusco commented 2 years ago

Hello @SRGDamia1 @vshymanskyy thank you for your great work.

This PR fixes two issues with the NTPServerSync function.

1) Prior to this PR, you could not set negative timezones because the passed value was byte (which translates to uin8_t). Now the value passed it's an Int so you can set any timezone (from -47 to +48).

2) On old SIM800 the return code of +CNTP was always: +CNTP: <code> but now with newer modules you could also get the network time attached to the response like this: +CNTP: <code>[,<time>] . What I did to keep backward compatibility is to look for the ',' and remove all the leading characters if found. If not, assume the reply was just the <code>.

It is working perfectly on my SIM7000.

Thanks Gonzalo

gonzabrusco commented 1 year ago

Just one not to this. With the SIM7000 that worked perfectly. But now I'm using the SIM7070 and this stopped working. The reason is that the SIM7070 code uses another CNTPCID. You have to use 0 insted of 1 for some reason. Maybe we should separate the code of NTPServerSyncImpl for SIM7080 family modules.

gonzabrusco commented 1 year ago

Ok I did the change I suggested erlier. Now every module on the 70xx family can have it's own NTP function (but if not, they use the template ones). Now both 7000 and 7070 are working as expected.