"Lost" - Particle subscribe

This morning when I powered up my test devices, all except one worked as I expected - came alive and did their thing
.
The one that did not appeared to be be receiving response from webhook.
Pressed the reset on the failing boron and now all is well.

Some facts: System_thread = enabled, system_mode = Semi_automatic, OS 1.5.2

Setup goes like this:
Particle connect,
wait until particle connected is true
wait 20 seconds,
Particle.syncTime()
waitUntil(Particle.syncTimeDone)
Particle.subscribe
Particle Publish

I have been using this approach successfully for some 2 years acros Electrons and now boron LTE. This is the firsts time I have observed this type of failure.

Questions:

  • Am I missing something
  • Is there a better setup sequence I should be using.
  • Is there any way to detect that “Particle.subscribe” did not stick.
  • Is there any harm in add the same “Particle.subscribe” to the loop or at least in the error recovery path in the loop. For reliability the flow is: particle.publish --> webhook --> response --> subscribe. If there is not response in N seconds, publish it repeated (could add “Particle.subscribe” here).
  • Any other suggestions or ideas.

@Jibeset, you need to put your Particle.subscribe() as the very first thing, even if you are not connected to the Cloud. The function will queue the registration request for when it connects. From the docs:

Particle.subscribe() returns a bool indicating success. It is OK to register a subscription when the device is not connected to the cloud - the subscription is automatically registered with the cloud next time the device connects.

Also, when the device connects to the cloud (from a disconnected state), it will also sync the time. Again, from the docs:

Synchronize the time with the Particle Device Cloud. This happens automatically when the device connects to the Cloud. However, if your device runs continuously for a long time, you may want to synchronize once per day or so.

1 Like

@peekay, thank you for your suggestions. I am surprised that the documentation is not more specific about the ordering requirements. We (including Particle) would all be better off if Particle were to publish code snippets of the preferred methods e.g how to manage the connection to the cloud, how to recover failed cellular connections - then everybody would plough the same trench.
As for the time sync, it was my attempt to ensure that the time value had arrived before the loop code started to run.

1 Like

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