Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
|
Data Structures | |
struct | infuse_state_cb |
Infuse-IoT application state callback structure. More... | |
Macros | |
#define | INFUSE_STATES_ARRAY_SIZE ATOMIC_BITMAP_SIZE(INFUSE_STATES_END + 1) |
#define | INFUSE_STATES_ARRAY(name) |
Define a variable that can hold all Infuse-IoT application states. | |
Enumerations | |
enum | infuse_state { INFUSE_STATE_REBOOTING = 1 , INFUSE_STATE_APPLICATION_ACTIVE = 2 , INFUSE_STATE_TIME_KNOWN = 3 , INFUSE_STATE_DEVICE_STATIONARY = 4 , INFUSE_STATE_HIGH_PRIORITY_UPLINK = 5 , INFUSE_STATE_DEVICE_STARTED_MOVING = 6 , INFUSE_STATE_DEVICE_STOPPED_MOVING = 7 , INFUSE_STATES_APP_START = 128 , INFUSE_STATES_END = UINT8_MAX } |
Infuse-IoT application states. More... | |
Functions | |
void | infuse_state_register_callback (struct infuse_state_cb *cb) |
Register to be notified of state update events. | |
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. | |
bool | infuse_state_set_timeout (enum infuse_state state, uint16_t timeout) |
Set an application state that times out after a duration. | |
int | infuse_state_get_timeout (enum infuse_state state) |
Get the timeout associated with a state. | |
bool | infuse_state_clear (enum infuse_state state) |
Clear an application state. | |
static bool | infuse_state_set_to (enum infuse_state state, bool val) |
Set an application state to a specific value. | |
bool | infuse_state_get (enum infuse_state state) |
Get 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. | |
void | infuse_states_tick (atomic_t snapshot[ATOMIC_BITMAP_SIZE(INFUSE_STATES_END+1)]) |
Run one tick of the state timeouts. | |
#define INFUSE_STATES_ARRAY | ( | name | ) |
#include <infuse/states.h>
Define a variable that can hold all Infuse-IoT application states.
#define INFUSE_STATES_ARRAY_SIZE ATOMIC_BITMAP_SIZE(INFUSE_STATES_END + 1) |
#include <infuse/states.h>
enum infuse_state |
#include <infuse/states.h>
Infuse-IoT application states.
1 - 127: Infuse-IoT defined states 128 - 255: Application specific states
bool infuse_state_clear | ( | enum infuse_state | state | ) |
#include <infuse/states.h>
Clear an application state.
state | State to clear |
bool infuse_state_get | ( | enum infuse_state | state | ) |
#include <infuse/states.h>
Get an application state.
state | State to query |
true | Application state is set |
false | Application state is not set |
int infuse_state_get_timeout | ( | enum infuse_state | state | ) |
#include <infuse/states.h>
Get the timeout associated with a state.
state | State to query timeout of |
-EINVAL | is state is not set |
0 | if state is set but has no timeout |
timeout | seconds until the state is cleared otherwise |
void infuse_state_register_callback | ( | struct infuse_state_cb * | cb | ) |
#include <infuse/states.h>
Register to be notified of state update events.
cb | Callback struct to register |
bool infuse_state_set | ( | enum infuse_state | state | ) |
#include <infuse/states.h>
Set an application state.
Application state will remain set until infuse_state_clear is called. Any pending timeouts from infuse_state_set_timeout will be cancelled.
state | State to set |
bool infuse_state_set_timeout | ( | enum infuse_state | state, |
uint16_t | timeout ) |
#include <infuse/states.h>
Set an application state that times out after a duration.
Calling this function multiple times will reschedule the timeout each time. If the state was previously set without a timeout via infuse_state_set, a timeout will be added.
state | State to set |
timeout | Seconds that state should be set for |
|
inlinestatic |
#include <infuse/states.h>
Set an application state to a specific value.
state | State to set |
val | Value to set to |
bool infuse_state_unregister_callback | ( | struct infuse_state_cb * | cb | ) |
#include <infuse/states.h>
Unregister previously registered callback structure.
cb | Callback struct to unregister |
true | When callback structure unregistered |
false | When structure was not previously registered |
void infuse_states_snapshot | ( | atomic_t | snapshot[ATOMIC_BITMAP_SIZE(INFUSE_STATES_END+1)] | ) |
#include <infuse/states.h>
Get a snapshot of the current application states.
snapshot | Memory to store snapshot in |
void infuse_states_tick | ( | atomic_t | snapshot[ATOMIC_BITMAP_SIZE(INFUSE_STATES_END+1)] | ) |
#include <infuse/states.h>
Run one tick of the state timeouts.
The requirement to provide the snapshotted state is to prevent situations where a state is set just before this function is called, but after the consumer of the states has run. The typical concrete example of this is the task runner. This feature ensures that for a timeout of N, the state is set for N iterations of the task runner evaluation.
snapshot | States that were present at evaluation time, from infuse_states_snapshot |