I have been working on an Android app and want to ensure that the Electron is running the correct program. To do this I created a cloud variable:
Since I am using the variable name (not the value), I can check the version a lot faster since the Particle Cloud retains a list of registered variables and does not need to talk to the device to get the name (rather than value) of the variable for each request. (I am using this API call: https://api.particle.io/[device_name/id]?access_token=[access_token]")
The problem I am running into is when the Electron is in safe mode. In this case, the Electron remains connected (so the last_head statistic is continuously updated to the Cloud) & the variable “Version-v6e” remains on Particle’s Cloud variable list.
I basically have no way of telling the difference between safe-mode and regular operation without contacting the device each time. I want the device to contact the cloud and remove the variable “Version-v6e” from the variable list before it enters safe mode.
Is there a way to remove the variable from the Particle Cloud before entering safe mode?
I initially thought I could do something along the lines of:
if(Particle.variable("Version-v6e", "") == true) Particle.variable("Version-v6e", "") = false;
This didn’t work.
I’m considering a work-around, but am looking for an easier way.
My idea is to create a retained boolean variable, and then reset the Electron. When the device restarts, check the retained boolean in setup(): if true enter safe mode & make boolean false, else register cloud variable “Version-v6e”.
I really don’t want to make safe-mode a retained variable since, I don’t want to unplug/flash the Electron every time it is not supposed to be in safe mode. Any suggestions?