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_fwd_decl.hpp
Go to the documentation of this file.
1/**
2 * @file meshx_fwd_decl.hpp
3 * @brief Forward declaration of MeshX classes
4 * @date 2024-2025
5 * @copyright Copyright 2024 - 2025 MeshX
6 * @author Pranjal Chanda
7 */
8
9#ifndef __MESHX_FWD_DEC_H__
10#define __MESHX_FWD_DEC_H__
11
12/***************************************************************************************************************************************
13 * Includes
14 ***************************************************************************************************************************************/
15#include <vector>
16#include <memory>
17#include <meshx_c_header.h>
18
19/***************************************************************************************************************************************
20 * Template Prototypes
21 ***************************************************************************************************************************************/
22#define MESHX_BASE_TEMPLATE_PROTO template <typename ble_mesh_send_msg_params_t>
23#define MESHX_BASE_TEMPLATE_PARAMS <ble_mesh_send_msg_params_t>
24#define MESHX_BASE_CLIENT_TEMPLATE_PROTO template <typename baseClientModelDerived_t, typename ble_mesh_send_msg_params_t, typename ble_mesh_plat_model_cb_params_t>
25#define MESHX_BASE_CLIENT_TEMPLATE_PARAMS <baseClientModelDerived_t, ble_mesh_send_msg_params_t, ble_mesh_plat_model_cb_params_t>
26#define MESHX_BASE_SERVER_TEMPLATE_PROTO template <typename baseServerModelDerived_t, typename ble_mesh_send_msg_params_t, typename ble_mesh_plat_restore_params_t, typename ble_mesh_plat_cb_params_t>
27#define MESHX_BASE_SERVER_TEMPLATE_PARAMS <baseServerModelDerived_t, ble_mesh_send_msg_params_t, ble_mesh_plat_restore_params_t, ble_mesh_plat_cb_params_t>
28
29#define MESHX_MODEL_TEMPLATE_PROTO template <typename meshxBaseModel_t, typename meshx_send_packet_params_t>
30#define MESHX_MODEL_TEMPLATE_PARAMS <meshxBaseModel_t, meshx_send_packet_params_t>
31#define MESHX_SERVER_MODEL_TEMPLATE_PROTO template <typename meshxBaseServerModel_t, typename meshx_send_packet_params_t>
32#define MESHX_SERVER_MODEL_TEMPLATE_PARAMS <meshxBaseServerModel_t, meshx_send_packet_params_t>
33#define MESHX_CLIENT_MODEL_TEMPLATE_PROTO template <typename meshxBaseClientModel_t, typename meshx_send_packet_params_t>
34#define MESHX_CLIENT_MODEL_TEMPLATE_PARAMS <meshxBaseClientModel_t, meshx_send_packet_params_t>
35
36#define MESHX_ELEMENT_TEMPLATE_PROTO template <typename meshx_model_send_param_header_t>
37#define MESHX_ELEMENT_TEMPLATE_PARAMS <meshx_model_send_param_header_t>
38#define MESHX_SERVER_ELEMENT_TEMPLATE_PROTO
39#define MESHX_SERVER_ELEMENT_TEMPLATE_PARAMS
40#define MESHX_CLIENT_ELEMENT_TEMPLATE_PROTO
41#define MESHX_CLIENT_ELEMENT_TEMPLATE_PARAMS
42
43/***************************************************************************************************************************************
44 * Forward declaration of Classes
45 ***************************************************************************************************************************************/
46
50
51class meshXModelIF;
55
56/*********************************************************************************
57 * meshXElementIF
58 *********************************************************************************/
64
65/**
66 * @class meshXElementIF
67 * @brief Interface class for MeshX elements
68 * @details This is an interface class defining the base functionality for mesh elements.
69 */
70
72
73/**
74 * @brief Common element context structure for base handling.
75 */
76typedef struct {
77 uint16_t app_id;
78 uint16_t pub_addr;
80
82{
83private:
84 uint16_t element_idx;
85public:
86 /**
87 * @brief Handle model callback from child models.
88 *
89 * This is a pure virtual function that must be implemented by derived classes.
90 * It is called when a model event occurs, allowing the element to handle the event.
91 *
92 * @param[in] param Pointer to the model event parameters.
93 * @param[in] param_size Size of the parameter structure.
94 * @return MESHX_SUCCESS on success, error code otherwise.
95 */
96 virtual meshx_err_t on_model_cb(meshx_ptr_t param, size_t param_size) = 0;
97
98 void set_element_idx(uint16_t idx) { element_idx = idx; }
99 uint16_t get_element_idx(void) const { return element_idx; }
100
101 /**
102 * @brief Called when the composition is baked to update the element's index.
103 * @param index The final platform index of this element.
104 */
105 virtual void on_baked(uint16_t index) = 0;
106
107 /**
108 * @brief Get the element type
109 * @return Element type (server or client)
110 */
111 virtual meshxElementType_t get_element_type(void) const = 0;
112
113 /**
114 * @brief Get the element variant
115 * @return Element variant (meshx_element_type_t)
116 */
117 virtual meshx_element_type_t get_element_variant(void) const = 0;
118
119 /**
120 * @brief Get the number of SIG models supported by the element
121 * @return Number of SIG models
122 */
123 virtual uint8_t get_no_of_sig_models(void) const = 0;
124
125 /**
126 * @brief Get the number of Vendor models supported by the element
127 * @return Number of Vendor models
128 */
129 virtual uint8_t get_no_of_ven_models(void) const = 0;
130
131 /**
132 * @brief Lists and creates all required SIG models for the element.
133 */
134 virtual uint8_t list_sig_models(void) = 0;
135
136 /**
137 * @brief Lists and creates all required Vendor models for the element.
138 */
139 virtual uint8_t list_ven_models(void) = 0;
140
141 /**
142 * @brief Get the SIG models vector
143 * @return Reference to the SIG models vector
144 */
145 virtual std::vector<std::unique_ptr<meshXModelIF>>& get_sig_models(void) = 0;
146
147 /**
148 * @brief Get the Vendor models vector
149 * @return Reference to the Vendor models vector
150 */
151 virtual std::vector<std::unique_ptr<meshXModelIF>>& get_ven_models(void) = 0;
152
153 /**
154 * @brief Initialize the element
155 * @return MESHX_SUCCESS on success, error code otherwise
156 */
157 virtual meshx_err_t initialize(void) = 0;
158
159 /**
160 * @brief Reset the element
161 * @return MESHX_SUCCESS on success, error code otherwise
162 */
163 virtual meshx_err_t reset(void) = 0;
164
165 /**
166 * @brief Check if the element is initialized
167 * @return true if initialized, false otherwise
168 */
169 virtual bool is_initialized(void) const = 0;
170
171 /**
172 * @brief Restore the element's context from NVS.
173 * @return MESHX_SUCCESS on success, error code otherwise.
174 */
176
177 /**
178 * @brief Check if the element contains a specific model by ID
179 * @param model_id The model ID to check for
180 * @return true if the model exists in this element, false otherwise
181 */
182 virtual bool has_model(uint16_t model_id) const = 0;
183
184 /**
185 * @brief Get the element context structure
186 * @return Pointer to the element context structure
187 */
188 virtual meshx_ptr_t get_element_ctx(void) const = 0;
189
190 /**
191 * @brief Get the size of the element context structure
192 * @return Size of the element context structure
193 */
194 virtual size_t get_element_ctx_size(void) const = 0;
195
196 /**
197 * @brief Synchronize element state (Status broadcast or GET request)
198 * @param evt The event trigger (STACK_READY or FRESH_BOOT)
199 */
200 virtual void sync(control_task_msg_evt_t evt) = 0;
201
202 /**
203 * @brief Get the name of the element.
204 * @return String literal representing the element name.
205 */
206 virtual const char* get_element_name(void) const = 0;
207
208 /**
209 * @brief Handle configuration server events (AppKey bind, Publication, etc.)
210 * @param evt The configuration event code
211 * @param params Pointer to the configuration parameters
212 */
214
215
216 meshXElementIF() = delete;
218 virtual ~meshXElementIF() = default;
219};
220
224
225#endif/* __MESHX_FWD_DEC_H__ */
Definition meshx_base_model_class.hpp:244
Base class for all mesh models.
Definition meshx_base_model_class.hpp:50
Definition meshx_base_model_class.hpp:189
Base class for all client models in the mesh network.
Definition meshx_model_class.hpp:429
Derived class for client elements.
Definition meshx_element_class.hpp:349
virtual meshx_ptr_t get_element_ctx(void) const =0
Get the element context structure.
virtual std::vector< std::unique_ptr< meshXModelIF > > & get_ven_models(void)=0
Get the Vendor models vector.
virtual ~meshXElementIF()=default
virtual uint8_t get_no_of_sig_models(void) const =0
Get the number of SIG models supported by the element.
virtual const char * get_element_name(void) const =0
Get the name of the element.
virtual size_t get_element_ctx_size(void) const =0
Get the size of the element context structure.
virtual void sync(control_task_msg_evt_t evt)=0
Synchronize element state (Status broadcast or GET request).
virtual meshx_err_t restore_nvs_context(void)=0
Restore the element's context from NVS.
virtual meshx_err_t reset(void)=0
Reset the element.
meshXElementIF()=delete
virtual void on_baked(uint16_t index)=0
Called when the composition is baked to update the element's index.
virtual bool is_initialized(void) const =0
Check if the element is initialized.
void set_element_idx(uint16_t idx)
Definition meshx_fwd_decl.hpp:98
virtual meshx_err_t initialize(void)=0
Initialize the element.
uint16_t get_element_idx(void) const
Definition meshx_fwd_decl.hpp:99
virtual bool has_model(uint16_t model_id) const =0
Check if the element contains a specific model by ID.
virtual void handle_config(control_task_msg_evt_t evt, const meshx_config_srv_cb_param_t *params)=0
Handle configuration server events (AppKey bind, Publication, etc.).
virtual uint8_t get_no_of_ven_models(void) const =0
Get the number of Vendor models supported by the element.
virtual uint8_t list_sig_models(void)=0
Lists and creates all required SIG models for the element.
virtual std::vector< std::unique_ptr< meshXModelIF > > & get_sig_models(void)=0
Get the SIG models vector.
virtual uint8_t list_ven_models(void)=0
Lists and creates all required Vendor models for the element.
meshXElementIF(uint16_t element_idx)
Definition meshx_fwd_decl.hpp:217
uint16_t element_idx
Definition meshx_fwd_decl.hpp:84
virtual meshx_element_type_t get_element_variant(void) const =0
Get the element variant.
virtual meshx_err_t on_model_cb(meshx_ptr_t param, size_t param_size)=0
Handle model callback from child models.
virtual meshxElementType_t get_element_type(void) const =0
Get the element type.
Derived class for server elements.
Definition meshx_element_class.hpp:336
Base class for MeshX elements.
Definition meshx_element_class.hpp:34
Definition meshx_model_class.hpp:32
meshXModel class
Definition meshx_model_class.hpp:175
Base class for all server models in MeshX.
Definition meshx_model_class.hpp:366
void * meshx_ptr_t
Definition meshx_ble_mesh_cmn_def.h:636
struct meshx_config_srv_cb_param meshx_config_srv_cb_param_t
This file includes all required header file encapslated under C env.
uint32_t control_task_msg_evt_t
Type definition for control task message event.
Definition meshx_control_task.h:81
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
#define MESHX_SERVER_ELEMENT_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:38
#define MESHX_ELEMENT_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:36
#define MESHX_BASE_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:22
#define MESHX_BASE_CLIENT_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:24
#define MESHX_SERVER_MODEL_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:31
meshxElementType
Definition meshx_fwd_decl.hpp:60
@ MESHX_ELEMENT_TYPE_CLIENT
Definition meshx_fwd_decl.hpp:62
@ MESHX_ELEMENT_TYPE_SERVER
Definition meshx_fwd_decl.hpp:61
#define MESHX_MODEL_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:29
#define MESHX_CLIENT_ELEMENT_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:40
#define MESHX_BASE_SERVER_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:26
#define MESHX_CLIENT_MODEL_TEMPLATE_PROTO
Definition meshx_fwd_decl.hpp:33
enum meshxElementType meshxElementType_t
Definition meshx_fwd_decl.hpp:71
Common element context structure for base handling.
Definition meshx_fwd_decl.hpp:76
uint16_t pub_addr
Definition meshx_fwd_decl.hpp:78
uint16_t app_id
Definition meshx_fwd_decl.hpp:77