MeshX 0.3
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_config_server.c File Reference

Implementation of the Configuration Server for ESP BLE Mesh. More...

Include dependency graph for meshx_config_server.c:

Go to the source code of this file.

Data Structures

struct  config_server_model_evt_map
 

Macros

#define CONFIG_SRV_INIT_MAGIC   0x2307
 

Typedefs

typedef struct config_server_model_evt_map config_server_model_evt_map_t
 

Functions

static meshx_err_t meshx_config_server_control_task_handler (const dev_struct_t *pdev, control_task_msg_evt_t evt, const void *params)
 Handles the configuration server events from the control task.
 
meshx_err_t meshx_init_config_server ()
 Initializes the Configuration Server.
 
meshx_err_t meshx_config_server_cb_reg (config_srv_cb_t cb, uint32_t config_evt_bmap)
 Registers a configuration server callback for specific events.
 
meshx_err_t meshx_get_config_srv_instance (void **p_conf_srv)
 Retrieves the instance of the MeshX configuration server.
 
meshx_err_t meshx_get_config_srv_model (meshx_ptr_t p_model)
 Retrieves the configuration server model for the MeshX framework.
 

Variables

static uint16_t config_srv_init_flag = 0
 
static const config_server_model_evt_map_t config_server_model_evt_map_table []
 
uint16_t config_srv_evt_map_count = sizeof(config_server_model_evt_map_table) / sizeof(config_server_model_evt_map_t)
 

Detailed Description

Implementation of the Configuration Server for ESP BLE Mesh.

Copyright © 2024 - 2025 MeshX

This file contains the initialization and event handling logic for the BLE Mesh Configuration Server, including the management of callback registrations and event dispatching.

Author
Pranjal Chanda

Definition in file meshx_config_server.c.

Macro Definition Documentation

◆ CONFIG_SRV_INIT_MAGIC

#define CONFIG_SRV_INIT_MAGIC   0x2307

Definition at line 15 of file meshx_config_server.c.

Typedef Documentation

◆ config_server_model_evt_map_t

Function Documentation

◆ meshx_config_server_cb_reg()

meshx_err_t meshx_config_server_cb_reg ( config_srv_cb_t cb,
uint32_t config_evt_bmap )

Registers a configuration server callback for specific events.

Adds a new callback registration to the linked list for dispatching events.

Parameters
[in]cbCallback function to register.
[in]config_evt_bmapBitmap of events the callback is interested in.
Returns
MESHX_SUCCESS on success, an error code otherwise.

Definition at line 122 of file meshx_config_server.c.

123{
124 if (cb == NULL || config_evt_bmap == 0)
125 {
126 return MESHX_INVALID_ARG; // Invalid arguments
127 }
128
131 config_evt_bmap,
133
134}
meshx_err_t(* control_task_msg_handle_t)(dev_struct_t *pdev, control_task_msg_evt_t evt, void *params)
Function pointer type for control task message handler.
@ CONTROL_TASK_MSG_CODE_CONFIG
meshx_err_t control_task_msg_subscribe(control_task_msg_code_t msg_code, control_task_msg_evt_t evt_bmap, control_task_msg_handle_t callback)
Subscribe to a control task message.
@ MESHX_INVALID_ARG
Definition meshx_err.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_config_server_control_task_handler()

static meshx_err_t meshx_config_server_control_task_handler ( const dev_struct_t * pdev,
control_task_msg_evt_t evt,
const void * params )
static

Handles the configuration server events from the control task.

This function processes the events received from the control task and publishes them to the registered callbacks for the configuration server.

Parameters
[in]pdevPointer to the device structure.
[in]evtEvent type from the control task.
[in]paramsPointer to the parameters associated with the event.
Returns
MESHX_SUCCESS on success, an error code otherwise.

Definition at line 52 of file meshx_config_server.c.

57{
58 if(!pdev || !params)
59 {
60 return MESHX_INVALID_ARG;
61 }
62 const meshx_config_srv_cb_param_t *pub_param = (const meshx_config_srv_cb_param_t *)params;
63
65 {
66 return MESHX_INVALID_ARG;
67 }
68 /* Map event to config event */
70 for (uint16_t i = 0; i < config_srv_evt_map_count; i++)
71 {
72 if (config_server_model_evt_map_table[i].model_op_code == pub_param->ctx.opcode)
73 {
74 config_evt = config_server_model_evt_map_table[i].config_evt;
75 break;
76 }
77 }
78 if (config_evt == CONTROL_TASK_MSG_EVT_CONFIG_ALL)
79 {
80 return MESHX_INVALID_ARG;
81 }
82 /* Publish the event */
85 config_evt,
86 pub_param,
88}
#define MESHX_MODEL_ID_CONFIG_SRV
BLE Mesh models related Model ID and Opcode definitions.
struct meshx_config_srv_cb_param meshx_config_srv_cb_param_t
control_task_msg_evt_config_t config_evt_t
static const config_server_model_evt_map_t config_server_model_evt_map_table[]
uint16_t config_srv_evt_map_count
meshx_err_t control_task_msg_publish(control_task_msg_code_t msg_code, control_task_msg_evt_t msg_evt, const void *msg_evt_params, size_t sizeof_msg_evt_params)
Publish a control task message.
CONTROL_TASK_MSG_EVT_CONFIG_ALL
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_get_config_srv_instance()

