Commit 3546cc81 authored by Eric Duminil's avatar Eric Duminil
Browse files

Adding documentation to commands

parent 0722bbb7
......@@ -103,17 +103,18 @@ namespace sensor {
Serial.print(F("Auto-calibration is "));
Serial.println(config::auto_calibrate_sensor ? "ON." : "OFF.");
sensor_commands::defineCallback("co2", setCO2forDebugging);
sensor_commands::defineCallback("timer", setTimer);
sensor_commands::defineCallback("calibrate", calibrateSensorToSpecificPPM);
sensor_commands::defineCallback("calibrate!", calibrateSensorRightNow);
sensor_commands::defineCallback("co2", setCO2forDebugging, " 1500 (Sets co2 level, for debugging purposes)");
sensor_commands::defineCallback("timer", setTimer, " 30 (Sets measurement interval)");
sensor_commands::defineCallback("calibrate", calibrateSensorToSpecificPPM,
" 600 (Starts calibration process, to given ppm)");
sensor_commands::defineCallback("calibrate!", calibrateSensorRightNow, " 600 (Calibrates right now, to given ppm)");
}
//NOTE: should timer deviation be used to adjust measurement_timestep?
void checkTimerDeviation() {
static int32_t previous_measurement_at = 0;
int32_t now = millis();
Serial.print("Measurement time offset : ");
Serial.print(F("Measurement time offset : "));
Serial.print(now - previous_measurement_at - config::measurement_timestep * 1000);
Serial.println(" ms.");
previous_measurement_at = now;
......
......@@ -125,7 +125,7 @@ namespace csv_writer {
showFilesystemContent();
Serial.println();
sensor_commands::defineCallback("csv", setCSVinterval);
sensor_commands::defineCallback("csv", setCSVinterval, " 60 (Sets CSV writing interval)");
// sensor_commands::defineCallback("format_filesystem", FS_LIB.format);
}
......
......@@ -44,7 +44,7 @@ namespace mqtt {
// mqttClient.setSocketTimeout(config::mqtt_timeout); //NOTE: somehow doesn't seem to have any effect on connect()
mqttClient.setServer(config::mqtt_server, config::mqtt_port);
sensor_commands::defineCallback("mqtt", setMQTTinterval);
sensor_commands::defineCallback("mqtt", setMQTTinterval, " 60 (Sets MQTT sending interval)");
}
void publish(const String &timestamp, int16_t co2, float temperature, float humidity) {
......
......@@ -5,20 +5,20 @@ namespace sensor_commands {
const uint8_t MAX_COMMAND_SIZE = 30;
uint8_t callbacks_count = 0;
//TODO: Add example? Add description?
struct Callback {
Callback(const char *s = 0, void (*f)(int32_t) = 0) :
name(s), function(f) {
Callback(const char *s = 0, void (*f)(int32_t) = 0, const char *d = 0) :
name(s), function(f), doc(d) {
}
const char *name;
void (*function)(int32_t);
const char *doc;
};
Callback callbacks[MAX_CALLBACKS];
void defineCallback(const char *n, void (*f)(int32_t)) {
void defineCallback(const char *name, void (*function)(int32_t), const char *doc) {
if (callbacks_count < MAX_CALLBACKS) {
callbacks[callbacks_count] = Callback(n, f);
callbacks[callbacks_count] = Callback(name, function, doc);
callbacks_count++;
} else {
Serial.println(F("Too many callbacks have been defined."));
......@@ -58,11 +58,12 @@ namespace sensor_commands {
}
void listAvailableCallbacks() {
Serial.println(F("Message not supported. Doing nothing. Available commands :"));
Serial.println(F("Message not supported. Available commands :"));
for (uint8_t i = 0; i < callbacks_count; i++) {
Serial.print(" ");
Serial.print(callbacks[i].name);
Serial.println(" 1234");
Serial.print(callbacks[i].doc);
Serial.println(".");
}
led_effects::showKITTWheel(color::red, 1);
}
......
......@@ -9,5 +9,5 @@
namespace sensor_commands {
void run(const char *command);
//TODO: Add defineIntCallback?
void defineCallback(const char *command, void (*f)(int32_t));
void defineCallback(const char *command, void (*function)(int32_t), 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