Data Gator
Hardware and software documentation for the Data Gator project.
Loading...
Searching...
No Matches
scheduler.hpp File Reference

Utilities for scheduling tasks and saving persistent data. More...

#include <NimBLEDevice.h>
#include <Adafruit_MAX1704X.h>
#include <OWMAdafruit_ADS1015.h>
#include <ble_util.hpp>
#include <VWCSensor.hpp>
#include <Teros10.hpp>
#include <Atlas_EZO-pH.hpp>
#include <Atlas_Gravity_pH.hpp>
Include dependency graph for scheduler.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  planner
 Data structure for task scheduling stored in NVS. More...
 

Functions

void init_nvs ()
 Open NVS, check if it is initialized with data, if not, initialize it.
 
bool task_is_scheduled (int reset_count)
 Check if a task will run this time, NVS must be initialized first!
 
void ReadHT ()
 Reads temperature and humidity sensors via BLE and then sends complete data to the database.
 
void ReadWired ()
 Reads all wired sensors attached to the aggregator.
 
void OTAUpdate ()
 Checks and updates from new code published at HTTPS address.
 
void PatWDT ()
 Pat the watchdog by raising watchdog done pin high, and then setting it low.
 
void SendTLM ()
 Send a telemetry message to the MQTT broker.
 
void Scheduler (int reset_count)
 Perform a state transition based on the number of reset counts.
 
void SchedulerClearAll (int reset_count)
 Clear all tasks so that none are scheduled to run.
 

Variables

bool maxlipo_attached
 Fuel Gauge successfully initialized?
 
Adafruit_MAX17048 maxlipo
 MAX17048 battery Fuel Gauge.
 
Adafruit_ADS1115 ads
 Analog to digital converter object (I2C)
 
int reset_count = -1
 number of resets retrieved for NVS
 
struct planner planner
 

Detailed Description

Utilities for scheduling tasks and saving persistent data.

Defines the mechanism for implementing task scheduling for sensors, OTA updates, etc. Timing is measured in "ticks". One tick is approximately 64 seconds or the time that the watchdog timer waits before reseting the device and waking it from hibernation. Ticks are tracked between power cycles using the non-volatile storage (NVS) system.

Author
Garrett Wells
Date
2023

Function Documentation

◆ Scheduler()

void Scheduler ( int  reset_count)

Perform a state transition based on the number of reset counts.

Parameters
[in]reset_countThe number of resets that have been performed in this epoch

◆ SchedulerClearAll()

void SchedulerClearAll ( int  reset_count)

Clear all tasks so that none are scheduled to run.

Parameters
[in]reset_countThe number of reset counts to have elapsed.

◆ task_is_scheduled()

bool task_is_scheduled ( int  reset_count)

Check if a task will run this time, NVS must be initialized first!

Parameters
[in]reset_countThe number of resets recorded.
Returns
true if a task is scheduled to run this reboot cycle, false otherwise

Variable Documentation

◆ ads

Adafruit_ADS1115 ads
extern

Analog to digital converter object (I2C)

Interface for the analog to digital converter.

◆ maxlipo

Adafruit_MAX17048 maxlipo
extern

MAX17048 battery Fuel Gauge.

Interface for the battery fuel gauge.

◆ maxlipo_attached

bool maxlipo_attached
extern

Fuel Gauge successfully initialized?

External flag indicating whether maxlipo was initialized successfully.

◆ reset_count

int reset_count = -1

number of resets retrieved for NVS

External variable holding the number of resets recorded by the system. Stored and loaded from non-volatile storage.