Spark.publish() & Spark.sleep() - How to make sure publish() is finished?

Hi guys,

Is there a way to make sure that event was published?

In my project I have the following snippet

void loop() {
    ...
    Spark.publish(...);
    Spark.sleep(SLEEP_MODE_DEEP ...);
}

What I noticed is that the event is not published most of the time. The only improvement I come up with is to add artificial delay before sending Spark to sleep.

void loop() {
    ...
    Spark.publish(...);
    delay(5000);
    Spark.sleep(SLEEP_MODE_DEEP ...);
}

PROBLEM: I understand that Spark.publish requires variable amount of time to finish depending on the quality of a network connection/server’s load/other factors. Is there a way to make sure that Spark.publish is finished before calling Spark.sleep ?

1 Like

A forum search for complete came up with this