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

Gen2: fixes the issue that the cellular modem is reset unexpectedly. #2307

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

XuGuohui
Copy link
Member

Problem

If the WLAN_WD expires during device is connecting to the cellular tower followed by user requests to cancel the on-going cellular operation, the modem might be reset still.

Solution

Clear the WLAN_WD on user request to cancel the on-going cellular operation.

Steps to Test

N/A

Example App

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

SerialLogHandler logHandler(115200, LOG_LEVEL_ALL);

bool shutoff = false;
system_tick_t last_sync = 0;

// handler for mode button being clicked to trigger
// connect/disconnect
void mode_clicked(system_event_t event, int param)
{
    shutoff = !shutoff;
    Log.info("mode button clicked");
}

// background thread to call blocking API
// this appears to allow the idle task in during the `Cellular.off` sequence
// and trigger the WLAN watchdog
void background_thread_func()
{
    while(true)
    {
        last_sync = Particle.timeSyncedLast();
        delay(1);
    }
}

void setup()
{
    auto background_thread = new Thread("sysapp_background", background_thread_func);
    (void) background_thread;

    System.on(button_click, mode_clicked);

    Particle.connect();
}

void loop()
{
    static bool last_shutoff = shutoff;

    if(last_shutoff != shutoff)
    {
        last_shutoff = shutoff;

        if(shutoff)
        {
            Log.info("disconnect");
            Cellular.off();
            Log.info("post disconnect");
        }
        else
        {
            Log.info("connecting again");
            Particle.connect();
        }
    }
}

References

N/A


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)

@XuGuohui XuGuohui added this to the 2.1.0 milestone Apr 20, 2021
@XuGuohui XuGuohui requested a review from avtolstoy April 20, 2021 06:57
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.

Let's add an automated test to wiring/no_fixture for this. Some examples on how to force a specific system thread behavior can be found in THREAD_07_particle_process_behavior_when_threading_enabled.

@XuGuohui
Copy link
Member Author

Let's add an automated test to wiring/no_fixture for this. Some examples on how to force a specific system thread behavior can be found in THREAD_07_particle_process_behavior_when_threading_enabled.

I don’t think a no_fixture test can verify this. As we need to enforce a blocking connection attempt, which can be produced by detaching the antenna or put the device in a bad cellular environment.

@XuGuohui XuGuohui added ready to merge PR has been reviewed and tested and removed needs review labels Apr 27, 2021
@XuGuohui XuGuohui merged commit 08463e6 into develop Apr 27, 2021
@XuGuohui XuGuohui deleted the fix/cellular_reset/ch71838 branch April 27, 2021 14:23
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
2 participants