Pebble App Framework
v7.1.1
How It Works
CLI
Device API
Phone API
C Coverage
TS Coverage
GitHub
Theme
Pebble App Framework: Device API
Toggle main menu visibility
Loading...
Searching...
No Matches
link_change.h
Go to the documentation of this file.
1
12
#pragma once
13
#include <stdbool.h>
14
19
23
typedef
enum
24
{
25
LINK_SAME
,
26
LINK_DROPPED
,
27
LINK_RECONNECTED
28
}
LinkChange
;
29
33
typedef
struct
34
{
35
bool
connected
;
36
bool
seeded
;
37
}
LinkState
;
38
49
static
inline
LinkChange
link_change_read
(
LinkState
*state,
bool
connected)
50
{
51
bool
was_connected = state->
connected
;
52
bool
seeded = state->
seeded
;
53
54
state->
connected
= connected;
55
state->
seeded
=
true
;
56
57
if
(!seeded || was_connected == connected)
58
{
59
return
LINK_SAME
;
60
}
61
62
return
connected ?
LINK_RECONNECTED
:
LINK_DROPPED
;
63
}
64
link_change_read
static LinkChange link_change_read(LinkState *state, bool connected)
Takes one reading of the link and says what it means.
Definition
link_change.h:49
LinkChange
LinkChange
What one reading of the link means.
Definition
link_change.h:24
LINK_RECONNECTED
@ LINK_RECONNECTED
The phone link just came back.
Definition
link_change.h:27
LINK_SAME
@ LINK_SAME
The first reading, or one that matches the last. Nothing to act on.
Definition
link_change.h:25
LINK_DROPPED
@ LINK_DROPPED
The phone link just went down.
Definition
link_change.h:26
LinkState
The link as last read. Zeroed is a store that has read nothing yet.
Definition
link_change.h:34
LinkState::seeded
bool seeded
True once a reading has come in, so the next one can be a change.
Definition
link_change.h:36
LinkState::connected
bool connected
True when the phone link was up at the last reading.
Definition
link_change.h:35
src
c
core
io
link_change.h
Generated by
1.18.0