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_base_model_common.hpp
Go to the documentation of this file.
1/**
2 * @file meshx_base_model_common.hpp
3 * @brief Header file for MeshX Config Server base class implementation.
4 *
5 * This header file contains the declarations for Config Server BLE mesh model classes
6 * that extend the template-based meshXBaseServerModel. It defines the specific
7 * implementation for Config Server models including message contexts, callback structures,
8 * and the main Config Server model class.
9 *
10 * Key Components:
11 * - Config Server message context structures for TXCM integration
12 * - Config Server parameter structures for state management
13 * - meshXBaseConfigServerModel class with Config-specific functionality
14 * - Platform-specific message sending and state restoration interfaces
15 * - Opcode validation for Config Server model operations
16 *
17 * Template Specialization:
18 * This file provides concrete implementations of the template-based base classes
19 * specifically tailored for Config BLE mesh server models, ensuring type safety and
20 * optimal performance for configuration management operations.
21 *
22 * @author Pranjal Chanda
23 * @date 2024-2025
24 * @copyright Copyright © 2024 - 2025 MeshX
25 */
26#ifndef _MESHX_BASE_MODE_COMMON_H_
27#define _MESHX_BASE_MODE_COMMON_H_
28
30
31#define MESHX_BASE_CONFIG_SERVER_TEMPLATE_PROTO
32#define MESHX_BASE_CONFIG_SERVER_TEMPLATE_PARAMS
33
34#if CONFIG_ENABLE_CONFIG_SERVER
35/*********************************************************************************************************
36 * meshXBaseConfigServerModel
37 ********************************************************************************************************/
38
39/**
40 * @struct meshx_config_server_send_params
41 * @brief Structure containing the parameters for config server model message sending.
42 *
43 * This structure is used to store the message parameters for config server model messages,
44 * including the model pointer, context pointer, state change information, and message length.
45 */
47{
48 meshx_model_t *p_model; /**< Pointer to the server model. */
49 meshx_ctx_t *p_ctx; /**< Pointer to the context. */
50 uint8_t *p_data; /**< Pointer to the message data. */
51 size_t data_len; /**< Length of the data. */
52};
53
54/**
55 * @struct meshx_config_server_restore_params
56 * @brief Structure containing the parameters for config server model state restoration.
57 *
58 * This structure is used to store the state restoration parameters for config server models,
59 * including the model pointer and state change information.
60 */
62{
63 meshx_model_t *p_model; /**< Pointer to the server model. */
64 uint8_t *p_data; /**< Pointer to the state data. */
65 size_t data_len; /**< Length of the state data. */
66};
67
68/**
69 * @class meshXBaseConfigServerModel
70 * @brief Template specialization of meshXBaseServerModel for Config BLE mesh server models.
71 *
72 * This class provides a concrete implementation of the template-based meshXBaseServerModel
73 * specifically designed for Config BLE mesh server models. It inherits all the template
74 * benefits including type safety, static callback dispatching, and enhanced debugging
75 * while providing Config-specific functionality.
76 *
77 * Key Features:
78 * - Inherits template-based architecture from meshXBaseServerModel
79 * - Provides Config-specific opcode validation and message handling
80 * - Implements platform-specific message sending
81 * - Supports configuration and provisioning operations
82 * - Enhanced error handling and debugging with template type identification
83 * - Static wrapper functions for C-style callback compatibility
84 *
85 * Template Parameters:
86 * - baseServerModelDerived_t: meshXBaseConfigServerModel (CRTP pattern)
87 * - ble_mesh_send_msg_params_t: meshx_config_server_send_params_t
88 * - ble_mesh_restore_params_t: meshx_config_server_restore_params_t
89 *
90 * Supported Operations:
91 * - Node identity operations
92 * - Model composition operations
93 * - Configuration status updates
94 * - Provisioning-related configurations
95 * - Device property operations
96 * - State restoration from persistent storage
97 *
98 * @note This class uses private inheritance to maintain encapsulation while
99 * providing access to base functionality through friendship.
100 * @see meshXBaseServerModel for base template functionality.
101 * @see meshx_config_server_send_params_t for send parameter structure.
102 * @see meshx_config_server_restore_params_t for restore parameter structure.
103 */
105class meshXBaseConfigServerModel : public meshXBaseServerModel<meshXBaseConfigServerModel, meshx_config_server_send_params_t, meshx_config_server_restore_params_t, meshx_config_srv_cb_param_t>
106{
107public:
109 /**
110 * @brief Initialize platform-specific config server model
111 * @return MESHX_SUCCESS on successful initialization, error code otherwise
112 */
113 meshx_err_t plat_model_init(void) override;
114
115 /**
116 * @brief Validate config server model status opcode
117 * @param[in] opcode The opcode to validate
118 * @return MESHX_SUCCESS if opcode is valid, error code otherwise
119 */
120 meshx_err_t validate_server_status_opcode(uint16_t opcode) override;
121
122public:
123 /**
124 * @brief Restore server state from persistent storage
125 * @param[in] param Pointer to restoration parameters containing state data
126 * @return MESHX_SUCCESS on successful restoration, error code otherwise
127 */
129
130 /**
131 * @brief Send message through the config server model
132 * @param[in] params Pointer to send parameters structure
133 * @return MESHX_SUCCESS if message sent successfully, error code otherwise
134 */
136
137 /**
138 * @brief Construct a new meshXBaseConfigServerModel object
139 * @param[in] model_id Model identifier for the config server
140 * @param[in] p_plat_model Pointer to the platform model instance
141 * @param[in] from_ble_cb Callback function for handling BLE messages
142 */
144
145 /**
146 * @brief Delete default constructor
147 */
149
150 /**
151 * @brief Virtual destructor for meshXBaseConfigServerModel
152 */
154};
155
156#endif /* CONFIG_ENABLE_CONFIG_SERVER */
157
158#endif /* _MESHX_BASE_MODE_COMMON_H_ */
meshx_err_t validate_server_status_opcode(uint16_t opcode) override
Validate config server model status opcode.
Definition meshx_base_model_common.cpp:47
meshXBaseConfigServerModel(uint32_t model_id, meshx_ptr_t p_plat_model, const control_msg_cb &from_ble_cb)
Construct a new meshXBaseConfigServerModel object.
Definition meshx_base_model_common.cpp:23
~meshXBaseConfigServerModel() final=default
Virtual destructor for meshXBaseConfigServerModel.
meshx_err_t server_state_restore(meshx_config_server_restore_params_t *param) override
Restore server state from persistent storage.
Definition meshx_base_model_common.cpp:104
meshXBaseConfigServerModel()=delete
Delete default constructor.
meshx_err_t plat_send_msg(meshx_config_server_send_params_t *params) override
Send message through the config server model.
Definition meshx_base_model_common.cpp:83
meshx_err_t plat_model_init(void) override
Initialize platform-specific config server model.
Definition meshx_base_model_common.cpp:36
meshx_err_t from_ble_reg_cb(void) const
Definition meshx_base_model_class.cpp:82
uint32_t model_id
Definition meshx_base_model_class.hpp:52
control_task_msg_handle_t from_ble_cb
Definition meshx_base_model_class.hpp:54
This file declares the meshXBaseModel class and its derived Client and Server classes.
std::function< meshx_err_t(dev_struct_t *, control_task_msg_evt_t, meshx_ptr_t)> control_msg_cb
Definition meshx_base_model_class.hpp:32
struct meshx_config_server_restore_params { meshx_model_t *p_model; uint8_t *p_data; size_t data_len; } meshx_config_server_restore_params_t
Definition meshx_base_model_common.hpp:61
struct meshx_config_server_send_params { meshx_model_t *p_model; meshx_ctx_t *p_ctx; uint8_t *p_data; size_t data_len; } meshx_config_server_send_params_t
Definition meshx_base_model_common.hpp:46
#define MESHX_BASE_CONFIG_SERVER_TEMPLATE_PROTO
Definition meshx_base_model_common.hpp:31
struct meshx_model meshx_model_t
struct meshx_ctx meshx_ctx_t
Structure to hold context information for BLE Mesh operations.
void * meshx_ptr_t
Definition meshx_ble_mesh_cmn_def.h:636
struct meshx_config_srv_cb_param meshx_config_srv_cb_param_t
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
Structure containing the parameters for config server model state restoration.
Structure containing the parameters for config server model message sending.