vshymanskyy / TinyGSM

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

Automatic time zone update fails on Arduino MKR GSM 1400 #511

Closed jwindhager closed 3 years ago

jwindhager commented 3 years ago

[x] I have read the Troubleshooting section of the ReadMe

What type of issues is this?

[ ] Request to support a new module [ ] Bug or problem compiling the library [x] Bug or issue with library functionality (ie, sending data over TCP/IP) [ ] Question or request for help

What are you working with?

Modem: u-blox SARA-U201 (SARA-U201-03B-00) Main processor board: Arduino MKR GSM 1400 TinyGSM version: 0.10.9 Code: AllFunctions example

Scenario, steps to reproduce

Adapt the AllFunctions example to the Arduino MKR GSM 1400 board as specified here

Expected result

Successful output of the AllFunctions example

Actual result

The example fails upon enabling automatic time zone update with AT+CTZU=1. The extended error message ("SIM not inserted") is wrong. My guess is that either my network does not support automatic time zone update (NITZ at network registration seems to be an optional feature, see https://www.u-blox.com/sites/default/files/u-blox-CEL_ATCommands_UBX-13002752.pdf, page 63), I'm missing something, or the SARA-U201 firmware has a bug. When commenting out the following lines, everything works as expected: https://github.com/vshymanskyy/TinyGSM/blob/9498800b50baa46c1a0b3f6d0df68cbd3230c025/src/TinyGsmClientUBLOX.h#L194-L196

As a quick fix, I propose to simply ignore the return value of AT+CTZU=1 if it fails.

Debug and AT command log

...
00:20:54.780 -> [13190] Initializing modem...
00:20:54.780 -> AT
00:20:54.780 -> 
00:20:54.780 -> OK
00:20:54.780 -> AT+CFUN=16
00:20:54.913 -> 
00:20:54.913 -> OK
00:20:57.902 -> [16314] ### TinyGSM Version: 0.10.9
00:20:57.902 -> [16314] ### TinyGSM Compiled Module:  TinyGsmClientUBLOX
00:20:57.902 -> AT
00:20:59.994 -> AT
00:20:59.994 -> 
00:20:59.994 -> OK
00:20:59.994 -> ATE0
00:20:59.994 -> 
00:20:59.994 -> OK
00:20:59.994 -> AT+CMEE=2
00:20:59.994 -> 
00:20:59.994 -> OK
00:20:59.994 -> AT+CGMI
00:20:59.994 -> 
00:20:59.994 -> u-blox
00:20:59.994 -> 
00:20:59.994 -> OK
00:20:59.994 -> AT+GMM
00:20:59.994 -> 
00:20:59.994 -> SARA-U201
00:20:59.994 -> 
00:20:59.994 -> OK
00:20:59.994 -> [18407] ### Modem: u-blox SARA-U201
00:20:59.994 -> [18408] ### Modem: u-blox SARA-U201
00:20:59.994 -> AT+CTZU=1
00:20:59.994 -> 
00:20:59.994 -> +CME ERROR: SIM not inserted
00:20:59.994 -> [18412] Failed to restart modem, delaying 10s and retrying
...