MeshX 0.4
This repository provides an implementation for Bluetooth Low Energy (BLE) Mesh network nodes. The project allows you to create BLE mesh nodes that can communicate with each other, enabling the development of smart home solutions or other IoT-based applications.
Loading...
Searching...
No Matches
meshx_shell.h File Reference

Platform-agnostic shell interface for MeshX. More...

#include "meshx_err.h"

Go to the source code of this file.

Data Structures

struct  meshx_shell_cmd_t
 Shell command structure. More...

Macros

#define MESHX_SHELL_MAX_COMMANDS   32

Typedefs

typedef int(* meshx_shell_func_t) (int argc, char **argv)
 Shell command function pointer type.

Functions

meshx_err_t meshx_shell_init (void)
 Initializes the MeshX shell core and the underlying platform console.
meshx_err_t meshx_shell_register_command (const meshx_shell_cmd_t *cmd)
 Registers a command with the MeshX shell.
meshx_err_t meshx_shell_start (void)
 Starts the MeshX shell task.
void meshx_shell_printf (const char *fmt,...)
 Prints a message to the shell console.

Detailed Description

Platform-agnostic shell interface for MeshX.

Copyright © 2024 - 2025 MeshX

Macro Definition Documentation

◆ MESHX_SHELL_MAX_COMMANDS

#define MESHX_SHELL_MAX_COMMANDS   32

Typedef Documentation

◆ meshx_shell_func_t

typedef int(* meshx_shell_func_t) (int argc, char **argv)

Shell command function pointer type.

Function Documentation

◆ meshx_shell_init()

meshx_err_t meshx_shell_init ( void )

Initializes the MeshX shell core and the underlying platform console.

Returns
meshx_err_t MESHX_SUCCESS on success, error code otherwise.
102 {
103 if (shell_ctx.initialized) return MESHX_SUCCESS;
104
105 memset(&shell_ctx, 0, sizeof(shell_ctx));
106 MESHX_LOGD(MODULE_ID_COMMON, "Initializing MeshX Shell...");
107
109 if (err != MESHX_SUCCESS) {
110 MESHX_LOGE(MODULE_ID_COMMON, "Platform console init failed: %d", err);
111 return err;
112 }
113
114 shell_ctx.initialized = true;
115 MESHX_LOGD(MODULE_ID_COMMON, "MeshX Shell Initialized");
116 return MESHX_SUCCESS;
117}
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
#define MESHX_LOGE(module_id, format,...)
Definition meshx_log.h:114
#define MESHX_LOGD(module_id, format,...)
Definition meshx_log.h:132
**This function is called by the parent element when a state change request *is received It validates the request and returns a result to the element not the model layer **return * MESHX_SUCCESS
Definition meshx_model_level.cpp:385
meshx_err_t meshx_platform_console_init(void)
Initializes the console interface.
Definition esp_platform.c:144
static struct @335173246346112024255321071157347140337303275335 shell_ctx
@ MODULE_ID_COMMON
Definition module_id.h:36

◆ meshx_shell_printf()

void meshx_shell_printf ( const char * fmt,
... )

Prints a message to the shell console.

Parameters
[in]fmtFormat string.
[in]...Arguments.
30 {
31 va_list args;
32 va_start(args, fmt);
33 meshx_tiny_vprintf(fmt, args);
34 va_end(args);
35}
int meshx_tiny_vprintf(const char *fmt, va_list args)
Definition meshx_tiny_printf.c:157

◆ meshx_shell_register_command()

meshx_err_t meshx_shell_register_command ( const meshx_shell_cmd_t * cmd)

Registers a command with the MeshX shell.

Parameters
[in]cmdPointer to the command structure.
Returns
meshx_err_t MESHX_SUCCESS on success, error code otherwise.
119 {
120 if (!shell_ctx.initialized) {
121 MESHX_LOGE(MODULE_ID_COMMON, "Shell not initialized, cannot register command '%s'", cmd->command);
122 return MESHX_ERR_NOT_INIT;
123 }
124 if (shell_ctx.cmd_count >= MESHX_SHELL_MAX_COMMANDS) return MESHX_FAIL;
125
126 shell_ctx.commands[shell_ctx.cmd_count++] = *cmd;
127 return MESHX_SUCCESS;
128}
@ MESHX_FAIL
Definition meshx_err.h:45
@ MESHX_ERR_NOT_INIT
Definition meshx_err.h:53
#define MESHX_SHELL_MAX_COMMANDS
Definition meshx_shell.h:32
const char * command
Definition meshx_shell.h:26

◆ meshx_shell_start()

meshx_err_t meshx_shell_start ( void )

Starts the MeshX shell task.

Returns
meshx_err_t MESHX_SUCCESS on success, error code otherwise.
130 {
131 meshx_task_t task_cfg = {
132 .task_cb = shell_task,
133 .task_name = "meshx_shell",
134 .stack_size = 4096,
135 .priority = 4,
136 .arg = NULL
137 };
138
139 return meshx_task_create(&task_cfg);
140}
static void shell_task(void *pvParameters)
Definition meshx_shell.c:75
struct meshx_task meshx_task_t
MeshX Task Structure.
meshx_err_t meshx_task_create(meshx_task_t *task_handle)
Create a MeshX Task.