@rickkas7, am implementing your excellent PublishQuequeAsyncRK library, https://github.com/rickkas7/PublishQueueAsyncRK, v0.0.4.
Have added a simple enhancement to invoke a callback within the checkQuequeState() method when there has been excessive time elapsed in waiting for transmission and/or acknowledgement, which may never happen.
The idea is that the callback function handles the “stuck” event, for example by saving the event to file on an SD CARD so as to be processed in an offline manner later on. The callback returns a boolean to indicate “you can delete the event”.
Am wondering if you could comment on this piece of your code ("// UMD comments" are mine):
auto request = Particle.publish(eventName, eventData, data->ttl, flags);
// Use this technique of looping because the future will not be handled properly
// when waiting in a worker thread like this.
while(!request.isDone()) { // UMD - when will isDone() return true?
delay(1);
}
bool bResult = request.isSucceeded(); // UMD - what is the difference between
// isSuceeded() and isDone?
if (bResult) {
// Successfully published
log.info("published successfully");
discardOldEvent(false);
}
else {
// Did not successfully transmit, try again after retry time
log.info("published failed, will retry in %lu ms", failureRetryMs);
stateHandler = &PublishQueueAsync::waitRetryState;
}
Am just wondering if request.isDone() means “transmitted” and request.isSucceeded() means “ACK received”.
.
I have been able to produce a situation where request.isDone() does not return true by turning of data on a mobile hotspot (hence the callback strategy enhancement), and hence never exiting the loop.
Next question - wondering why discardOldEvent() has the option to remove the first or second event?