P1 module create a SOS when Wifi lost and reset system

After trying different options, it seem using a millis timer is the only way that work for me. WiFi.ready(), System.On() does not get trigger when the hard fault happens, it get trigger after reset. Maybe a Particle software engineer can comment on this.

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

#define connectDelay 5000
unsigned long lastAttempt;

// setup() runs once, when the device is first turned on.
void setup() {
  Serial.begin(9600);
  WiFi.on();
  Particle.connect();
}

void loop() {
 if (millis() - lastAttempt >= connectDelay)
  {
    Serial.printlnf("wifi ready");
    Serial.println(WiFi.ready());
    if (WiFi.ready())
    {
      Serial.printlnf("wifi rssi");
      Serial.println(WiFi.RSSI());
    }
    lastAttempt = millis();
  }
}