Why can I get GPS fix while Im an GSM mode

Good evening,
I still have difficulties to understand the user of gps and gsm mode. I am sorry.
I worked hard I can have good result.
Here is my code, where I am going to explain.
Note, now, I work wirh Leonardo board instead of UNO
Fiest I turn up the module. I will not past all function as the setup loop works fine
steup()
Now the loop() loop does simply
Does the gps mode is a way to receive the GPS fix automoticaly from Serial?
In my case, I can I switch S3 to GSM mode?
Then could you clearly telll me why I have to switch to GPS mode. I carefuly look at the Sketc exemple and particularely to http://www.dfrobot.com/wiki/index.php/G ... indication (The last, at the bottom "GPS Sample Code").
I observed that the GPS mode is enabled at the end of the start_up function, and it stay at the gps mode. I also never observed the command AT+CGPSINF= to get the GPS fixes.
Could you clarify me that. It would be very helpfully.
Many many thank
I still have difficulties to understand the user of gps and gsm mode. I am sorry.
I worked hard I can have good result.
Here is my code, where I am going to explain.
Note, now, I work wirh Leonardo board instead of UNO
Fiest I turn up the module. I will not past all function as the setup loop works fine
steup()
Code: Select all
From now, I AM ON GSM MODEvoid setup()
{
// TURN THE SERIAL AT 9600 baut
Serial.begin(baud_rate); // Comm to PC
while(!Serial); // while the serial stream is not open, do nothing:
#ifdef LEONARDO
Serial1.begin(baud_rate); // Comm to GPS/GSM
while(!Serial1); // while the serial stream is not open, do nothing:
#endif
delay(4000); // Wait for 4sec after begin
if(debug)
{
Serial.println(F("\n******************************"));
Serial.println(F("STARTING SYSTEM Read AT stream"));
Serial.println(F("******************************"));
}
// SET THE PIN
pinMode(pin_gsm,OUTPUT); // Set the pins
pinMode(pin_gps,OUTPUT);
pinMode(pin_power,OUTPUT);
powerUpModule:
// POWER THE MODULE. THE powerUp function will attempt 4 time if AT does not return RDY
if(powerUp(4)) // Nb of attempt
{
// Enabling GSM mode
gsm_enable();
/*
the gsm_enable does
digitalWrite(pin_gsm,LOW); //Enable GSM mode
digitalWrite(pin_gps,HIGH); //Disable GPS mode
delay(2000);
*/
// Staring GPS AT+CGPSPWR=1 AT+CGPSRST=0.
if(start_gps())
{
readyToGo = true;
if(debug)
{
Serial.println(F("\n***********"));
Serial.println(F("READY TO GO"));
Serial.println(F("***********\n"));
}
}
else
{
// gps or rst does not return OK
readyToGo = false;
goto powerUpModule;
}
}
else
{
// Could not be poweredUp
if(debug) Serial.print(F("Could not powerup the module."));
readyToGo = false;
}
}
Now the loop() loop does simply
Code: Select all
To understand my question, look at the two following function
void loop()
{
if(readyToGo)
{
if(debug) serialhwread();
// Check the gps stat
if(gps_stat() > 0)
{
// Display gps fixes
gps_read();
}
delay(5000);
}
}
Code: Select all
and
int gps_stat(void)
{
if(debug) Serial.println(F("\n> Getting GPS Stat"));
int val = 0;
if(strstr(read_AT_string("AT+CGPSSTATUS?",3000),"OK") != NULL)
{
if(strstr(buffer,"+CGPSSTATUS: Location Unknown") != NULL)
{
val=0;
}
if(strstr(buffer,"+CGPSSTATUS: Location Not Fix") != NULL)
{
val=1;
}
if(strstr(buffer,"+CGPSSTATUS: Location 2D Fix") != NULL)
{
val=2;
}
if(strstr(buffer,"+CGPSSTATUS: Location 3D Fix") != NULL)
{
val=3;
}
}
else
{
if(debug) Serial.println(F(" Could not get GPS Stat"));
val=0;
}
/*
"Location Unknown": if GPS is not run
"Location Not Fix": after GPS is run ,and haven’t fixed,
"Location 2D Fix" : after GPS status is 2D fixed,
"Location 3D Fix" : after GPS status is 3D fixed.
*/
if(debug_buffer)
{
Serial.println(F("------- Show buffer------"));
Serial.println(buffer);
Serial.println(F("-------------------------\n"));
}
return val;
}
Code: Select all
You can observe, I use the AT command
// read data to gps_buf[] from GPS
static int gps_read () {
read_AT_string("AT+CGPSINF=2",6000);
Serial.println(F("------- Show buffer------"));
Serial.println(buffer);;
Serial.println(F("-------------------------\n"));
}
Code: Select all
After about 20sec, I got fixes while I never switch the GPS mode
AT+CGPSSTATUS?
AT+CGPSINF=2
Code: Select all
But why!!!!!!digitalWrite(pin_gps,LOW); //Enable GPS mode
digitalWrite(pin_gsm,HIGH); //Disable GSM mode
delay(2000);
Does the gps mode is a way to receive the GPS fix automoticaly from Serial?
In my case, I can I switch S3 to GSM mode?
Then could you clearly telll me why I have to switch to GPS mode. I carefuly look at the Sketc exemple and particularely to http://www.dfrobot.com/wiki/index.php/G ... indication (The last, at the bottom "GPS Sample Code").
I observed that the GPS mode is enabled at the end of the start_up function, and it stay at the gps mode. I also never observed the command AT+CGPSINF= to get the GPS fixes.
Could you clarify me that. It would be very helpfully.
Many many thank
2014-09-15 19:16:41 Hi Pierrot,
In the older version, UART select is the switch of the GSM and GPS, but it is not very convenient to change its working mode. So if the switch in middle, you could control it via code.
In the USB debugging mode, if you want to check the GPS data, turn the switch to GSM side, and input AT command, then you need switch it GPS side to check the data in the monitor.
And for the GPS fix, I don't have information regarding this feature yet. It is better to check its datasheet.
Anyway, I find a library about this chip. maybe you can take a look. Wrote by marco
https://github.com/MarcoMartines/GSM-GPRS-GPS-Shield
Grey.CC
In the older version, UART select is the switch of the GSM and GPS, but it is not very convenient to change its working mode. So if the switch in middle, you could control it via code.
In the USB debugging mode, if you want to check the GPS data, turn the switch to GSM side, and input AT command, then you need switch it GPS side to check the data in the monitor.
And for the GPS fix, I don't have information regarding this feature yet. It is better to check its datasheet.
Anyway, I find a library about this chip. maybe you can take a look. Wrote by marco
https://github.com/MarcoMartines/GSM-GPRS-GPS-Shield
