Xenon attempting to connect to cloud/wifi when parameters are set for offline state

xenon
argon
Tags: #<Tag:0x00007fe2201fa9a0> #<Tag:0x00007fe2201fa810>

#1

Hello all,

Currently I am having an issue of my Xenon attempting to connect to the cloud or some other network when the system is set to be in an offline state. Let me explain the setup and contingencies for this project. An Argon and Xenon have been setup on a network where there is access to the cloud and they function properly. Eventually, this system will be moved to a managed network where the Argon will not be able to access the cloud, but managed WiFi access is available. This WiFi will be used by the npt-time library in order to provide accurate time for the project. The issue that I am running into is when I configure the Argon to only use wifi and not connect to the cloud (SYSTEM_MODE(SEMI_AUTOMATIC), WiFi.on(), WiFi.connect(), Mesh.on()) along with the Xenon only using mesh (Mesh.on(), Mesh.connect()) the Xenon upon startup flashes green slowly then flashes green rapidly and remains that way, thus halting the entire program. I searched through documentation and I assume the rapid green flash means that it is attempting to connect to the wifi or other network, or finalizing the mesh connection. I’ve looked at a lot of articles in this board regarding Xenon in an offline state, but none of them seem to work. The code on the Argon works perfectly and delivers the intended result. I have included a simple code below that gives the same result.

Argon:

#include <ntp-time.h>

NtpTime* ntpTime;

SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

void setup() {
  WiFi.on();
  WiFi.connect();
  Mesh.on();
  ntpTime = new NtpTime(60);
  ntpTime->start();
}

void loop() {
  //Time Variables
  struct epochMillis now;  //holds the unix epoch time to millisecond resolution
  ntpTime->nowMillis(&now);  //get the current NTP time
}

Xenon:

SYSTEM_MODE(SEMI_AUTOMATIC);

void setup() {
    Mesh.on();
    Mesh.connect();
}

void loop() {

}

Thank you for any help!


#2

Try using SYSTEM_MODE(MANUAL) instead.


#3

You may want to add a waitFor(WiFi.ready, 30000) before starting the NTP object (assuming you got a true return value of the call).


#4

And you may also want to use SYSTEM_THREAD(ENABLE).


#5

Thank you for the prompt reply’s. I have stripped down the code to a bare minimum and the error is still occurring. Now, the status led on the Argon is breathing blue (mesh on) and when the Xenon comes online it starts at white, then blinks green, then fast blinks green forever. I have tried SYSTEM_MODE as manual and semi automatic, along with adding SYSTEM_THREAD(ENABLED). Below is the code I am using.

Argon

SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);

void setup() {
    Mesh.on();
}

void loop() {

}

Xenon

SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);

void setup() {
    Mesh.on();
    Mesh.connect();
}

void loop() {

}

#6

I am unsure if this is a related issue or not, but I found a similar issue here: https://github.com/particle-iot/device-os/issues/1877 Whenever Mesh.connect() is invoked, the Xenon attempts to connect to the cloud (fast blinking green) even when the system mode is set to manual and system thread is enabled. Can anyone give the example above a try to see if this a hardware issue or a software issue? I am using the latest 1.4.2 firmware.


#7

You’d also have to call Mesh.connect() on the Argon in order to actually create the network for the node to join.

However, I think the issue is actually the gateway not the Xenon.
When I flash this code to both devices

#if (Wiring_WiFi)
  SYSTEM_MODE(AUTOMATIC);    
#else
  SYSTEM_MODE(MANUAL);    
#endif
SYSTEM_THREAD(ENABLED);

const char *eventName = "test";

void setup() {
  Mesh.on();
  Mesh.connect();
  Mesh.subscribe(eventName, test);
  pinMode(D7, OUTPUT);
  digitalWrite(D7, HIGH);
  waitUntil(Mesh.ready);
}

void loop() {
  if (!digitalRead(BTN)) {
    Mesh.publish(eventName, System.deviceID());
    delay(500);
  }
}

void test(const char* name, const char* data) {
  if (!System.deviceID().equals(data)) {
    digitalWrite(D7, !digitalRead(D7));
#if (Wiring_WiFi)
    if (digitalRead(D7)) {
      Particle.connect();  // this alone seems not enough, although it shoule be!
      // *** this helps to reconnect but should NOT be required really ***
      //WiFi.on();
      //WiFi.connect();  
      //if (waitFor(WiFi.ready, 60000)) 
      //  Particle.connect();
      //else
      //  digitalWrite(D7, LOW);
      // *** this helps to reconnect but should NOT be required really ***
    }
    else {
      //Particle.disconnect();
      //WiFi.disconnect();
      WiFi.off();
    }
#endif
  }
}

the Argon will start breathing cyan and the Xenon will breathe green (expected behaviour).
Whenever pushing the MODE button on the Argon, the Xenon’s D7 LED will toggle, signalling a working mesh connection.
When pushing MODE on the Xenon the Argon will also be toggling the D7 LED but also toggle the cloud connection state causing the RGB LED of both devices to go into fast blinking green, where the Argon should actually go into breathing white (WiFi off) and the Xenon should be unaffected and carry on breathing green.
Also another MODE press on the Xenon should cause the Argon to reestablish the connection, but that doesn’t seem to work either - both device keep blinking green forever - the Argon doesn’t even try to connect to WiFi (depsite rapid blinking green).

At appears as if the gateway would be actively telling the nodes that it has lost connection and “instructing” them to alter their RGB signal but not actually do anything other than that.

I wonder what @rickkas7 would think of this behaviour.


#8

I wonder what @rickkas7 would think of this behaviour.

Does anyone have any updates on this topic or discovered a workaround?


#9

@rickkas7 - would you mind commenting on the above?