Problem with Particle.publish()? - Solid green light after reboot


I was playing around with the accelerometer shield and ran into some odd problems, such as Bluz shutting down suddenly (no LED) and after rebooting it just displays solid green and is not discoverable (iOS app).
The iOS device is in close vicinity of Bluz.

So, I loaded a simple tinker app, all it does is blinks D7 on and off as follows:

`void loop() {
// To blink the LED, first we’ll turn it on…
digitalWrite(led2, HIGH);
// We’ll leave it on for 1 second…
// Then we’ll turn it off…
digitalWrite(led2, LOW);
// Wait 1 second…

// And repeat!

Everything great ! I turn it off and on and connect to iOS app works perfectly.

Now, I add Particle.publish() and things go a bit sideways, every thing works the first time after flashing, I can see the data being reported on Particle dashboard, but after I reboot Bluz, I get into the dreaded solid green state where my bluz is not discoverable. I have to do a soft reset on it and load the code again to get it to work and this happens every time after I turn power off and on.

This is the code that’s causing it:

void loop() { // To blink the LED, first we'll turn it on... digitalWrite(led2, HIGH); Particle.publish("D7", "High", 60, PRIVATE); // We'll leave it on for 1 second... delay(1000); // Then we'll turn it off... digitalWrite(led2, LOW); Particle.publish("D7", "Low", 60, PRIVATE); // Wait 1 second... delay(1000); }

I am using iOS app (recent) and building with default firmware (release-1.0.47).
Am I doing anything wrong here or perhaps missing anything obvious ?


There is a bug on this, it is rather old and I need to get it fixed:

The main reason I haven’t is that there is a relatively simple workaround. If you add:
if (Particle.connected()) {
// publish in here

That should fix the issue. I am contemplating a new release soon as we have fixed a few minor issues, I will try and add this one to the next release as well.

As a side note, it is good practice on bluz to check for Particle.connected() and handle that accordingly. By default, user code in bluz will run without a cloud connection, unlike the Photon. We did this intentionally, but it means that publishing data may not always work by default, whereas on the Photon you would have to mess with System Modes to get into a similar situation.

We will fix the bug that causes a hang, but probably good practice to check before you publish anyway.


Cool, this seems to have fixed the issue ! thanks a lot for the workaround and the tip :slight_smile: