 #include <SPI.h>
 #include <RFM22.h>
 #include <TinyGPS.h>
- 
-#define ASCII 7          // ASCII 7 or 8
-#define STOPBITS 2       // Either 1 or 2
-#define TXDELAY 0        // Delay between sentence TX's
-#define RTTY_BAUD 50    // Baud rate for use with RFM22B Max = 600
+
+#define ASCII 7                 // ASCII 7 or 8
+#define STOPBITS 2              // Either 1 or 2
+#define TXDELAY 0               // Delay between sentence TX's
+#define RTTY_BAUD 50            // Baud rate for use with RFM22B Max = 600
 #define RADIO_FREQUENCY 434.160
 
 


float flat, flon = 0;
unsigned long age;
char latbuf[12] = "0", lonbuf[12] = "0" ,altbuf[12] = "0";
int hour = 0 , minute = 0 , second = 0, oldsecond = 0, sats = 0;
unsigned long date, time;
long int ialt = 123;

long int ticks = 1;
 
byte gps_set_sucess = 0 ;

bool newData = false;


}

// Calculate expected UBX ACK packet and parse UBX response from GPS
boolean getUBX_ACK(uint8_t * MSG)
{
  uint8_t b;
  uint8_t ackByteID = 0;
  uint8_t ackPacket[10];
  unsigned long startTime = millis();
  //mySerial.print(" * Reading ACK response: ");

  // Construct the expected ACK packet    
  ackPacket[0] = 0xB5;          // header
  ackPacket[1] = 0x62;          // header
  ackPacket[2] = 0x05;          // class
  ackPacket[3] = 0x01;          // id
  ackPacket[4] = 0x02;          // length
  ackPacket[5] = 0x00;
  ackPacket[6] = MSG[2];        // ACK class
  ackPacket[7] = MSG[3];        // ACK id
  ackPacket[8] = 0;             // CK_A
  ackPacket[9] = 0;             // CK_B

  // Calculate the checksums
  for (uint8_t i = 2; i < 8; i++) {
    ackPacket[8] = ackPacket[8] + ackPacket[i];
    ackPacket[9] = ackPacket[9] + ackPacket[8];
  }

  while (1) {

    // Test for success
    if (ackByteID > 9) {
      // All packets in order!
      //mySerial.println(" (SUCCESS!)");
      return true;
    }
    // Timeout if no valid response in 3 seconds
    if (millis() - startTime > 3000) {
      //mySerial.println(" (FAILED!)");
      return false;
    }
    // Make sure data is available to read
    if (Serial.available()) {
      b = Serial.read();

      // Check that bytes arrive in sequence as per expected ACK packet
      if (b == ackPacket[ackByteID]) {
        ackByteID++;
        //mySerial.print(b, HEX);
      } else {
        ackByteID = 0;          // Reset and look again, invalid order
      }

    }
  }
}
