Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Task runner schedule APIs

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.
 

Detailed Description

Task runner schedule API .

Macro Definition Documentation

◆ TASK_RUNNER_LOCKOUT_IGNORE_FIRST

#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.

◆ TASK_SCHEDULE_STATES_DEFINE

#define TASK_SCHEDULE_STATES_DEFINE ( name,
schedules )

#include <infuse/task_runner/schedule.h>

Value:
static struct task_schedule_state name[_TASK_SCHEDULE_MAX_SCHEDULES(schedules)]
State for a given task schedule.
Definition schedule.h:223

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.

Parameters
nameName of the schedule state array
schedulesArray of default schedules

◆ TASK_STATES_DEFINE

#define TASK_STATES_DEFINE ( ...)

#include <infuse/task_runner/schedule.h>

Value:
_TR_GET_MACRO(__VA_ARGS__, _TR_STATES_4, _TR_STATES_3, _TR_STATES_2, _TR_STATES_1) \
(__VA_ARGS__)

Helper for constructing a task_schedule_state_conditions struct.

struct state_control test1 = TASK_STATES_DEFINE(10);
struct state_control test2 = TASK_STATES_DEFINE(10, 11, 45, 200);
struct state_control test3 = TASK_STATES_DEFINE(TR_NOT | 34, 12, TR_NOT | 99);
#define TASK_STATES_DEFINE(...)
Helper for constructing a task_schedule_state_conditions struct.
Definition schedule.h:104
#define TR_NOT
Invert the state.
Definition schedule.h:65
Parameters
...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.

◆ TR_NOT

#define TR_NOT   0x100

#include <infuse/task_runner/schedule.h>

Invert the state.

Typedef Documentation

◆ task_schedule_event_cb_t

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.

Note
Callback can only be assigned to the task_schedule_state AFTER the call to task_runner_init.
Parameters
scheduleSchedule with the event
eventEvent that occurred

Enumeration Type Documentation

◆ task_runner_periodicity_type

#include <infuse/task_runner/schedule.h>

Enumerator
TASK_PERIODICITY_FIXED 

Task can only run on N second boundaries.

TASK_PERIODICITY_LOCKOUT 

Task can only run N seconds after previous run started.

TASK_PERIODICITY_AFTER 

Task can only run N seconds after another schedule terminates.

◆ task_runner_valid_type

#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.

◆ task_schedule_event

#include <infuse/task_runner/schedule.h>

Events that can trigger callbacks.

Enumerator
TASK_SCHEDULE_STARTED 

Task associated with the schedule has been started.

TASK_SCHEDULE_TERMINATE_REQUEST 

Task associated with the schedule has been requested to terminate.

TASK_SCHEDULE_STOPPED 

Task associated with the schedule has stopped.

Function Documentation

◆ task_schedule_should_start()

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.

Parameters
scheduleTask schedule to evaluate
statePrevious state of the schedule
app_statesCurrent application states
uptimeCurrent system uptime in seconds
epoch_timeCurrent epoch time (GPS time) in seconds
batteryBattery charge percent
Return values
trueTask should be started
falseTask should not be started

◆ task_schedule_should_terminate()

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.

Parameters
scheduleTask schedule to evaluate
statePrevious state of the schedule
app_statesCurrent application states
uptimeCurrent system uptime in seconds
epoch_timeCurrent epoch time (GPS time) in seconds
batteryBattery charge percent
Return values
trueTask should be terminated
falseTask should not be terminated

◆ task_schedule_validate()

bool task_schedule_validate ( const struct task_schedule * schedule)

#include <infuse/task_runner/schedule.h>

Basic validity checking on task schedules.

Note
This function checks for schedules that would lead to divide-by-zero or similar errors, not for schedules that will never execute.
Parameters
scheduleSchedule to validate
Return values
trueIf schedule doesn't contain invalid parameters
falseIf schedule contains invalid parameters