OS 2.0.0 console Function & VARIABLES lost

Hi Guys,

I just update the os for my photon from 1.2.1 to 2.0.0 now I found function & variable on the console are lost did any one know how to fix this ?

Hard to say without seeing your code :wink:

A simple test code which doesn’t anything else than register some variables and functions might help distinguish whether it’s really 2.0.0 (which I don’t see on my side) or rather your existing code.

This is some for the code.

Normally This code are work fine with OS 1.2.1. But after upgrade device os to 2.0 and compile code to 2.0 function and variable are missing

SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);

void manageConnection() {

    if((!startup ||  millis()-lastconnection>reconnect) && millis()>30000) {
      lastconnection = millis();
      if (!Particle.connected()) {
        Particle.disconnect();
        _connectingToCloud = false;

        if (!WiFi.ready()) {
          if (!WiFi.listening() && !WiFi.connecting()) {
            WiFi.connect(WIFI_CONNECT_SKIP_LISTEN);
          }
        } else {
          if (!_connectingToCloud) {
            // NOTE: This only needs to be called once and after that, the system
            // thread should maintain the connection automatically until
            // Particle.disconnect() is called. Still, it shouldn't hurt to call
            // this every time we get disconnected.
            // source: https://github.com/spark/firmware/issues/663#issuecomment-147549451
            startup = true;
            disableWDT();
            networkService();
            lcd->clear();
            lcd->setCursor(0, 0);
            lcd->print("attempt connection..");

            Particle.connect();
            _connectingToCloud = true;

            Particle.function("setATemp", setATemp);
            Particle.function("setHum", setHum);
            Particle.function("setHour", setHour);
            Particle.function("setMinute", setMinute);
            Particle.function("clearEEPROM*", clearEEPROM);
            Particle.function("startPump", startPump);
            Particle.function("stopPump", stopPump);
            Particle.function("stopDemo", stopDemo);
            Particle.function("Reboot", forceReboot);
            Particle.function("ConCheck", ConCheck);
 
            Particle.variable("sysHH", sysHour);
            Particle.variable("sysMM", sysMinute);
            Particle.variable("uptime", systemUptime);
            Particle.variable("fw_ver", current_version);

            if(!Particle.connected()) {
                lcd->setCursor(0, 2);
                lcd->print("cloud connect failed");
                alert(2);
            } 
          }
        }
      } else {
        if (_connectingToCloud) {
        }
        _connectingToCloud = false;
        Particle.process();
      }
  }
}

When you put your Particle.connect() call after the function and variable registration it should work.

I’d even put that entire block into setup() as it doesn’t need to be repeated on subsequent re-connection attempts.

Oh yes. thanks you so much