/** * @file cli_core.h * @brief CLI core: command table, command handlers and line execution, * decoupled from the transport (UART / BLE frame frontends). */ #ifndef __CLI_CORE_H__ #define __CLI_CORE_H__ #ifdef __cplusplus extern "C" { #endif #include /* Output callback: one string (not necessarily NUL-terminated style-safe; * always a C string here) per call. */ typedef void (*cli_out_fn)(const char* str); /** * @brief Set the output callback used by cli_write/cli_printf and by command * handlers during cli_exec_line(). Pass NULL to restore the default * UART DMA output. * @note The callback is a single global: the UART and BLE frontends must not * run cli_exec_line() concurrently (simple set/exec/restore policy, * see app_ble_proto.c). */ void cli_set_output(cli_out_fn out); /** * @brief Tokenize @p line in place and run the matching command. * @return 0 on success (or empty line), 1 on unknown command. */ int cli_exec_line(char* line); /* Output helpers routed through the current out callback */ void cli_write(const char* str); void cli_printf(const char* fmt, ...); /* Command table iteration (used by the UART frontend for TAB completion) */ uint32_t cli_cmd_count(void); const char* cli_cmd_name(uint32_t idx); #ifdef __cplusplus } #endif #endif /* __CLI_CORE_H__ */