vladak / shield

code for ESP32 Adafruit Feather to get various sensor readings and publish them to MQTT broker
2 stars 0 forks source link

store the safe mode reason #24

Closed vladak closed 4 months ago

vladak commented 6 months ago

follow-up to #23: consider passing the reason for safe mode entry to code.py.

Inspiration: https://gist.github.com/anecdata/fe35dc6a94069fc920edf61a64750b53

vladak commented 4 months ago

The goal is to have a appendable log file with the safe mode reasons. Avoid using JSON as appending to the file without reading and parsing the contents will produce invalid JSON. Text entries are enough. The timestamps will not tell much because they get reset, however at least might reveal for how long the code was running.

vladak commented 4 months ago

Tested by using:

#!/usr/bin/env python3

import microcontroller

print("switching info safe mode")
microcontroller.on_next_reset(microcontroller.RunMode.SAFE_MODE)
microcontroller.reset()