I notice that in about 10% of the cases, when an Electron connects it does not attempt to publish its data. I haven’t been able to replicate this issue yet using the serial monitor so I’m not 100% what exactly happens with the Electron - but I have 10 field Electrons atm and often I only get 8-9 webhook responses.
I currently have the following code:
case CONNECT:
...
if (Particle.connected()) {
initialized = false;
Serial.println("connection established!");
stateTime = millis();
state = PUBLISH;
break;
}
...
Is there anything in here that could create an issue? Would Particle.connected() ever return false even if the device is connected? Is it possible a Particle.Publish() may fail once? Is there any way to verify that data has been published, before putting the Electron into Sleep mode?
For the past 3 weeks I’ve had had 12 devices running this code for their publishing. A few times I actually experienced publishSuccess returning false (see example above) even though the data was sent; So they published the max. number of times (rather than once). This happened in about 5% of the cases.
Does anyone have any idea on how to improve this code to prevent this from happening? Or is it just a limitation of publish-with-ack?