esp_garden git · master
Distributed ESP sensor and actuator system (garden)
C++ 70.7% Markdown 18% C 10.7%git clone https://git.christianimmanuel.de/embedded/esp_garden.gitwget https://git.christianimmanuel.de/embedded/esp_garden/archive/esp_garden.tar.gzclient_sensor/main/ClientSensor.h raw
#ifndef CLIENTSENSOR_H
#define CLIENTSENSOR_H
#include "globals.h"
// ----------------------------------------------------------------------------
// WiFi handling
// ----------------------------------------------------------------------------
void init_WiFi();
// ----------------------------------------------------------------------------
// Peers
// ----------------------------------------------------------------------------
void print_SensorConfig(const SensorConfig_s& cfg);
// ----------------------------------------------------------------------------
// Config to flash
// ----------------------------------------------------------------------------
void restore_SensorConfigs();
// ----------------------------------------------------------------------------
// ESP-NOW handling
// ----------------------------------------------------------------------------
void ensure_Peers();
void init_EspNow();
// ----------------------------------------------------------------------------
// Time handling
// ----------------------------------------------------------------------------
void save_time_reference(int64_t epoch, int64_t uptime);
void load_time_reference(int64_t *epoch, int64_t *uptime);
int64_t get_CurrentUnix();
int64_t get_CurrentUnixMs();
bool request_TimeSync(uint32_t timeout_ms = 3000);
void setup_Timezone();
// ----------------------------------------------------------------------------
// Deep sleep scheduler
// ----------------------------------------------------------------------------
int64_t get_NextSensorReadFor(const char* sensor_name);
int64_t get_NextSensorReadsUnixTime(const uint8_t* mac = nullptr);
void sleep_UntilNextSend(int64_t next_read);
void set_AllNextSensorReads();
// ----------------------------------------------------------------------------
// Request sensor config from server via ESP-NOW
// ----------------------------------------------------------------------------
void get_AllSensorConfigs();
void process_PendingSensorConfigs();
// ----------------------------------------------------------------------------
// Send Data to peers
// ----------------------------------------------------------------------------
bool is_TimeToReadSensor(const SensorConfig_s& cfg);
void send_DataToPumpAndServer(size_t config_id, uint32_t value, bool shall_pump);
void send_NextSensorReadToPeer(const uint8_t* mac, int64_t unix_time);
#endif