Commit 634af243 authored by Eric Duminil's avatar Eric Duminil
Browse files

Refactor. Fewer dependencies for MQTT

parent 3d479e99
......@@ -118,7 +118,7 @@ namespace csv_writer {
Serial.println();
sensor_commands::defineIntCallback("csv", setCSVinterval, " 60 (Sets CSV writing interval, in s)");
// sensor_commands::defineCallback("format_filesystem", FS_LIB.format);
sensor_commands::defineCallback("format_filesystem", formatFilesystem, "(Deletes the whole filesystem.)");
}
File openOrCreate() {
......@@ -175,4 +175,9 @@ namespace csv_writer {
Serial.println("s.");
led_effects::showKITTWheel(color::green, 1);
}
void formatFilesystem() {
FS_LIB.format();
led_effects::showKITTWheel(color::blue, 2);
}
}
......@@ -27,6 +27,7 @@ namespace csv_writer {
extern const String filename;
void setCSVinterval(int32_t csv_interval);
void formatFilesystem();
}
#endif
......@@ -99,12 +99,7 @@ namespace mqtt {
if (messageString == "publish") {
Serial.println(F("Forcing MQTT publish now."));
publish(sensor::timestamp, sensor::co2, sensor::temperature, sensor::humidity);
#ifdef AMPEL_CSV
} else if (messageString == "format_filesystem") {
FS_LIB.format();
led_effects::showKITTWheel(color::blue, 2);
#endif
last_sent_at = 0;
} else if (messageString == "night_mode") {
led_effects::toggleNightMode();
} else if (messageString == "local_ip") {
......
......@@ -5,10 +5,6 @@
#include "config.h"
#include "led_effects.h"
#include "sensor_commands.h"
#ifdef AMPEL_CSV
# include "csv_writer.h"
#endif
#include "co2_sensor.h"
#include "src/lib/PubSubClient/src/PubSubClient.h"
#include "wifi_util.h"
namespace config {
......
......@@ -16,6 +16,10 @@ namespace sensor_commands {
Callback callbacks[MAX_CALLBACKS];
void defineCallback(const char *name, void (*function)(void), const char *doc) {
}
void defineIntCallback(const char *name, void (*function)(int32_t), const char *doc) {
if (callbacks_count < MAX_CALLBACKS) {
callbacks[callbacks_count] = Callback(name, function, doc);
......
......@@ -8,6 +8,6 @@
namespace sensor_commands {
void run(const char *command);
//TODO: Add defineIntCallback?
void defineIntCallback(const char *command, void (*function)(int32_t), const char *doc);
void defineCallback(const char *command, void (*function)(void), const char *doc);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment