This was exactly what I needed and it worked on the first try. I am powering off the GPS and using SLEEP_NETWORK_STANDBY for sleep mode, then using a function call to wake and turning the GPS back on. I plan to incorporate another function to change the sleep time from the UI. I really struggled to wrap my head around this and it turned out to be pretty simple, so here’s all the components of my code in case it helps anyone else.
Setup (using AssetTrackerRK) and my savePower function
void setup() {
Particle.connect();
Particle.function("savePower", savePower);
Serial.begin();
pinMode(D6, OUTPUT);
digitalWrite(D6, LOW);
t.gpsOn();
t.startThreadedMode();
startFix = millis();
gettingFix = true;
t.antennaExternal();
}
int savePower(String command) {
if (command == "sleep") {
digitalWrite(D6, HIGH);
Cellular.command("AT+URING=1\r\n");
delay(1000);
System.sleep(RI_UC, RISING, 120, SLEEP_NETWORK_STANDBY);
}
else if (command == "wake") {
digitalWrite(D6, LOW);
startFix = millis();
gettingFix = true;
Cellular.command("AT+URING=0\r\n");
}
else {
return 0;
}
return 1;
}
My javascript being called from the web UI thanks to the awesome tutorial from @bko
function savePower(command) {
var requestURL = "https://api.spark.io/v1/devices/" + deviceID + "/savePower/";
$.post( requestURL, { params: command, access_token: accessToken });
}
Thank you @rickkas7, you’re a lifesaver!