Following from a previous topic I’ve posted, I’m planning to use Cellular.on() / Cellular.off() to conserve battery power in my Electron application. I’m also planning to take advantage of Particle.function() capabilities to remotely invoke functions on the Electrion. I’d also like to keep my options open for OTA firmware updates.
So my question is, when my sketch uses Cellular.off() and Cellular.on(), and System.sleep functionality, how are cloud interactions / pattern affected by this kind of power conserving behavior? Here are some specifics I’m wondering about:
Do I need to remain connected for some period of time after calling Cellular.on() and receiving Cellular.ready() confirmation before calling Cellular.off() in order to guarantee pending Particle.function() events are received and executed?
Does the Electron need to be connected at the instant that the POST /v1/devices/{DEVICE_ID}/{FUNCTION} API call happens, or is the function invocation queued in the Particle Cloud and delivered on the next device connection to the Cloud?
When are Cloud-pushed firmware updates delivered to the devices, and do the power saving tactics I’ve described interfere with those mechanisms? If they do interfere generally, what boundaries do I need to observe in order to avoid that kind of interference?
Cellular.on() & Cellular.ready() are not enough to receive Particle.function() calls (you need Particle.connect()/Particle.connected()) and these calls are never pending, but only issued once and have to be serviced within a few seconds, otherwise the call will timeout.
see answer to 1.
Yes, they are effected since user OTA flash orders are not queued, only Product OTA updates via the Particle Console are “queued” by default, but you could set up your own OTA updating server that could subscribe to an online-event of your device.
@ScruffR thanks! As far as OTA, I should have been clearer in that I am thinking of a Product case, not an individual device case here.
So, first, in that case what is required to receive a Product firmware push? Do I have to write firmware that intervenes / supports / participates in OTA in that case? I'm envisioning a sequence like:
Cellular.on() -> Cellular.connected() -> do internet related stuff -> Particle.connect() -> Particle.connected() -> Product OTA needed (Yes or No) ? (Yes) Stay Connected and eventually reset automatically because Product OTA finishes : (No) Cellular.off() -> Sleep
Second, with delivering Particle.function() messages to a particular device (within a given Product umbrella), and with the battery conserving strategy above, what is a recommended strategy if Particle.function() isn't "reliable" under intermittent Cloud connection? I suppose I could just keep trying with sufficient frequency to "catch" the device while it's briefly (with remain connected duration built into firmware) Particle.connected() and before Cellular.off(), until I get a successful response from the Particle Cloud API call. Since Particle.functions() are free according to the pricing page, that seems like a viable, if inelegant, approach. Is there a better (or recommended) approach available that I'm not thinking of (or haven't noticed)?