Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
|
Task runner schedule API . More...
Data Structures | |
struct | task_schedule_tdf_logging |
Control TDF logging output of a task. More... | |
struct | task_schedule_state_conditions |
Schedule state conditions. More... | |
struct | task_schedule |
Schedule for a given task. More... | |
struct | task_schedule_state |
State for a given task schedule. More... | |
Macros | |
#define | TR_NOT 0x100 |
Invert the state. | |
#define | TASK_STATES_DEFINE(...) |
Helper for constructing a task_schedule_state_conditions struct. | |
#define | TASK_RUNNER_LOCKOUT_IGNORE_FIRST BIT(31) |
Normally the lockout period must elapse after boot before the periodicity check passes. | |
#define | TASK_SCHEDULE_STATES_DEFINE(name, schedules) |
Instantiate schedule state array. | |
Typedefs | |
typedef void(* | task_schedule_event_cb_t) (const struct task_schedule *schedule, enum task_schedule_event event) |
Callback notifying that an event has occurred on a schedule. | |
Enumerations | |
enum | task_runner_valid_type { TASK_LOCKED = 0x80 , TASK_VALID_ALWAYS = 1 , TASK_VALID_ACTIVE = 2 , TASK_VALID_INACTIVE = 3 , TASK_VALID_PERMANENTLY_RUNS = 4 } |
enum | task_runner_periodicity_type { TASK_PERIODICITY_FIXED = 1 , TASK_PERIODICITY_LOCKOUT = 2 , TASK_PERIODICITY_AFTER = 3 } |
enum | task_schedule_event { TASK_SCHEDULE_STARTED = 0 , TASK_SCHEDULE_TERMINATE_REQUEST = 1 , TASK_SCHEDULE_STOPPED = 2 } |
Events that can trigger callbacks. More... | |
Functions | |
bool | task_schedule_validate (const struct task_schedule *schedule) |
Basic validity checking on task schedules. | |
bool | task_schedule_should_start (const struct task_schedule *schedule, struct task_schedule_state *state, atomic_t *app_states, uint32_t uptime, uint32_t epoch_time, uint8_t battery) |
Determine whether a task should start executing. | |
bool | task_schedule_should_terminate (const struct task_schedule *schedule, struct task_schedule_state *state, atomic_t *app_states, uint32_t uptime, uint32_t epoch_time, uint8_t battery) |
Determine whether a task should be terminated. | |
Task runner schedule API .
#define TASK_RUNNER_LOCKOUT_IGNORE_FIRST BIT(31) |
#include <infuse/task_runner/schedule.h>
Normally the lockout period must elapse after boot before the periodicity check passes.
Apply to task_schedule.periodicity.lockout.lockout_s for the periodicity check to always pass before the schedule runs for the first time.
#define TASK_SCHEDULE_STATES_DEFINE | ( | name, | |
schedules ) |
#include <infuse/task_runner/schedule.h>
Instantiate schedule state array.
If loading schedules from the KV store is enabled, the array is sized to the maximum number of schedules possible. Otherwise, it is sized to the number of default schedules.
name | Name of the schedule state array |
schedules | Array of default schedules |
#define TASK_STATES_DEFINE | ( | ... | ) |
#include <infuse/task_runner/schedule.h>
Helper for constructing a task_schedule_state_conditions struct.
... | Variable number of states (up to 4) which are evaluated together. Each state can be optionally inverted (with TR_NOT), and all states are AND'ed together for the final decision. |
#define TR_NOT 0x100 |
#include <infuse/task_runner/schedule.h>
Invert the state.
typedef void(* task_schedule_event_cb_t) (const struct task_schedule *schedule, enum task_schedule_event event) |
#include <infuse/task_runner/schedule.h>
Callback notifying that an event has occurred on a schedule.
schedule | Schedule with the event |
event | Event that occurred |
#include <infuse/task_runner/schedule.h>
#include <infuse/task_runner/schedule.h>
Enumerator | |
---|---|
TASK_LOCKED | Do not update definition from KV store. |
TASK_VALID_ALWAYS | Task is always valid. |
TASK_VALID_ACTIVE | Task is only valid when INFUSE_STATE_APPLICATION_ACTIVE is set. |
TASK_VALID_INACTIVE | Task is only valid when INFUSE_STATE_APPLICATION_ACTIVE is not set. |
TASK_VALID_PERMANENTLY_RUNS | Entry and exit conditions never checked, task is rebooted if it terminates. |
enum task_schedule_event |
#include <infuse/task_runner/schedule.h>
Events that can trigger callbacks.
bool task_schedule_should_start | ( | const struct task_schedule * | schedule, |
struct task_schedule_state * | state, | ||
atomic_t * | app_states, | ||
uint32_t | uptime, | ||
uint32_t | epoch_time, | ||
uint8_t | battery ) |
#include <infuse/task_runner/schedule.h>
Determine whether a task should start executing.
schedule | Task schedule to evaluate |
state | Previous state of the schedule |
app_states | Current application states |
uptime | Current system uptime in seconds |
epoch_time | Current epoch time (GPS time) in seconds |
battery | Battery charge percent |
true | Task should be started |
false | Task should not be started |
bool task_schedule_should_terminate | ( | const struct task_schedule * | schedule, |
struct task_schedule_state * | state, | ||
atomic_t * | app_states, | ||
uint32_t | uptime, | ||
uint32_t | epoch_time, | ||
uint8_t | battery ) |
#include <infuse/task_runner/schedule.h>
Determine whether a task should be terminated.
schedule | Task schedule to evaluate |
state | Previous state of the schedule |
app_states | Current application states |
uptime | Current system uptime in seconds |
epoch_time | Current epoch time (GPS time) in seconds |
battery | Battery charge percent |
true | Task should be terminated |
false | Task should not be terminated |
bool task_schedule_validate | ( | const struct task_schedule * | schedule | ) |
#include <infuse/task_runner/schedule.h>
Basic validity checking on task schedules.
schedule | Schedule to validate |
true | If schedule doesn't contain invalid parameters |
false | If schedule contains invalid parameters |