This commit is contained in:
30
src/main.cpp
30
src/main.cpp
@@ -22,6 +22,7 @@
|
|||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include "sensor/sensor.h"
|
#include "sensor/sensor.h"
|
||||||
#include "external_interfacing/leds.h"
|
#include "external_interfacing/leds.h"
|
||||||
|
#include "telemetry/telemetry.h"
|
||||||
#include "tools/tools.h"
|
#include "tools/tools.h"
|
||||||
|
|
||||||
Preferences prefs;
|
Preferences prefs;
|
||||||
@@ -39,35 +40,6 @@ AsyncWebServer server(80);
|
|||||||
#define FORMAT_LITTLEFS_IF_FAILED true
|
#define FORMAT_LITTLEFS_IF_FAILED true
|
||||||
|
|
||||||
|
|
||||||
void collect_internal_telemetry_task(void* parameter)
|
|
||||||
{
|
|
||||||
while (true) {
|
|
||||||
float heap_usage = (float(ESP.getFreeHeap()) / float(ESP.getHeapSize())) * 100;
|
|
||||||
uint64_t uptime_seconds = millis() / 1000;
|
|
||||||
|
|
||||||
telemetry.heap_used_percent = heap_usage;
|
|
||||||
telemetry.uptime_seconds = uptime_seconds;
|
|
||||||
delay(60000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String processor(const String& var)
|
|
||||||
{
|
|
||||||
if (var == level_sensor_range_key) {
|
|
||||||
return String(prefs.getFloat(level_sensor_range_key, -1));
|
|
||||||
} else if (var == water_level_min_key) {
|
|
||||||
return String(prefs.getFloat(water_level_min_key, -1));
|
|
||||||
} else if (var == water_level_max_key) {
|
|
||||||
return String(prefs.getFloat(water_level_max_key, -1));
|
|
||||||
} else if (var == water_volume_key) {
|
|
||||||
return String(prefs.getFloat(water_volume_key, -1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return String("Test");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
prefs.begin("waterlevel", false);
|
prefs.begin("waterlevel", false);
|
||||||
|
|||||||
17
src/telemetry/telemetry.cpp
Normal file
17
src/telemetry/telemetry.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "telemetry.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "../global_data/global_data.h"
|
||||||
|
|
||||||
|
extern DeviceTelemetry telemetry;
|
||||||
|
|
||||||
|
void collect_internal_telemetry_task(void* parameter)
|
||||||
|
{
|
||||||
|
while (true) {
|
||||||
|
float heap_usage = (float(ESP.getFreeHeap()) / float(ESP.getHeapSize())) * 100;
|
||||||
|
uint64_t uptime_seconds = millis() / 1000;
|
||||||
|
|
||||||
|
telemetry.heap_used_percent = heap_usage;
|
||||||
|
telemetry.uptime_seconds = uptime_seconds;
|
||||||
|
delay(60000);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/telemetry/telemetry.h
Normal file
1
src/telemetry/telemetry.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
void collect_internal_telemetry_task(void* parameter);
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include <ArduinoLog.h>
|
#include <ArduinoLog.h>
|
||||||
|
#include "../global_data/defines.h"
|
||||||
|
#include <Preferences.h>
|
||||||
|
|
||||||
|
extern Preferences prefs;
|
||||||
|
|
||||||
void printSuffix(Print* _logOutput, int logLevel)
|
void printSuffix(Print* _logOutput, int logLevel)
|
||||||
{
|
{
|
||||||
@@ -18,4 +22,19 @@ void print_prefix(Print* _logOutput, int logLevel)
|
|||||||
|
|
||||||
bool is_error(ActiveErrors active_errors) {
|
bool is_error(ActiveErrors active_errors) {
|
||||||
return active_errors.current_high || active_errors.current_low || active_errors.level_high || active_errors.level_low || active_errors.voltage_high || active_errors.voltage_low;
|
return active_errors.current_high || active_errors.current_low || active_errors.level_high || active_errors.level_low || active_errors.voltage_high || active_errors.voltage_low;
|
||||||
|
}
|
||||||
|
|
||||||
|
String processor(const String& var)
|
||||||
|
{
|
||||||
|
if (var == level_sensor_range_key) {
|
||||||
|
return String(prefs.getFloat(level_sensor_range_key, -1));
|
||||||
|
} else if (var == water_level_min_key) {
|
||||||
|
return String(prefs.getFloat(water_level_min_key, -1));
|
||||||
|
} else if (var == water_level_max_key) {
|
||||||
|
return String(prefs.getFloat(water_level_max_key, -1));
|
||||||
|
} else if (var == water_volume_key) {
|
||||||
|
return String(prefs.getFloat(water_volume_key, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return String("Test");
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,5 @@
|
|||||||
|
|
||||||
void printSuffix(Print* _logOutput, int logLevel);
|
void printSuffix(Print* _logOutput, int logLevel);
|
||||||
void print_prefix(Print* _logOutput, int logLevel);
|
void print_prefix(Print* _logOutput, int logLevel);
|
||||||
bool is_error(ActiveErrors active_errors);
|
bool is_error(ActiveErrors active_errors);
|
||||||
|
String processor(const String& var);
|
||||||
Reference in New Issue
Block a user