Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnect from the cloud before going to sleep #2206

Merged
merged 1 commit into from
Oct 5, 2020

Conversation

sergeuz
Copy link
Member

@sergeuz sergeuz commented Sep 29, 2020

Problem

By default, the Sleep 2.0 API leaves the protocol layer in whatever state it was before going to sleep and continues to use it after waking up from sleep without checking whether the session with the server is still valid.

Solution

Always disconnect from the cloud before going to sleep unless the network interface is used as a wake-up source. In the latter case, send a PING message to the server after waking up from sleep.

Steps to Test

  1. Verify that a sleepy device that doesn't use its network interface as a wake-up source successfully resumes its session when reconnecting to the cloud from a different address.
  2. Using one of the network interfaces as a wake-up source, verify that the device sends a ping message to the cloud after waking up from sleep.

References

  • [ch64208]

@sergeuz sergeuz added the bug label Sep 29, 2020
@sergeuz sergeuz added this to the 2.0.0 milestone Sep 29, 2020
Copy link
Member

@avtolstoy avtolstoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this!

@@ -29,8 +29,6 @@

void Spark_Signal(bool on, unsigned, void*);
void Spark_SetTime(unsigned long dateTime);
void Spark_Sleep(unsigned duration);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// on the disconnection options that can be set via Particle.setDisconnectOptions() or
// Particle.disconnect().
//
// TODO: Rename CLOUD_DISCONNECT_GRACEFULLY to CLOUD_DISCONNECT_IMMEDIATELY and invert its
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@avtolstoy avtolstoy added the ready to merge PR has been reviewed and tested label Oct 2, 2020
@avtolstoy avtolstoy merged commit 3594760 into develop Oct 5, 2020
@avtolstoy avtolstoy deleted the sleep_disconnect/ch64208 branch October 5, 2020 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ready to merge PR has been reviewed and tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants