I am trying to use SYSTEM_MODE(MANUAL) and then Particle.connect() in setup(). When viewing the console.particle.io I see my data being published but functions and variables do not appear even after after refreshing them. Also pinging my device from the console fails. Yet, my publishes keep being displayed.
I had this type of connection working 5 or 6 weeks ago but tried to make some changes yesterday and can’t get it to work.
Any help is appreciated.
I am using an Electron, Asset Tracker 2, compiling with --target 0.6.2.
Here is my code reduced to a simple test. The calls to Particle.function() and Particle.variable() both return true. I tried making the calls after Particle.connect() and before with the same results.
Thanks.
Lynd
// Test for registering functions using manual connect.
SYSTEM_MODE(MANUAL)
int myVariable = 123;
int foo(String s)
{
Serial.println(s);
return 1;
}
void setup()
{
Serial.begin(9600);
// wait for monitor connection
delay(10000);
if ( Particle.function("foo", foo) == false){
Serial.println("Particle.function returned false");
} else {
Serial.println("Particle.function returned true");
}
if ( Particle.variable("var", myVariable) == false){
Serial.println("Particle.function returned false");
} else {
Serial.println("Particle.function returned true");
}
Serial.println("Calling connect...");
Particle.connect();
Serial.println("Back from calling connect");
}
unsigned long lastPublish = 0;
unsigned long delaymillis = 10000;
void loop() {
unsigned long now;
String nowstr;
now = millis();
if ((now - lastPublish) > delaymillis ){
nowstr = String::format("%d", now);
Particle.publish("now", nowstr);
Serial.println(nowstr);
lastPublish = millis();
}
}