#include "application.h"
SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
#define PUBLISH_PERIOD_MS 2000
int last_publish_attempt_ms;
void setup() {
Serial.begin(9600);
Particle.connect(); // Should be run without credentials present.
last_publish_attempt_ms = 0;
delay(2000);
}
void loop() {
if (millis() - last_publish_attempt_ms >= PUBLISH_PERIOD_MS) {
last_publish_attempt_ms = millis();
Serial.println("pre-publish");
Particle.publish("test");
Serial.println("post-publish");
}
}
If the above program is run without credentials present, so that the call to Particle.connect() puts the module into listening mode, it will only print a single “pre-publish” message, with no “post-publish” following. The call to Particle.publish(“test”) never seems to return, even through timeout. This is true for MANUAL, SEMI_AUTOMATIC and AUTOMATIC system modes. I saw no mention of this behavior in the documentation, so I figured that it’s a bug. I’ve raised a issue on GitHub here: https://github.com/spark/firmware/issues/761
Thanks,
Derek