First
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user