[IMPROVEMENT] Wake publish sleep example docs

Hi, I was reading this example Wake publish sleep example

I wonder if it could be improved and add the option to send all the cloud messages before going to sleep WAIT_CLOUD:

  • SystemSleepFlag::WAIT_CLOUD

So instead of the example doing this:

                config.mode(SystemSleepMode::HIBERNATE)
                    .duration(sleepTime);
                System.sleep(config);

It could do this?

                config.mode(SystemSleepMode::HIBERNATE)
                    .flag(SystemSleepFlag::WAIT_CLOUD)
                    .duration(sleepTime);
                System.sleep(config);

FYI @Colleen @rickkas7
thanks

1 Like

@gusgonnet ,

Love this idea.

Also for publishing using publishQueuePOSIX, there is a function called getCanSleep() but I have never been able to make it work correctly.

Chip

1 Like

hum, I was just wondering how the WAIT_CLOUD would work with the PublishQueuePosixRK and PublishQueueAsyncRK libraries.

Maybe @rickkas7 can shed some light here?

1 Like

It’s generally better to use the graceful disconnect global setting Particle.setDisconnectOptions instead.

Setting WAIT_CLOUD just temporarily sets the graceful option to true, but it’s better to set the global option so you can also set how long you want to wait. And setting the global option makes it work for all sleep calls, as well as system reset.

4 Likes