resetReason() value decoder

I feel like this must be obvious to others, but where can I find the decoder to turn resetReason() numerical outputs into the text string that’s shown on the reference page?

For example, when I use a statement like String(System.resetReason()); I just get an integer. What step am I missing?

Maybe there’s an ENUM list in particle.h? But where can I find particle.h? It’s not coming up in the library search in the online IDE.

In C/C++ enums cannot be translated into clear text that simple.

But you can find Particle.h at https://https://github.com/particle-iot/device-os.
However, Particle.h is only a collection of more #include statements and the enum you are looking for can be found here

Alternatively, if searching the device-os source code isn’t your thing you can write a little program to print them out to serial. For example:

STARTUP(System.enableFeature(FEATURE_RESET_INFO));

void setup()
{
Serial.begin();
while (!Serial.available()) Particle.process();
Serial.printlnf("Reset button or reset pin %i", RESET_REASON_PIN_RESET);
Serial.printlnf("Low-power management reset %i", RESET_REASON_POWER_MANAGEMENT);
Serial.printlnf("Power-down reset %i", RESET_REASON_POWER_DOWN);
Serial.printlnf("Brownout reset %i", RESET_REASON_POWER_BROWNOUT);
Serial.printlnf("Hardware watchdog reset %i", RESET_REASON_WATCHDOG);
Serial.printlnf("Successful firmware update %i", RESET_REASON_UPDATE);
Serial.printlnf("Firmware update timeout %i", RESET_REASON_UPDATE_TIMEOUT);
Serial.printlnf("Factory reset requested %i", RESET_REASON_FACTORY_RESET);
Serial.printlnf("Safe mode requested %i", RESET_REASON_SAFE_MODE);
Serial.printlnf("DFU mode requested %i", RESET_REASON_DFU_MODE);
Serial.printlnf("System panic %i", RESET_REASON_PANIC);
Serial.printlnf("User-requested reset %i", RESET_REASON_USER);
Serial.printlnf("Unspecified reset reason %i", RESET_REASON_UNKNOWN);
Serial.printlnf("Information is not available %i", RESET_REASON_NONE);
}

void loop()
{
}

Thanks, this is helpful. I’m trying to create a reviewable log of reset events (and other status info) and thought it would be nice to have the reason code intelligible to folks not as familiar with the Particle documentation. I was considering making the translation to text on the device, but it seems more efficient to publish the codes to a Google sheet and then do the translation there.

It’s always interesting to see how much of a project ends up being stuff related to robustness and crash handling, versus the actual task you wanted to perform.