Device Unreachable, but publishes messages to cloud without issue

I have an E-Series LTE running the 1.5.1 Device OS.

It was previously working without issue. It will now publish messages to the cloud fine, but returns device unreachable when requesting vitals. Pings and function call are also not working.

In order to rule out application firmware issues, I’m running the following code with the same results.

#include "Particle.h"

SerialLogHandler logHandler(115200, LOG_LEVEL_ALL);

int testFunction(String extra);

void setup()
{
    Particle.function("TEST", testFunction);
}

int testFunction(String extra)
{
    Particle.publish("test", "this is a test message", PRIVATE);

    return 1;
}

Any insight would be appreciated.

UPDATE:

adding the following line to setup seems to resolve the issue:

Particle.publishVitals(10)

I thought that it may be a keep alive issue so I tried this:

#include "Particle.h"

SYSTEM_MODE(SEMI_AUTOMATIC);

SerialLogHandler logHandler(115200, LOG_LEVEL_ALL);

int testFunction(String extra);

void setup()
{
    Particle.function("TEST", testFunction);
    Particle.keepAlive(10);
    Particle.connect();
}

int testFunction(String extra)
{
    Particle.publish("test", "this is a test message", PRIVATE);

    return 1;
}

This also works. Setting the keep alive interval greater than 10 seconds causes intermittent outages.

1 Like

Where is your loop()?

I did not override it for clarity of example i.e. loop function is empty. The application I am debugging which does implement code in the loop demonstrates the same behavior.

A quibble I have with this is that you’re publishing before the connection is made, which makes the message to publish wait in a very limited queue area. I don’t know if it’s affecting your problem though. Maybe trying throwing

while(!Particle.connected()) Particle.process();
Particle.function("TEST", testFunction);

at the end of setup() and see what happens…

Thank you for the suggestion, but I think you may be conflating Particle.publish() and Particle.function().

According to the Device OS API Particle functions should be registered as soon as possible in Setup() when running in AUTOMATIC mode and before Particle.connect() is called when running in SEMI_AUTOMATIC code.

Ah, no, I saw (and wrote)

Particle.function("TEST", testFunction);

and read

testFunction("TEST");

I see that you’re doing a call and response now…

Maybe try decoupling the call and response like this:

bool gDoPublish = false;

int testFunction(String extra)
{
    Log.info("Publish requested from cloud.");
    gDoPublish = true;
    return 1;
}

void loop() {
    if (gDoPublish) {
        gDoPublish = false;
        bool success = Particle.publish("test", "this is a test message", PRIVATE);
        if (success) Log.info("Publish succeeded.");
        else Log.error("Publish failed.");
    }
}

Thank you, but that does not resolve the issue. Pings and Health checks are also affected.

1 Like

Forgot to follow up on this issue. I was able to resolve it on my own and the root cause was a klutz move on my part.

I’d been testing E-Series LTE and 3G modules and had inadvertently installed the 3G antenna on the LTE device.

Swapping to the correct LTE antenna resolved the issue.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.