Host C Specs


Directory: src/c/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 14 / 0 / 14
Functions: 100.0% 4 / 0 / 4
Branches: 100.0% 12 / 0 / 12

pebble/io/stores/store_poll.c
Line Branch Exec Source
1 /**
2 * @file store_poll.c
3 * @brief The polling decisions the weather, stock, and calendar stores share.
4 *
5 * Each store keeps its own interval, its own first fetch, and its own request. What they share is
6 * when a poll is due and when polling is on at all.
7 *
8 * @ingroup lib_stores
9 */
10 #include "io/stores/store_poll.h"
11
12 #include "io/store_live.h"
13
14 16 bool store_poll_start(StorePoll *poll, int poll_min, bool live, time_t now)
15 {
16 16 poll->pinned = !live;
17 16 return store_poll_set(poll, poll_min, live, now);
18 }
19
20 27 bool store_poll_set(StorePoll *poll, int poll_min, bool live, time_t now)
21 {
22 27 poll->poll_min = poll_min;
23 27 poll->live = store_live_after_reconfigure(live, poll->pinned);
24
25
4/4
✓ Branch 3 → 4 taken 16 times.
✓ Branch 3 → 5 taken 11 times.
✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 6 taken 14 times.
27 if (!poll->live || poll_min <= 0)
26 {
27 13 return false;
28 }
29
30 14 poll->next = store_poll_next(poll_min, now);
31 14 return true;
32 }
33
34 3 bool store_poll_turn(StorePoll *poll, time_t now)
35 {
36
4/4
✓ Branch 2 → 3 taken 2 times.
✓ Branch 2 → 6 taken 1 time.
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 6 taken 1 time.
3 return poll->live && store_poll_due(poll->poll_min, &poll->next, now);
37 }
38
39 8 bool store_poll_reconnect(const StorePoll *poll, int age_s)
40 {
41
4/4
✓ Branch 2 → 3 taken 5 times.
✓ Branch 2 → 6 taken 3 times.
✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 6 taken 3 times.
8 return poll->live && store_poll_reconnect_due(age_s, poll->poll_min);
42 }
43