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

Publish last reset event on session resumption #2771

Conversation

monkbroc
Copy link
Member

Problem

When the device reboots and resumes its session (for example after System.reset() and after pin reset on Gen 3), the spark/device/last_reset event is not published. It's only published when a new session is established.

Solution

Publish last reset reason whenever the first cloud connection is established, regardless if it's a new session or a resumed session.

Note: there's a lot of duplication in if (!session_resumed) part of Spark_Handshake and it's not clear if additional things in the if should also be done in the else. Please think about this as part of the review for this PR.

Steps to Test

Ensure a spark/device/last_reset is published in the following conditions

  • Power on reset
  • Pin reset (check Gen 3 & Gen 4)
  • particle usb reset

Example App

When device resets from System.reset(), spark/device/last_reset with data user should be published.

void setup()
{
   System.enable(SYSTEM_FLAG_PUBLISH_RESET_INFO);
   System.enableFeature(FEATURE_RESET_INFO);
}
void loop()
{
  if (Particle.connected()) {
        delay(10000);
        System.reset();
  }
}

References

https://app.shortcut.com/particle/story/128022/publish-last-reset-event-on-session-resumption


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@eberseth
Copy link
Contributor

@monkbroc Could you rebase this onto develop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants