Initial awareness alarm implementation

This commit is contained in:
RandyTheSilly committed 2026-08-13 22:37:53 -04:00
1 parent 4ebc7ab3ad
commit 857e18e5cb
4 files changed
+81 -41

No files matched your search

+4 -4
View File
@@ -17,24 +17,24 @@ static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit
// Mostly stolen from https://github.com/SeaPea/GentleWake;
// A slightly more robust wakeup scheduler that retries on certain errors and
// can retry for a different wakeup time offset by retry_diff up to retry_max times
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, bool is_fallback) {
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, WakeupReason wakeup_reason) {
WakeupId result = 0;
uint8_t try_count = 0;
result = wakeup_schedule(wakeup_time, is_fallback, true);
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
if (result < 0) {
// If result is negative, something went wrong, so make sure all wakeups for this app are cancelled and try again
wakeup_cancel_all();
result = wakeup_schedule(wakeup_time, is_fallback, true);
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
if (result == E_RANGE) {
// E_RANGE means some other app has the same wakeup time +/- 1 minute, so try to set
// the wakeup for a time up to (retry_diff * 8) minutes before/after.
while (result == E_RANGE && try_count++ < 8) {
wakeup_time += retry_diff;
result = wakeup_schedule(wakeup_time, is_fallback, true);
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
}
}
}