With MQTT I Cannot program electron unless I place it in safe mode

It runs my program normally but when I need to program it OTA, it does nothing, just continues to run the program.

When I place it safe mode, I can then program it.

Any ideas?

I am using SYSTEM_THREAD(ENABLED) and SYSTEM_MODE(SEMI_AUTOMATIC).

Since I am working with MQTT, I created a command “place in safe mode”.
After I sent that command, then electron goes into safe mode and then I can program it.

But I want the normal way.

Thanks.
Vasilis.

It seems as thought something in your code might be interfering with the process, but without some code to look at, that’s hard to tell.

void loop() {
    if (mqtt_client.isConnected()) {

        mqtt_client.loop();
/*more code here, if, else, digitalWrite, sprintf, serial print*/
        mqtt_client.publish("asdf", msg);
    }

/*there are some other if/else statements, but program doesn't enter there*/
}

There is also one software timer that is running and it overflows every minute.

Do you think the mqtt_client.loop() may cause the problem?

Oh I forgot, and here are the first lines of the setup

Cellular.connect();
waitUntil(Cellular.ready);
Particle.connect();
waitUntil(Particle.connected);
Particle.keepAlive(60);
interrupts();
System.enableReset();
System.enableUpdates();

I noticed something strange. The Particle cloud cannot ping my electron.
This is weird. In my loop() I have the following:
if (!Particle.connected()) {
debug_print(“Particle is not connected?n”);
Particle.connect();

waitUntil(Particle.connected);

}
And it never gets there.
So, how is this possible?

Not to change the subject, but have you tried dfu-util flashing? It’s more convenient if you’re working locally and it saves data in the long run because you won’t be flashing firmware OTA.

Hi,

I want to be able to OTA because I will have the electron in a different apartment.

1 Like

I tried to re program the keys, as seen here:

but still nothing.
I cannot program it and I cannot ping it from the Particle console.

Any ideas?

OK, so I found the problem, but I don’t know what to do now.

If I remove the MQTT connection, then OTA works fine!

Is it the permanent TCP client that causes the problem?

Has anyone used MQTT and work with OTA before? Any advice?

Thanks.

Is there anything that could causing delays or interferences with the particle cloud connection?

Well I just verified that the mqtttest example from the MQTT library does the same for me.
I cannot program it.

I will try another MQTT library.

Migration to adafruit seems difficult for me right now.

I will go with this mqtt library and I will place the electron in safe mode before programming.

But this is an issue, should I raise a bug? How do I do that?

In Web IDE you should find a GitHub link for most libraries which will lead you to the contributors repository. There you can file an "issue" report.
In this case here
GitHub - hirotakaster/MQTT: MQTT for Photon, Spark Core


Update:
I see you've already found that out yourself :wink:

Hi!

I already did that, some hours ago, it is the last one.

But I am afraid that this is not only a library problem. Perhaps Particle has a small bug there.
On the other hand, perhaps it is only my fault :smile:

Something that bothers me is that I don’t see other people complaining about this. So perhaps they don’t see it because it does not happen to them. I suspect that I might be doing something completely wrong.

Is it possible for someone from this forum to verify this by running the mqtttest.ino from this library and then try to program it?

Thanks.

edit: So, in order to raise a bug issue in Particle, I would like a verification from someone here, it someone has time and doesn’t mind testing it, I would like to hear !

I, too, cannot flash OTA with units running MQTT. This is with 0.7.0. I haven’t tried the route of disconnecting from MQTT yet.

My $0.02 is that this seems like a bug which Particle should stay on top of, even if at its root cause it is due to bad behavior of the MQTT library. OTA seems like something which should be sacrosanct, with mechanisms in place to protect it from anything which would defeat it or otherwise prevent it from working.

I have this issue also