PROGRAMING PROBLEM WHIT A7 GSM/GPS

Hi serve professionals dear
i use a7 gsm/gps to make a gps tracker,
in default gps , agps and NEMA output are Close !!!

for active gps For every time you turn on the a7 module i need to :
1- "AT+GPS=1"
2- "AT+AGPS=1"
3- "AT+GPSRD=N" > NEMA information from AT N seconds once the output port, the actual use of the N into digital.

this is my code:

#include <SoftwareSerial.h>
SoftwareSerial gps(10, 11); // RX, TX

int gpsYear;
int gpsMonth;
int gpsDay = 0;
int gpsHour;
int gpsMin;
int gpsSec;
float gpsLat0;
float gpsLong0;
float gpsLat;
float gpsLong;
String gpsSpeed; //km/h
float gpsBearing; //deg
String latF;
String longF;
String Year;
String DateF;
String TimeF;

void setup() {
  Serial.begin(9600);
  gps.begin(9600);
  
}

void loop() 
{
  if (gps.available() > 1) 
  {
    if (char(gps.read()) == 'R' && char(gps.read()) == 'M' && char(gps.read()) == 'C') 
    {
      gpsTime(gps.parseInt());
      gps.parseFloat(); //discard unnecessary part
      gpsLatLong(gps.parseFloat(), gps.parseInt(), gps.parseFloat(), gps.parseInt());
      gpsSpeed = String (gps.parseFloat()*1.852); //km/h
      gpsBearing = gps.parseFloat();
      gpsDate(gps.parseInt());
     
      Serial.print(DateF);
      Serial.print(" ");
      Serial.print(TimeF);
      Serial.print(" ");
      Serial.print(latF);
      Serial.print(" ");
      Serial.print(longF);
      Serial.print(" ");
      Serial.println(gpsSpeed);
    }
  }
  
}

void gpsTime(long UTC)
{
  gpsHour = int(UTC/10000);
  gpsMin = int(UTC%10000/100);
  gpsSec = int(UTC%100);
  String gpsHour1 = String(gpsHour);
  //String gpsMin1 = String(gpsMin);
  //String gpsSec1 = String(gpsSec1);
  
  TimeF=String(gpsHour1+":"+gpsMin+":"+gpsSec);
}

void gpsLatLong(float long2, int long1, float lat2, int lat1)
{
  gpsLat = int(lat1/100) + float(((lat1%100)+lat2)/60);
    latF=String(gpsLat,4);
    //Serial.print(latF);
    //Serial.print(" ");
  gpsLong = int(long1/100) + float(((long1%100)+long2)/60);
    longF=String(gpsLong,4);
    //Serial.println(longF);
}

void gpsDate(long dateRead)
{
  gpsDay = int(dateRead/10000);
  gpsMonth = int(dateRead%10000/100);
  gpsYear = dateRead%100; //last 2 digits, e.g. 2013-> 13
  Year="20"+String(gpsYear);
  DateF=String(Year + "-"+gpsMonth+"-"+gpsDay);
}

and this is my program output in serial monitor(GPSRD is set for 5 second) :

2017-7-19 14:19:49 32.4227 52.6457 0.00
2017-7-19 14:19:54 32.4227 52.6457 0.00
2017-7-19 14:20:9 32.4228 52.6457 0.00
2017-7-19 14:20:14 32.4228 52.6457 0.00
2017-7-19 14:20:19 32.4228 52.6457 0.00
2017-7-19 14:20:24 32.4227 52.6457 0.00
2017-7-19 14:20:29 32.4227 52.6457 0.00
...

but i have to active gps, agps and gpsrd in another program like this in serial monitor:

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte);
  }
}

and then upload the original program :slightly_frowning_face:

my idea is add this line in program :

#include <SoftwareSerial.h>
SoftwareSerial gps(10, 11); // RX, TX

int gpsYear;
int gpsMonth;
int gpsDay = 0;
int gpsHour;
int gpsMin;
int gpsSec;
float gpsLat0;
float gpsLong0;
float gpsLat;
float gpsLong;
String gpsSpeed; //km/h
float gpsBearing; //deg
String latF;
String longF;
String Year;
String DateF;
String TimeF;

void setup() {
  Serial.begin(9600);
  gps.begin(9600);
  delay(3000);
  gps.println("AT+GPS=1");
  delay(3000);
  gps.println("AT+AGPS=1");
  delay(25000);

  
}

void loop() 
{
  gps.println("AT+GPSRD");
  delay(5000);
  if (gps.available() > 1) 
  {
    if (char(gps.read()) == 'R' && char(gps.read()) == 'M' && char(gps.read()) == 'C') 
    {
      gpsTime(gps.parseInt());
      gps.parseFloat(); //discard unnecessary part
      gpsLatLong(gps.parseFloat(), gps.parseInt(), gps.parseFloat(), gps.parseInt());
      gpsSpeed = String (gps.parseFloat()*1.852); //km/h
      gpsBearing = gps.parseFloat();
      gpsDate(gps.parseInt());
     
      Serial.print(DateF);
      Serial.print(" ");
      Serial.print(TimeF);
      Serial.print(" ");
      Serial.print(latF);
      Serial.print(" ");
      Serial.print(longF);
      Serial.print(" ");
      Serial.println(gpsSpeed);
    }
  }
  
}

void gpsTime(long UTC)
{
  gpsHour = int(UTC/10000);
  gpsMin = int(UTC%10000/100);
  gpsSec = int(UTC%100);
  String gpsHour1 = String(gpsHour);
  //String gpsMin1 = String(gpsMin);
  //String gpsSec1 = String(gpsSec1);
  
  TimeF=String(gpsHour1+":"+gpsMin+":"+gpsSec);
}

void gpsLatLong(float long2, int long1, float lat2, int lat1)
{
  gpsLat = int(lat1/100) + float(((lat1%100)+lat2)/60);
    latF=String(gpsLat,4);
    //Serial.print(latF);
    //Serial.print(" ");
  gpsLong = int(long1/100) + float(((long1%100)+long2)/60);
    longF=String(gpsLong,4);
    //Serial.println(longF);
}

void gpsDate(long dateRead)
{
  gpsDay = int(dateRead/10000);
  gpsMonth = int(dateRead%10000/100);
  gpsYear = dateRead%100; //last 2 digits, e.g. 2013-> 13
  Year="20"+String(gpsYear);
  DateF=String(Year + "-"+gpsMonth+"-"+gpsDay);
}

but i dont see anything in serial monitor :frowning:

I think the GPS requires CR/LF line endings, so:

  gps.begin(9600);
  delay(3000);
  gps.print("AT+GPS=1\r\n");
  delay(3000);
  gps.print("AT+AGPS=1\r\n");
  delay(25000);