meshx_err_t meshx_get_config_srv_instance ( void ** p_conf_srv)

Retrieves the instance of the MeshX configuration server.

This function provides access to the configuration server instance used in the MeshX framework. The configuration server is responsible for managing and storing configuration settings for the mesh network.

Parameters
[out]p_conf_srvPointer to a variable where the configuration server instance will be stored. The pointer must be of type void**.
Returns
  • MESHX_SUCCESS on successful retrieval of the configuration server instance.
  • An appropriate error code of type meshx_err_t on failure.

Definition at line 151 of file meshx_config_server.c.

152{
153 return meshx_plat_get_config_srv_instance(p_conf_srv);
154}
meshx_err_t meshx_plat_get_config_srv_instance(meshx_ptr_t *p_conf_srv)
Retrieve the instance of the BLE Mesh configuration server.
Here is the call graph for this function:

◆ meshx_get_config_srv_model()

meshx_err_t meshx_get_config_srv_model ( meshx_ptr_t p_model)

Retrieves the configuration server model for the MeshX framework.

This function provides access to the configuration server model used in the MeshX implementation. The retrieved model can be used for configuring and managing the mesh network.

Parameters
[out]p_modelPointer to a variable where the address of the configuration server model will be stored. The caller must ensure that the pointer is valid.
Returns
  • MESHX_SUCCESS on success.
  • An appropriate error code of type meshx_err_t on failure.

Definition at line 171 of file meshx_config_server.c.

172{
173 return meshx_plat_get_config_srv_model(p_model);
174}
meshx_err_t meshx_plat_get_config_srv_model(meshx_ptr_t p_model)
Retrieves the configuration server model for the BLE Mesh.
Here is the call graph for this function:

◆ meshx_init_config_server()

meshx_err_t meshx_init_config_server ( void )

Initializes the Configuration Server.

Initialize the meshxuction configuration server.

Registers the BLE Mesh Configuration Server callback function and prepares the server for use.

Returns
MESHX_SUCCESS on success, an error code otherwise.

Definition at line 97 of file meshx_config_server.c.

98{
100 return MESHX_INVALID_ARG;
101
103
108
110}
meshx_err_t meshx_plat_config_srv_init(void)
Initializes the MeshX platform configuration server.
static meshx_err_t meshx_config_server_control_task_handler(const dev_struct_t *pdev, control_task_msg_evt_t evt, const void *params)
Handles the configuration server events from the control task.
static uint16_t config_srv_init_flag
#define CONFIG_SRV_INIT_MAGIC
@ CONTROL_TASK_MSG_CODE_FRM_BLE
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ config_server_model_evt_map_table

const config_server_model_evt_map_t config_server_model_evt_map_table[]
static
Initial value:
= {
}
#define MESHX_MODEL_OP_MODEL_APP_BIND
#define MESHX_MODEL_OP_NET_KEY_DELETE
#define MESHX_MODEL_OP_MODEL_SUB_ADD
#define MESHX_MODEL_OP_MODEL_PUB_SET
#define MESHX_MODEL_OP_MODEL_SUB_DELETE
#define MESHX_MODEL_OP_APP_KEY_ADD
#define MESHX_MODEL_OP_MODEL_APP_UNBIND
#define MESHX_MODEL_OP_NET_KEY_ADD
#define MESHX_MODEL_OP_APP_KEY_DELETE
CONTROL_TASK_MSG_EVT_NET_KEY_DEL
CONTROL_TASK_MSG_EVT_APP_KEY_DEL
CONTROL_TASK_MSG_EVT_SUB_DEL
CONTROL_TASK_MSG_EVT_APP_KEY_UNBIND
CONTROL_TASK_MSG_EVT_APP_KEY_ADD
CONTROL_TASK_MSG_EVT_PUB_ADD
CONTROL_TASK_MSG_EVT_APP_KEY_BIND
CONTROL_TASK_MSG_EVT_SUB_ADD
CONTROL_TASK_MSG_EVT_NET_KEY_ADD

Definition at line 27 of file meshx_config_server.c.

◆ config_srv_evt_map_count

uint16_t config_srv_evt_map_count = sizeof(config_server_model_evt_map_table) / sizeof(config_server_model_evt_map_t)

Definition at line 38 of file meshx_config_server.c.

◆ config_srv_init_flag

uint16_t config_srv_init_flag = 0
static

Definition at line 18 of file meshx_config_server.c.