Getting location for Curl to Asset tracking

When ever time I make a request

curl "https://api.particle.io/v1/devices/12345/gps?access_token=xxxxxxxx "
-d args=G
-d access_token=6789
""
and return this

{“id”:“12345”,“last_app”:"",“connected”:true,“return_value”:0}

How can i do to make a return to get location info like the one on the events?

Particle.function() calls will only ever return one integer value.
If you want the function to give you the coordinates you need to Particle.publish() the data from within that function or you could use a Particle.variable() to request the last read location.

AFAIK, the Asset Tracker Sample does already publish.

Have a look at https://console.particle.io/logs to see your events.

1 Like

I changed
void setup() {
Particle.variable(“tmode”, transmitMode);
Particle.variable(“batt”, batteryStatus);
Particle.variable(“gps”, gpsPublish);
}

but the return still not what I’m looking for

{“cmd”:“VarReturn”,“name”:“gps”,“result”:true,“coreInfo”:{“last_app”:"",“last_heard”:“2017-10-23T19:19:29.911Z”,“connected”:true,“last_handshake_at”:“2017-10-23T19:10:24.823Z”,“deviceID”:“12345”,“product_id”:10}

please advice, thank you

This is not how Particle.variable() works.
These are functions, but Particle.variable() expects variables

Go back to the original code and check the console as I said before.

Additionally you can add a global char gpsLocation[64], register this as Particle.variable() in setup() and set its value in your code (e.g. inside gpsPublish() and/or regularly in loop()).

2 Likes

I got it to work now, just like you posted. Thanks a lot.

3 Likes