vshymanskyy / TinyGSM

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

NTPServerSync() fails to return the appropriate status upon success for SIM7000G #791

Open cognoquest opened 6 months ago

cognoquest commented 6 months ago

LiLYGOSIMCOM SIM7000G SIM7000G R1529 TinyGSM version: 0.11.7

I am using the AllFunctions.ino example code and implemented the following functions: TINY_GSM_TEST_GPRS TINY_GSM_TEST_NTP TINY_GSM_TEST_TIME

Everything works well during the synchronization, the modem gets updated. The issue that I am having is with the function NTPServerSync returning the value 255 when the synchronization is successful.

For my modem the request network synchronization AT cmd returns more than just the value: 1. It appends to the value: ,"datetime", example of this: 1,"2024/05/23,17:44:42"

Note that I could not find this documented in the SIM7000 Series_AT Command Manual hence no surprise that it is not parsed properly in TinyGSM by the function TinyGsmIsValidNumber.

I recreated/modified the function: TinyGsmIsValidNumber from TinyGsmNTP.tpp with:

`... if (str.length() >= 2 && str.substring(0, 2).equals("1,")) {return 1;}

if (!(str.charAt(0) == '+' || str.charAt(0) == '-' || isDigit(str.charAt(0)))) return false; ...`

By the way great library ... thks