ESP32/components/cmd_transport/cmd_transport.h

38 lines
1.0 KiB
C

#pragma once
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Function pointer structure for replying to the command source
*/
typedef void (*cmd_reply_func_t)(const char *msg, void *ctx);
/**
* @brief Callback for handling incoming lines
* * @param line The received line (null-terminated, trimmed of trailing CR/LF)
* @param reply_func Function to call to send a response back to the source
* @param reply_ctx Context pointer to pass to reply_func
* @return true if the line was consumed/handled
* @return false if the line should be passed to the next listener (or system console)
*/
typedef bool (*cmd_line_handler_t)(const char *line, cmd_reply_func_t reply_func, void *reply_ctx);
/**
* @brief Initialize the command transport (starts UART and USB listener tasks)
*/
void cmd_transport_init(void);
/**
* @brief Register a listener for console input
* @param handler The callback function
*/
void cmd_transport_register_listener(cmd_line_handler_t handler);
#ifdef __cplusplus
}
#endif