I apologize for the following generic question. I’m trying to see where in the Tracker Edge Software GPS data is available for reading.
Previously I used the Adafruit_GPS library on with an electron where I could use create an object called “GPS” and then be able to access the values anywhere. I leaned pretty heavily on the Adafruit examples.
You don't need to copy the forward declaration (aka prototype) of getLocation() you need to call it in your code.
The prototype only tells you how you need to call the function when you want it to do its thing.
if (millis() - temp_timer >= 1000){
temp_timer = millis();
LocationPoint lp; // declare a variable to hold your data
getLocationPoint(lp); // call the function to fill that variable with your desired data
Serial.println(lp.latitude); // use the requested data now stored in your variable
}
This doesn't work as you intend since LocationPoint is only a struct (like a datatype) but not a variable of that type so it cannot hold any data.
Just like you cannot live in the blueprint of your house
I feel like I’m close and I understand your explanation, but I’m not understanding the function you are calling getLocationPoint(lp). I get a compile error that getLocationPoint(lp) function does not exist and I’m not able to find it in the location_service.cpp reference.
Is there really nothing I need to do earlier in my code?
#include "Particle.h"
#include "tracker_config.h"
#include "tracker.h"
#include "Process.h"
#include "tracker_location.h"
#include "location_service.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(AUTOMATIC);
PRODUCT_ID(secret);
PRODUCT_VERSION(FIRMWARE_VERSION);
SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
{ "app.gps.nmea", LOG_LEVEL_INFO },
{ "app.gps.ubx", LOG_LEVEL_INFO },
{ "ncp.at", LOG_LEVEL_INFO },
{ "net.ppp.client", LOG_LEVEL_INFO },
});
Process Main;
// I want to start something for getLocation,
// but the spec says it already starts up
static long temp_timer = 0;
void setup()
{
Tracker::instance().init();
Serial.begin(115200);
Main.setup();
}
void loop()
{
Tracker::instance().loop();
Main.loop();
if (millis() - temp_timer >= 1000){
temp_timer = millis();
LocationPoint lp; // declare a variable to hold your data
getLocationPoint(lp); // call the function to fill that variable with your desired data
// Adam-But this function is not anywhere in location_service.cpp ?
Serial.println(lp.latitude); // use the requested data now stored in your variable
}
}
Compile Error:
main.cpp:59:28: error: 'getLocationPoint' was not declared in this scope
I would avoid calling any class, structure or variable “Main” simply because ‘C’ uses main() as its primary startup function. Be a little more creative! I also assume the Main class is defined in Process.h?
The timer variable temp_timer doesn’t need to be declared static and it should ideally be declared unsigned long or unint32_t since time is not signed.
You do not need to have tracker_location.h or location_service.h#includes since these are already included in tracker.h
There is no such function as getLocationPoint()!! The correct function is getLocation()
Finally, in the docs, you will seegetLocation() - LocationService, indicating that this function is part of the LocationService class. To correctly access this function you need to use the following form:
#include "Particle.h"
#include "tracker_config.h"
#include "tracker.h"
#include "Process.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(AUTOMATIC);
PRODUCT_ID(secret);
PRODUCT_VERSION(FIRMWARE_VERSION);
SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
{ "app.gps.nmea", LOG_LEVEL_INFO },
{ "app.gps.ubx", LOG_LEVEL_INFO },
{ "ncp.at", LOG_LEVEL_INFO },
{ "net.ppp.client", LOG_LEVEL_INFO },
});
Process Main;
// I want to start something for getLocation,
// but the spec says it already starts up
static long temp_timer = 0;
void setup()
{
Tracker::instance().init();
Serial.begin(115200);
Main.setup();
}
void loop()
{
Tracker::instance().loop();
Main.loop();
if (millis() - temp_timer >= 1000){
temp_timer = millis();
LocationPoint lp; // declare a variable to hold your data
Tracker::instance().locationService.getLocation(lp); // call the function to fill that variable with your desired data
// Adam-But this function is not anywhere in location_service.cpp ?
Serial.println(lp.latitude); // use the requested data now stored in your variable
}
}
haha! Agreed @ScruffR, I should have figured it out.
I will say though, that needing to add the Tracker::instance().locationService. part at the beginning before.getlocation() is what threw me off.
I don’t have a good understanding of what’s happening with this syntax.
However, now that I know it exists I have a pretty clear view of how it will work going forward.