What *IS* Safe Mode?

The Photon Guide explains how to go into safe mode. One reason – perhaps the ONLY reason? – to enter safe mode is when you are in, say, Manual mode in your application and you cannot get to the cloud to allow a re-flash. I understand that and wonder if there are more reasons for entering safe mode.

My real question is: What happens now that you are in safe mode? Is it true that the only thing you can do, or would want to do, is flash a new application?

Normally I would just play around with the Photon and try to discover how it works. But there are too many forum posts discussing “stuck in safe mode”.

I only use the web IDE, Particle.build.

Our application uses Manual mode. We added a button on an unused Photon pin such that, when pressed, it forces the app to connect to cloud so we can re-flash. But I would prefer not to sacrifice a pin if safe mode really works properly. There are only so many pins!

If you can get to RESET and SETUP buttons with your application, then you can always get back to safe mode (assuming something really fatal hasn’t occurred).

Safe Mode will be automatically entered if you flash a User app to the device with incompatible dependencies, like your user app requires a newer system firmware version that is not present on the device. The Photon will “heal” itself when this happens, assuming it can connect back to the Cloud and report what dependencies it currently has.

When in Safe Mode, your user application will not run. This is probably the most important point, and why it’s called Safe Mode. If you flash bad code to your device that would normally prevent your application from running and interpreting a button input to Connect it to the Cloud… Safe Mode is a way to connect it to the Cloud again.

The Electron will not heal itself by default to conserve cellular data usage.

When using Manual mode… I could see dedicating a button for cloud connection would be useful. There is also a nice System event now that can detect a number of SETUP button presses (button_final_click), which you could setup up for 1 or more presses to indicate that it’s time to connect to the Cloud (or disconnect for that matter). There is a pad under the Photon to access this SETUP button as well, so it’s possible to wire that that a button without using up an extra I/O.

Safe Mode does not appear to be the thing you need, but it may be important to make RESET and SETUP available to the user. You can also hold SETUP when applying power to effectively do the same thing as pressing RESET while holding SETUP (to enter Safe Mode).

So the key point is that “Safe Mode is a way to connect it to the Cloud again”. Right?

And when in Safe Mode, flash works. RIght? And it works from build.particle.io?

You said that Safe Mode does not appear to be the thing I need. But isn’t it EXACTLY what I need? When I flash an app that uses Manual and I want to flash a new version of that app, isn’t entering Safe Mode what I want?

I am probably missing something obvious so let me ask the question differently. If a developer needs to use Manual mode, does he not require Safe Mode or something tricky (like my button) to allow him to flash new stuff?

Safe mode is primarily used to put the Particle device in a state in which it can be flashed yes. The device can also enter that state if there is something wrong with the user code and it is unable to run. In this case it enters safe mode so that you can flash new code on it.

For your application I think safe mode is a perfect solution to your flashing issues. Whenever you want to flash new code simply put your device in safe mode and then you can flash it.

It depends... if you are developing a product, requiring users to manipulate SETUP and RESET to enter Safe Mode may not be as friendly as a one button solution (which I presented two ways to do that). When you said "Our application uses Manual mode" it made me think you might be creating a product.

If you are just developing different test applications, and you have your Photon right there in front of you... then Safe Mode is your new best friend when flashing MANUAL mode applications. Safe Mode will allow your Photon to connect back to the Cloud easily, so you can flash another MANUAL mode app.

So you have lots of options :smile: Hope that helps explain why you might want to use one form of connecting to the cloud vs. the other.

We are making a “hobby product” for a bunch of people. It won’t be for sale but if we get it to work, we may deploy, say, 100 units. It is absolutely true that we never intend these users to hit ANY buttons. All we want them to do is power on and things either work perfectly or they call us!

So, yes, the Setup button is my new best friend!

Thanks for the help and advice.
–jim

1 Like