Go to safe state when leaving application control

I’m building a device which controls some reasonably high-powered devices (maximum total dissipation around 100 W). I’m controlling these devices with a few PWM channels.

What I’d like to do is have some way to detect when my device is going down for a firmware upgrade, and shut off the control channels. The controlled devices are off when the MCU undergoes a hardware reset, but for state changes which don’t cause such a reset the channels remain in the configuration the application put them in.

Is there any such functionality in the firmware?

Hi @AustinGlaser

You can subscribe to the special events such as firmware update started (and others). The doc is here:

https://docs.particle.io/reference/api/#special-events

So I’d have to subscribe to the special event stream on an external server, and then have that server send my firmware a notification when the device goes down for an upgrade?

No, you just subscribe on the device to that devices “spark/” messages and parse the remaining event name to see what happened.

There are also internal system events that can be hooked directly
https://docs.particle.io/reference/firmware/photon/#system-events

2 Likes

Awesome, I was hoping there was a mechanism like that in place. Thanks for pointing me to it!

1 Like