So, we have had a recurrent issue where our devices occasionally believe data has been sent and all’s good, but actually we can’t find any track of it anywhere (SUGGESTION: show more than the last 10 successes/fails in the console for a given webhook)
Here’s the part of the code that sends the data:
TransmitStatus Connector::particlePublish(char *event, uint8_t *data, int &dataLength) {
TransmitStatus result = TRANSMIT_FAILED;
_transmittedMessages++;
if (!Particle.connected()) {
Log.trace("Disconnected!");
return TRANSMIT_FAILED;
}
result = Particle.publish(event, convertData(data, dataLength), 30, PRIVATE | WITH_ACK) != false ? TRANSMIT_OK : TRANSMIT_FAILED;
Log.trace("publ. %dB: %u",dataLength,result);
return result;
}
(if necessary for a better understanding, what convertData
does is convert binary data to base64)
I read other topics about the fact the electron had no way to know if it was really connected or not… I’m wondering if it is possible that the publish function confirms sending even though the data is sent to a blackhole (AKA “UDP datagram”…)?
Any help/suggestion welcome.
This problem has been bothering us for a long time (as in close to 2 years) although we always tended to blame the code (and the coder, me), and implementing a confirmation is a bit problematic mostly because we want to stay connected as little as possible (a webhook callback could be a partial solution, confirming data reached Particle, but would that confirm it reached Google on the other side of the webhook?)
Side note, we sleep in-between the connections (to save battery, the devices are far from everything/everyone), and put everything to a rest, including the connection, so we fully reconnect each time.
Thanks,
Phil.
PS: we can’t seem to reproduce the fail on demand, and we have no access to the Serial to monitor failing devices (even less constantly)