Commit 755f8578 authored by Eric Duminil's avatar Eric Duminil
Browse files

Looking for corresponding code

parent 96d9138d
......@@ -59,10 +59,19 @@ namespace sensor_commands {
return 0;
}
void listAvailableCallbacks() {
Serial.println("DEBUG - Available commands :");
for (uint8_t i = 0; i < callbacks_count; i++) {
Serial.print(" ");
Serial.println(callbacks[i].name);
}
}
void run(const char *command) {
char function_name[MAX_COMMAND_SIZE];
long parameter;
if (parseCommand(command, function_name, parameter)) {
listAvailableCallbacks();
return;
}
Serial.print("Command : '");
......@@ -72,14 +81,15 @@ namespace sensor_commands {
// Test all the callbacks.
for (uint8_t i = 0; i < callbacks_count; i++) {
if (startsWith(function_name, callbacks[i].name)) {
Serial.print("OHHHH YES!!!");
if (!strcmp(function_name, callbacks[i].name)) {
Serial.print("Function found!!!");
Serial.print("Trying '");
Serial.print(callbacks[i].name);
Serial.println("'");
callbacks[i].function(callbacks[i].data);
return;
}
Serial.print("Trying '");
Serial.print(callbacks[i].name);
Serial.println("'");
callbacks[i].function(callbacks[i].data);
}
Serial.println("Done.");
listAvailableCallbacks();
}
}
Supports Markdown
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