Add mistakingly omitted files
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
// lol the code in this file is mostly stolen from https://github.com/SeaPea/GentleWake
|
||||||
|
|
||||||
|
#include <pebble.h>
|
||||||
|
|
||||||
|
// 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 result = 0;
|
||||||
|
uint8_t try_count = 0;
|
||||||
|
|
||||||
|
result = wakeup_schedule(wakeup_time, is_fallback, 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);
|
||||||
|
|
||||||
|
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 * 5) minutes before/after.
|
||||||
|
while (result == E_RANGE && try_count++ < 5) {
|
||||||
|
wakeup_time += retry_diff;
|
||||||
|
result = wakeup_schedule(wakeup_time, is_fallback, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <pebble.h>
|
||||||
|
|
||||||
|
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, bool is_fallback);
|
||||||
Reference in New Issue
Block a user