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

Workaround for Gen 3 devices not connecting to the cloud in non-automatic threaded mode #2152

Merged
merged 1 commit into from
Jul 20, 2020

Conversation

sergeuz
Copy link
Member

@sergeuz sergeuz commented Jul 17, 2020

Problem

The system loop on Gen 3 modifies the value of the SPARK_WLAN_SLEEP flag, which may prevent Particle.connect() from initiating a connection to the cloud when the app is running in threaded mode.

Solution

Do not call network_off() in the system loop if SPARK_WLAN_SLEEP is set but there's no active or ongoing network connection.

Note that this is more a workaround rather than a solution. Ideally, we need to refactor the system state management logic so that SPARK_WLAN_SLEEP (or its equivalent) only controls the "administrative" state of the networking subsystem, i.e. whether the user wants networking to be enabled, rather than both the administrative state and the actual one.

Steps to Test

The easiest way to reproduce this issue is to introduce artificial delays in the system loop:

  1. Apply this diff to develop, build and flash the system firmware and the example application to a Gen 3 device.
  2. Verify that the device is breathing white despite that Particle.connect() has been called in setup().
  3. Check out this branch and reintroduce the same delay in the system loop.
  4. Verify that the device running the same application is connecting to the cloud.

Example App

#include "application.h"

SYSTEM_MODE(SEMI_AUTOMATIC)
SYSTEM_THREAD(ENABLED)

void setup() {
    HAL_Delay_Milliseconds(250);
    Particle.connect();
}

void loop() {
}

References

  • [ch59176]

@sergeuz sergeuz added the bug label Jul 17, 2020
@sergeuz sergeuz added this to the 2.0.0 milestone Jul 17, 2020
@sergeuz sergeuz requested a review from avtolstoy July 17, 2020 19:57
…vent Particle.connect() from initiating a connection in multithreaded mode
@avtolstoy avtolstoy merged commit d769989 into develop Jul 20, 2020
@avtolstoy avtolstoy deleted the wlan_sleep/ch59176 branch July 20, 2020 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants