Xinyuan-LilyGO / T-SIM7600X

124 stars 41 forks source link

Cannot stop GPS session via AT commands #105

Open PsySc0rpi0n opened 1 day ago

PsySc0rpi0n commented 1 day ago

Hello.

I'm using the example code from here and after the device is ready to take AT commands, it seems that I cannot stop the GPS session.

This is what I get:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1448
load:0x40078000,len:14844
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c

# Startup #
# Sending "AT" to Modem. Waiting for Response
# .
# Response:
AT
OK
#

***********************************************************
 You can now send AT commands
 Enter "AT" (without quotes), and you should see "OK"
 If it doesn't work, select "Both NL & CR" in Serial Monitor
 DISCLAIMER: Entering AT commands without knowing what they do
 can have undesired consequences...
***********************************************************

AT+CGPS?
+CGPS: 1,1

OK
AT+CGPS=0,1
OK
AT+CGPS?
+CGPS: 1,1

OK
AT
OK
AT+CGPS?
+CGPS: 1,1

OK
AT+CGPS=0,1
OK
AT+CGPS?
+CGPS: 1,1

OK
AT+CGPS=0
OK
AT+CGPS?
+CGPS: 1,1

OK
AT+CGPS?
+CGPS: 1,1

OK

So, for some reason I cannot get the GPS session to stop. Why is this? Any common reason?

TexeCode07 commented 1 day ago

i see similar result in case i respond before its 2s result : AT+CGPS? +CGPS: 0,1 OK AT+CGPS=1 OK AT+CGPS? +CGPS: 1,1 --------if respond fast AT+CGPS? +CGPS: 1,1 OK AT+CGPS=0 --- This Put OK AT+CGPS? +CGPS: 1,1 ---- wrong result as respond before 2s OK +CGPS: 0 ---- prev command response i think AT+CGPS? +CGPS: 0,1 ---- now it works..

in AT Command module note: After the GPS closed, it should to wait about 2s~30s for start again. Reason: If the signal conditions are right (strong enough signals to allow ephemeris demodulation) or ephemeris demodulation is on going, sometimes MGP will stay on longer in order to demodulate more ephemeris. This will help the engine provide faster TTFF and possibly better yield later (up to 2 hours), because it has the benefit of more ephemeris available. https://m2msupport.net/m2msupport/atcgps-start-stop-gps-session/

PsySc0rpi0n commented 22 hours ago

Yes, I also read about that note. But I also tried to wait longer than that period of time and it was still not working. So, I issued a AT+CFUN command to restart the modem, and after that I was able to start/stop GPS sessions almost freely! Like almost immediately one after the other! So, I have no idea what was keeping the GPS session stuck. I'l still leave this issue open so that we can still discuss about it in the next days, if needed!

PsySc0rpi0n commented 16 hours ago

As a side note, I did something like this to wait for the modem response before issuing new AT command:

bool sendATCommand (const char* command, const char* expectedResponse,
                   unsigned long timeout){
    SerialAT.println (command);
    unsigned long startTime = millis();

    String response = "";
    while (millis() - startTime < timeout){
        while (SerialAT.available()){
            char c = SerialAT.read();
            response += c;
            if (response.indexOf(expectedResponse) != -1){
                Serial.print("Response: "), Serial.println(response);
                return true;
            }
        }
    }
    Serial.println("Timeout for response...");
    return false;
}