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

getGsmLocation problems with SIM7070 / SIM7070G #697

Open Limon93 opened 1 year ago

Limon93 commented 1 year 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: SIM7070G R1951.04 Main processor board: ESP32 TinyGSM version: 0.11.5

Scenario, steps to reproduce

Retriving GSM Location with getGsmLocation()

Expected result

some sort of not so much accurate location data

Actual result

no data initially, found out that the parameter pdpidx (PDP context id) set inside method getGsmLocation() with command thisModem().sendAT(GF("+CLBS=4,1")); (inside TinyGsmGSMLocation.tpp at line 104 to enable GSM location functionality) differs from the one the module uses to connect to GPRS.

In the SIM7070 case the pdpidx used to initialize gprs connection is set 0 and not 1 by this library at the line 250 of TinyGsmClientSIM7080.h: sendAT(GF("+CNCFG=0,1,\""), apn, "\",\"", user, "\",\"", pwd, '"');

[+CNCFG=X,...... where X is the desired pdpidx in a range from 0 to 3.]

The PDP context id needs to be the same for the GPRS connection and for the GSM location function or the module will not acquire any position. Fixed by changing these lines in TinyGsmGSMLocation.tpp:

-line 76 from: thisModem().sendAT(GF("+CLBS=1,1")); to: thisModem().sendAT(GF("+CLBS=1,0"));

-line 98 from: thisModem().sendAT(GF("+CLBS=4,1")); to: thisModem().sendAT(GF("+CLBS=4,0"));


After this first fix I started receiving fixes but with latitude and longitude swapped, fixed by changing these lines in TinyGsmGSMLocation.tpp:

-line 119 from: ilat = thisModem().streamGetFloatBefore(','); // Latitude to: ilon = thisModem().streamGetFloatBefore(','); // Longitude

-line 120 from: ilon = thisModem().streamGetFloatBefore(','); // Longitude to: ilat = thisModem().streamGetFloatBefore(','); // Latitude

SincHub commented 1 year ago

Hi Limon93, could you post the sketch for GsmLocation SIM7000?
Is there anything to know about modem setup?