33{
34 int64_t alarm_until_epoch = 0;
36 uint8_t i;
37
38 (void)arg;
39
41 last_trigger_minute[i] = -1;
42 }
43
44 while (true) {
46 struct tm local_time;
47 int64_t now_epoch = 0;
48 bool active = false;
50
52
53 if (time_valid) {
54 int64_t current_minute = now_epoch / 60;
55
58 continue;
59 }
60
63
64 if (due && current_minute != last_trigger_minute[i]) {
65 last_trigger_minute[i] = current_minute;
67 ESP_LOGI(
TAG,
"Alarm %u triggered at %02d:%02d",
68 (unsigned int)i, local_time.tm_hour, local_time.tm_min);
69 }
70 }
71 }
72
73 if (alarm_until_epoch > 0 && time_valid && now_epoch < alarm_until_epoch) {
74 active = true;
75 }
76
77 if (!time_valid) {
78 active = false;
79 alarm_until_epoch = 0;
80 }
81
85 }
86}
#define ALARM_TASK_PERIOD_MS
#define ALARM_ACTIVE_SECONDS
void app_state_set_alarm_active(bool active)
Update runtime alarm active flag.
void app_state_get_snapshot(app_state_snapshot_t *snapshot)
Get a thread-safe snapshot of the full state.
#define APP_ALARM_MAX_COUNT
Maximum number of configurable alarms.
alarm_entry_t alarms[APP_ALARM_MAX_COUNT]
Snapshot of full app state.
bool time_service_get_local_time(struct tm *out_tm, int64_t *out_epoch)
Get local time adjusted by the configured timezone offset.