vshymanskyy / TinyGSM

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

src/TinyGsmModem.tpp: fix registration state #503

Closed ffontaine closed 3 years ago

ffontaine commented 3 years ago

As specified in the ETSI standards (e.g. ETSI TS 127 001), CREG and CEREG responses can contain optional parameters: +CEREG: <n>,<stat>[,<tac>,<ci>[,<AcT>]]

For example, the Monarch GMS01Q returns the following response: +CEREG: 2,1,"3982","00DF3B03",7

This results in TinyGSM setting state as '7' instead of 1 preventing any connection.

Fix this by picking the next integer after the first ',' which will always works (with or without optional parameters)

Signed-off-by: Fabrice Fontaine fabrice.fontaine@orange.com

ffontaine commented 3 years ago

Do you have some comments on this Pull Request? I could move this fix to be Sequans specific but I think that it would be better to apply it for all modems.

SRGDamia1 commented 3 years ago

I'm sorry, I just haven't had a chance to test it.

ffontaine commented 3 years ago

OK, thanks for your answer, I asked because you were very quick on merging my first PR. Take your time to be sure that this PR doesn't break anything and thanks for your great work on TinyGSM.

SRGDamia1 commented 3 years ago

It's probably perfect. I just half-remember that there was something weird about the parseInt function that I haven't gotten a chance to confirm.

ffontaine commented 3 years ago

parseInt is already used in other source files so I assume that everything should be ok.