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

[system] disconnect the cloud when calling Mesh.off() #1857

Merged
merged 1 commit into from Jul 31, 2019

Conversation

@YutingYou
Copy link
Contributor

commented Jul 15, 2019

Problem

Issue: #1813

SEMI_AUTOMATIC mode blocks loop() after calling Mesh.off()

Solution

For user scenario like:

Mesh.on();
Mesh.connect(); 
Particle.connect();
...
Mesh.off();

SPARK_CLOUD_AUTO_CONNECT is set in Particle.connect() and it isn't cleaned in Mesh.off() which causes semi_automatic_connecting() always return ture, then the device assumes it is in a network connection task, it jumps over loop() task.

Steps to Test

  1. Use Argon as a border router
  2. Connect Xenon to the Argon mesh network
  3. Burn the example app to Xenon
  4. Observe whether Xenon gets stuck in blinking green.

Example App

#include "application.h"

SYSTEM_MODE(SEMI_AUTOMATIC);

Serial1LogHandler logHandler(115200, LOG_LEVEL_ALL, {{"app", LOG_LEVEL_ALL}});

void setup() {
  Serial.begin();
}

void loop() {
  static uint32_t msLast = 0;
  Serial.print('.');             // <-- get only printed on first call to loop() !!!
  if (millis() - msLast < 1000) return;
  msLast = millis();

  Serial.println("Turning ON radio...");
  Mesh.on();
  Mesh.connect(); 
  if (waitFor(Mesh.ready, 10000)) {
    Particle.connect();
    if (waitFor(Particle.connected, 10000)) {
      Particle.publish("xenon-test", PRIVATE);  // tried with WITH_ACK too 
      Serial.println("published xenon-text");   //  |
      delay(100);                               // delay required (even when using WITH_ACK) 
    }
    else
      Serial.println("Couldn't connect to cloud");
  }
  else
    Serial.println("Couldn't connect to mesh");
  
  Serial.println("Turning OFF radio...");

  Mesh.off();
  Serial.println("radio is off");
}

One more thing

Is this issue also with Cellular and Wifi?

image

References

[CH35131]


Completeness

  • [bugfix] [Gen3] Mesh.off() disconnects the cloud. Resolves an issue with loop() not being executed in SEMI_AUTOMATIC mode after Mesh.off()

@avtolstoy avtolstoy force-pushed the fix/SEMI_AUTOMATIC-mode-blocks-loop branch from e190079 to a07e80d Jul 31, 2019

@avtolstoy avtolstoy removed the needs review label Jul 31, 2019

@avtolstoy avtolstoy merged commit cbbec86 into develop Jul 31, 2019

0 of 2 checks passed

Codacy/PR Quality Review Hang in there, Codacy is reviewing your Pull request.
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@avtolstoy avtolstoy deleted the fix/SEMI_AUTOMATIC-mode-blocks-loop branch Jul 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.