Is there a way for my code to issue a reset when the photon lose connection to the particle cloud for more than a given amount of time ?
You can check for a cloud connection.
You can set a waitFor on calls.
You can issue a system reset.
With those, you should be able to conjure up something you want
Mind you, you’d have to run in threaded mode or control the connection manually if you don’t want the code to be blocked when losing the cloud connection.
I thought I saw something in the firmware documentation that provided something to achieve this almost out of the box.
Do you have an example for the threaded mode you mentioned ?
There is one strategy to think-up all possible use cases and provide them as one-line solutions and the other to provide some individual general purpose building blocks which you can use to create a solution for use-cases that haven’t been thought-up yet.
The former might appear convenient, but will always be failing to address more use-cases than it ever can address.
Hence the more flexible approach is the one chosen on this platform.
These are the building blocks you may want to look at
Why do you want to reset it after x time not connected to the cloud?
That is, alternatives could be attempting a reconnection to the cloud, or disconnecting from wifi and reconnecting if you think this will recover the connection (but if you’re running in Automatic mode it should do this anyway).
On reset startup, if the cloud connection is still not available, would that be any different than if you didn’t reset it and the cloud wasn’t connected?
One of my photons has started getting “stuck” on blinking (not breathing) cyan, after a while of being connected just fine.
Since it’s not connected to the cloud there’s nothing I can do other than physically clicking the reset button (after which the device starts and connects just fine to the cloud).
This is obviously not a good solution so I wanted to make a fail safe mechanism that just resets the device automatically when that happens.
The first thing to use in that case is
SYSTEM_THREAD(ENABLED) as linked above.