Need to block on Particle.publish?

I’m trying to build a battery powered device and would like to use deep sleep to get the most out of my device. It’s sleeping for a while and then waking up to check a couple of problems, then publishing the results. The problem I’m running into is I cannot figure out how to block until my device has finished publishing. Is there a good way to figure out if the device has done all of it’s cloud work before sleeping or do I need to resort to trying to find a sufficiently long delay to get this to happen?

If you publish to a webhook, you could subscribe to the hook response. Then you would know your message was received. That’s what I do in my app.

1 Like

Try adding a line of Particle.process() after your publish - this might already suffice - and if you want to make extra sure selfsubscribe to your event where you set a stopWaiting flag for which you wait in a Particle.process() loop (or you put the sleep in the handler)

1 Like