35 lines
645 B
C
35 lines
645 B
C
#include "command_handler.h"
|
|
#include "led.h"
|
|
|
|
#include <zephyr/logging/log.h>
|
|
|
|
LOG_MODULE_REGISTER(command_handler, LOG_LEVEL_INF);
|
|
|
|
int command_handler(struct command_message_t *msg) {
|
|
if (msg == NULL) {
|
|
LOG_ERR("Received NULL message pointer");
|
|
return -EINVAL;
|
|
}
|
|
|
|
LOG_DBG("Processing command: %d, length: %d", msg->command, msg->length);
|
|
|
|
switch (msg->command) {
|
|
case COMMAND_ERROR: {
|
|
LOG_WRN("Received COMMAND_ERROR");
|
|
break;
|
|
}
|
|
|
|
case LED: {
|
|
// Toggle LED with the LED command
|
|
led_toggle();
|
|
break;
|
|
}
|
|
|
|
default: {
|
|
LOG_WRN("Unknown command received: %d", msg->command);
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
} |