Was thinking of implementing something like this via a fork for now, where sleep settings would be configured via a "sleep.json" file much like wifi secrets. (And then ideally most of this is replaced by device config in the adafruit interface once sleep implemented.)
In short, if enabled, the device would sleep after the first data update cycle completed. Additionally, would add a number of settings/changes to support wakeup options, and help manage a low power device that sleeps whenever possible, with the fastest network connection possible. I prefer the LiPo's strapped to my chest be...smaller.
My draft config file as a basic design doc:
Code: Select all
{
"sleep_enable": true,
"sleep_enable_pin_enabled": true,
"sleep_enable_pin": "A0",
"sleep_initial_min_awake_seconds": 10,
"sleep_mode_options": "deep",
"sleep_mode": "deep",
"sleep_wake_type_options": "timer|pin|both|none",
"sleep_wake_type": "both",
"sleep_cycle_timer_seconds": 300,
"sleep_wake_pin": "A0",
"sleep_wake_pin_trigger_high": true,
"sleep_wake_pin_pull": true,
"powersave_disable_pixel_on_wake": true,
"powersave_sleep_on_all_halts": true,
"powersave_max_awake_seconds": 15,
"powersave_wifi_sleep_on_failure": true,
"powersave_wifi_override_max_retries": 1,
"powersave_wifi_override_retry_ms": 4000,
"powersave_wifi_override_check_ms": 100,
"powersave_wifi_skip_ssid_scan": true,
"powersave_wifi_fixed_channel": null,
"powersave_wifi_fixed_bssid": null,
"powersave_wifi_fixed_config_options": "if used, all are required",
"powersave_wifi_fixed_config_local_ip": null,
"powersave_wifi_fixed_config_gateway": null,
"powersave_wifi_fixed_config_subnet": null,
"powersave_wifi_fixed_config_dns1": null,
"powersave_wifi_fixed_config_dns2": null,
"powersave_mqtt_sleep_on_failure": true,
"powersave_mqtt_override_max_retries": 1,
"powersave_mqtt_override_server_ip": null,
}
- The "_options" elements are just comments.
- Sleep enable pin on the device aside from the obvious, allows a fast update timeframe in WipperSnapper and a longer sleep time, which could be used to switch between slow and fast update times with a switch on the device.
- Timer mode would attempt to keep the total awake+asleep time consistent so log entries have roughly the same intervals.
- The bottom powersave_ section is an initial list of items the could save awake time, preferring low power consumption over reliability. Would include any potential long delays or retry loops, lookups that can be sped up with hard-coding, a hard awake time limit, etc.
Some of the powersave options are pretty important for a device that sleeps (especially wearable) as for example, currently failing to find the set WiFi SSD causes a 60 second powered delay until hitting the watchdog reset, and repeating forever. Simply adding sleep alone would have a lot of cases still stuck with power on.
Was just curious if this would be useful for anyone else, and if that feature set would be reasonably useful sleep functionality? It seems pretty straightforward to add in -- although also a bit messy to do in a manner that keeps the structure the same, so it's easy(er) to keep up to date.