GPS program will not compile please help

i am trying to get this GPS tracking program to work but i cant even get it to compile i have got rid of most of the errors but there are just a few more i need help with
attached is the sketch

i don’t know if anyone can help so it can just compile then i can start to edit

tobeuploaded.zip (5.06 KB)

#define Location

Location::Location () {
  isValid = false;
};

What the hell is the #define statement for?

The Location.cpp file is missing a #include statement to include GPS.h.

The type Adafruit_GPS is undefined.

The Location.h file is missing a #include statement to include Arduino.h.

thanks i will try it … i got it sent to me by someone and it had a lot more errors in than that when i received it

ok i have in Location.h

#include <Arduino.h>



class Location {
  public:
    Location ();
    Location (Adafruit_GPS);

    boolean isValid;

    float latitude;
    float longitude;
    float hdop;
    float altitude;

    char latitude_c[12];
    char longitude_c[12];
    char hdop_c[5];
    char altitude_c[6];

    void set(Adafruit_GPS);
    boolean isEqual(Location);
  private:
    float toDecimal(float, char);
};

also Location.cpp

#include <Adafruit_GPS.h>

#include "Location.h"


Location::Location () {
  isValid = false;
};

Location::Location (Adafruit_GPS gps) {
  set(gps);
};

void Location::set (Adafruit_GPS gps) {
  isValid = (gps.fix == 0) ? false : true;

  latitude = toDecimal(gps.latitude, gps.lat);
  longitude = toDecimal(gps.longitude, gps.lon);
  hdop = gps.HDOP;
  altitude = gps.altitude;

  dtostrf(latitude, 8, 6, latitude_c);
  dtostrf(longitude, 8, 6, longitude_c);
  dtostrf(hdop, 1, 2, hdop_c);
  dtostrf(altitude, 4, 1, altitude_c);
};

boolean Location::isEqual(Location location) {
  if (isValid != location.isValid) return false;
  if (abs(latitude - location.latitude) > .001) return false;
  if (abs(longitude - location.longitude) > .001) return false;
  if (abs(altitude - location.altitude) > .1) return false;

  return true;
};

float Location::toDecimal (float nmeaCoord, char direction_letter) {
  uint16_t wholeDegrees = 0.01 * nmeaCoord;
  int direction_modifier = (direction_letter == 'S' || direction_letter == 'W') ? -1 : 1;
  return (wholeDegrees + (nmeaCoord - 100.0 * wholeDegrees) / 60.0) * direction_modifier;
};

is not

SoftwareSerial gpsSerial = SoftwareSerial(GPS_TX, GPS_RX);
Adafruit_GPS gps = Adafruit_GPS(&gpsSerial);

in the first tab not defining Adafruit_GPS

is not...in the first tab not defining Adafruit_GPS

The .ino file ic converted to a .cpp file and compiled.
The Location.cpp file is compiled. The Adafruit_GPS type is NOT defined anywhere that Location.cpp can see. You need a #include statement.

right i’ve done that and we are down to one error one i can’t really understand because its there and included
#include <keys.h>

gsm_tracker.ino:4:18: fatal error: keys.h: No such file or directory
compilation terminated.

and yes the tab and file is showing

i can't really understand because its there

where exactly is it ?

There are two ways to include a file:

#include <keys.h>

or

#include "keys.h"

Which one to use depends on where the file is. The quotes form is for when the file is in the same directory as the sketch.

yea already tried those but i get different errors on both entries

#include “keys.h”

In file included from Location.cpp:1:0:
/Volumes/HD2/Mike/documents/Arduino/libraries/gsm_tracker/gsm_tracker.ino:7:18: fatal error: keys.h: No such file or directory
 #include "keys.h"
                  ^
compilation terminated

#include <keys.h>

gsm_tracker.ino:4:18: fatal error: keys.h: No such file or directory
compilation terminated.

also if i delete keys file and put the defines in the main tab
and remove the include keys line

i still get keys.h: No such file or directory

even though there is no reference to that file anymore

also if i delete keys file and put the defines in the main tab
and remove the include keys line

i still get keys.h: No such file or directory

even though there is no reference to that file anymore

If you post the code, we can tell if the compiler is a bumbling idiot or if it is the operator that is the source of the problem.

i can tell you that… i’m a bumbling fool :slight_smile:

i’m still only 6 months into all this programming. but i’m getting there

when i received the program they keys file had 3 lines in it

#define SPARKFUN_PUBLIC_KEY "<Pub-Key>"
#define SPARKFUN_PRIVATE_KEY "<Pri-Key>"

#define MY_PHONE_NUMBER "<phoneNumber>"

and i just thought id get rid of the text Pub-Key, Pri-Key & PhoneNumber. With my Values

And i was getting errors on errors messing about trying to solve it

when all it was i was also to remove the <> between the text as well

where it may have been Obvious to some people. I thought id have to leave them in

But Anyway I started from scratch again and removed the <> and apart from a few small errors which point towards when it was written it was done aimed at an old version of the FONA library. i eventually got it to compile

Thanks Paul

mikewitney:
i am trying to get this GPS tracking program to work but i cant even get it to compile i have got rid of most of the errors but there are just a few more i need help with
attached is the sketch

i don't know if anyone can help so it can just compile then i can start to edit

Oh, man. I'm thinking "I bought a car, but it made this weird ticking noise so I started removing stuff from under the hood and now it doesn't make the noise but it won't go - please help me make my car go. Here's a photo."

Every line of that sketch that you got was there for a reason.