10#ifndef INFUSE_SDK_INCLUDE_INFUSE_STATES_H_
11#define INFUSE_SDK_INCLUDE_INFUSE_STATES_H_
16#include <zephyr/sys/atomic.h>
17#include <zephyr/sys/slist.h>
61#define INFUSE_STATES_ARRAY_SIZE ATOMIC_BITMAP_SIZE(INFUSE_STATES_END + 1)
66#define INFUSE_STATES_ARRAY(name) atomic_t name[INFUSE_STATES_ARRAY_SIZE]
void infuse_state_register_callback(struct infuse_state_cb *cb)
Register to be notified of state update events.
#define INFUSE_STATES_ARRAY_SIZE
Required size of atomic array for Infuse-IoT application states.
Definition states.h:61
bool infuse_state_clear(enum infuse_state state)
Clear an application state.
void infuse_states_tick(atomic_t snapshot[ATOMIC_BITMAP_SIZE(INFUSE_STATES_END+1)])
Run one tick of the state timeouts.
bool infuse_state_unregister_callback(struct infuse_state_cb *cb)
Unregister previously registered callback structure.
bool infuse_state_set(enum infuse_state state)
Set an application state.
void infuse_states_snapshot(atomic_t snapshot[ATOMIC_BITMAP_SIZE(INFUSE_STATES_END+1)])
Get a snapshot of the current application states.
static bool infuse_state_set_to(enum infuse_state state, bool val)
Set an application state to a specific value.
Definition states.h:171
bool infuse_state_get(enum infuse_state state)
Get an application state.
int infuse_state_get_timeout(enum infuse_state state)
Get the timeout associated with a state.
bool infuse_state_set_timeout(enum infuse_state state, uint16_t timeout)
Set an application state that times out after a duration.
infuse_state
Infuse-IoT application states.
Definition states.h:35
@ INFUSE_STATE_DEVICE_STATIONARY
Device is stationary (not moving)
Definition states.h:43
@ INFUSE_STATE_HIGH_PRIORITY_UPLINK
Device is currently sending high-priority data to the cloud.
Definition states.h:45
@ INFUSE_STATE_LED_SUPPRESS
Suppress LED activity.
Definition states.h:51
@ INFUSE_STATE_DEVICE_STARTED_MOVING
Device started moving.
Definition states.h:47
@ INFUSE_STATE_APPLICATION_ACTIVE
Application is active according to KV-store values.
Definition states.h:39
@ INFUSE_STATE_REBOOTING
Device is about to reboot.
Definition states.h:37
@ INFUSE_STATE_TIME_KNOWN
Application has a valid time source.
Definition states.h:41
@ INFUSE_STATES_APP_START
Start of application-specific state range.
Definition states.h:55
@ INFUSE_STATES_END
End of the state range.
Definition states.h:57
@ INFUSE_STATE_DEVICE_STOPPED_MOVING
Device stopped moving.
Definition states.h:49
@ INFUSE_STATE_DEVICE_MOVING
Device is moving (not stationary)
Definition states.h:53
Infuse-IoT application state callback structure.
Definition states.h:69
void(* state_cleared)(enum infuse_state state, void *user_ctx)
Application state has been cleared.
Definition states.h:90
void * user_ctx
User provided context pointer.
Definition states.h:93
void(* state_set)(enum infuse_state state, bool already, uint16_t timeout, void *user_ctx)
Application state has been set.
Definition states.h:80