Hi Paulohm!
What you want to achieve is relatively simple, as the location function already takes into account if the device is moved when sampling from the GPS receiver.
The periodic location sampling is what you want, as described here: Time & Location Requests - Blues Developers
The important part here is the note at the end of the section "To preserve battery, when the Notecard is in periodic mode, GPS is only enabled if the built-in accelerometer detects movement since the last GPS enable. "
Next, you want to use the Location Tracking feature to automatically send the location to Notehub, see the documentation here: Time & Location Requests - Blues Developers
Simply for what you hav described, two commands need to be sent to the note card:
{
"req": "card.location.mode",
"mode": "periodic",
"seconds": 60
}
and
{
"req": "card.location.track",
"start": true,
"sync": true
}
However, with these interval times, this may not work as you expect. The GPS and Cellular radios cannot be turned on simultaneously, and with the startup time required for both, you are likely to get inconsistent data going to notehub. It would be better to not have the "sync": true
argument to card.location.track
but instead configure the note card to send data on a longer period (with the frequent location data being queued and sent in batches. To do this you would configure the periodic time in the hub.set
command as follows (for 30 minutes to send data and 4 hours to receive data):
{
"req": "hub.set",
"mode": "periodic",
"outbound": 30,
"inbound": 240
}
If sending the GPS data to notehub every minute is required, you will need to configure an external GPS module, see Advanced Notecard Configuration - Blues Developers