|
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.
|
Base class for MeshX elements. More...
#include <meshx_element_class.hpp>
Public Member Functions | |
| void | set_element_type (meshxElementType_t type) |
| meshxElementType_t | get_element_type (void) const final |
| Get the element type. | |
| void | set_element_variant (meshx_element_type_t variant) |
| meshx_element_type_t | get_element_variant (void) const final |
| Get the element variant. | |
| void | set_no_of_sig_models (uint8_t cnt) |
| uint8_t | get_no_of_sig_models (void) const final |
| Get the number of SIG models supported by the element. | |
| void | set_no_of_ven_models (uint8_t cnt) |
| uint8_t | get_no_of_ven_models (void) const final |
| Get the number of Vendor models supported by the element. | |
| std::vector< std::unique_ptr< meshXModelIF > > & | get_sig_models (void) final |
| Get the SIG models vector. | |
| std::vector< std::unique_ptr< meshXModelIF > > & | get_ven_models (void) final |
| Get the Vendor models vector. | |
| const char * | get_element_name (void) const override |
| Get the name of the element. | |
| virtual uint8_t | list_sig_models (void) |
| Lists and creates all required SIG models for the element. | |
| virtual uint8_t | list_ven_models (void) |
| Lists and creates all required Vendor models for the element. | |
| virtual meshx_err_t | element_state_change_notify (meshx_ptr_t param, size_t param_size) |
| Notify element about state change. | |
| void | register_element_ctx (meshx_ptr_t ctx, size_t ctx_size) |
| Register element context structure. | |
| meshx_ptr_t | get_element_ctx (void) const override |
| Get the element context structure. | |
| size_t | get_element_ctx_size (void) const override |
| Get the size of the element context structure. | |
| meshx_err_t | sig_plat_model_array_allocate (void) |
| Allocate memory for SIG model platform array. | |
| meshx_err_t | ven_plat_model_array_allocate (void) |
| Allocate memory for Vendor model platform array. | |
| std::vector< uint8_t > & | get_sig_model_array (void) |
| Get the SIG model array. | |
| std::vector< uint8_t > & | get_ven_model_array (void) |
| Get the Vendor model array. | |
| template<typename meshXModelT, typename... ConstructorsArgs> | |
| meshx_err_t | add_sig_model (ConstructorsArgs &&... args) |
| Add a SIG model to the element. | |
| template<typename meshXModelT, typename... ConstructorsArgs> | |
| meshx_err_t | add_ven_model (ConstructorsArgs &&... args) |
| Add a Vendor model to the element. | |
| uint8_t | get_sig_model_count (void) const |
| Get the number of SIG models currently added to the element. | |
| uint8_t | get_ven_model_count (void) const |
| Get the number of Vendor models currently added to the element. | |
| meshx_err_t | add_sig_models (void) |
| Add multiple SIG models to the element. | |
| meshx_err_t | add_ven_models (void) |
| Add multiple Vendor models to the element. | |
| meshx_err_t | add_models (void) |
| Add both SIG and Vendor models to the element. | |
| MESHX_MODEL * | get_sig_plat_model_array (void) |
| Get the platform model array for SIG models. | |
| MESHX_MODEL * | get_ven_plat_model_array (void) |
| Get the platform model array for Vendor models. | |
| meshXElement (void) | |
| Default constructor for meshXElement. | |
| meshXElement (uint16_t element_idx) | |
| Constructor for meshXElement with element index. | |
| meshXElement (uint16_t element_idx, meshxElementType_t type, uint8_t no_of_sig_models, uint8_t no_of_ven_models) | |
| Constructor for meshXElement with element index, type, and model counts. | |
| meshx_err_t | initialize (void) override |
| Initialize the element. | |
| meshx_err_t | reset (void) override |
| Reset the element. | |
| bool | is_initialized (void) const override |
| Check if the element is initialized. | |
| meshx_err_t | restore_nvs_context (void) override |
| Restore the element's context from NVS. | |
| bool | has_model (uint16_t model_id) const override |
| Check if the element contains a specific model by ID. | |
| void | on_baked (uint16_t index) override |
| Called when the composition is baked to update the element's index. | |
| ~meshXElement () override | |
| Public Member Functions inherited from meshXElementIF | |
| void | set_element_idx (uint16_t idx) |
| uint16_t | get_element_idx (void) const |
| virtual void | sync (control_task_msg_evt_t evt)=0 |
| Synchronize element state (Status broadcast or GET request). | |
| 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.). | |
| meshXElementIF ()=delete | |
| meshXElementIF (uint16_t element_idx) | |
| virtual | ~meshXElementIF ()=default |
Static Public Member Functions | |
| static meshx_err_t | static_prov_srv_cb (const dev_struct_t *pdev, control_task_msg_evt_t evt, const void *params) |
| Global static provisioning callback for Server elements. | |
| static meshx_err_t | static_prov_cli_cb (const dev_struct_t *pdev, control_task_msg_evt_t evt, const void *params) |
| Global static provisioning callback for Client elements. | |
| static meshx_err_t | static_config_cb (const dev_struct_t *pdev, control_task_msg_evt_t evt, const meshx_config_srv_cb_param_t *params) |
| Global static configuration callback. | |
| static void | register_global_callbacks (void) |
| Register the global callbacks with the provisioning server. | |
Private Member Functions | |
| meshx_err_t | on_model_cb (meshx_ptr_t param, size_t param_size) final |
| Handle model callback from child models. | |
Private Attributes | |
| uint8_t | no_of_sig_models |
| uint8_t | no_of_ven_models |
| std::vector< uint8_t > | sig_model_array |
| std::vector< uint8_t > | ven_model_array |
| std::vector< std::unique_ptr< meshXModelIF > > | sig_models |
| std::vector< std::unique_ptr< meshXModelIF > > | ven_models |
| meshxElementType_t | element_type |
| meshx_element_type_t | element_variant |
| meshx_ptr_t | element_ctx |
| size_t | element_ctx_size |
Base class for MeshX elements.
This is a base class for elements.
| meshXElement< meshx_model_send_param_header_t >::meshXElement | ( | void | ) |
Default constructor for meshXElement.
Creates an element with default parameters (index 0, no models)
|
explicit |
Constructor for meshXElement with element index.
| [in] | element_idx | Index of the element in the mesh network |
| meshXElement< meshx_model_send_param_header_t >::meshXElement | ( | uint16_t | element_idx, |
| meshxElementType_t | type, | ||
| uint8_t | no_of_sig_models, | ||
| uint8_t | no_of_ven_models ) |
Constructor for meshXElement with element index, type, and model counts.
Construct meshXElement with explicit element index, type, and model counts.
| [in] | element_idx | Index of the element in the mesh network |
| [in] | type | Type of the element (server or client) |
| [in] | no_of_sig_models | Number of SIG models supported by the element |
| [in] | no_of_ven_models | Number of vendor models supported by the element |
|
override |
| meshx_err_t meshXElement< meshx_model_send_param_header_t >::add_models | ( | void | ) |
Add both SIG and Vendor models to the element.
This function combines the functionality of add_sig_models() and add_ven_models() to add all available models (both SIG and Vendor) to the element in a single call. It validates input parameters, checks capacity constraints for both model types, sets parent element for each model, and transfers ownership.
| meshx_err_t meshXElement< meshx_model_send_param_header_t >::add_sig_model | ( | ConstructorsArgs &&... | args | ) |
Add a SIG model to the element.
| meshXModelT | Type of the model to add |
| ConstructorsArgs | Variadic template parameter pack for constructor arguments |
This function adds a SIG model to the element using perfect forwarding. It validates the model type, checks capacity constraints, and transfers ownership.
| [in] | args | Constructor arguments for the model |
| meshx_err_t meshXElement< meshx_model_send_param_header_t >::add_sig_models | ( | void | ) |
Add multiple SIG models to the element.
This function allows adding multiple SIG models at once to the element. It accepts a vector of unique_ptr to meshXModelIF objects. The function validates input parameters, checks capacity constraints, sets parent element for each model, and transfers ownership.
| meshx_err_t meshXElement< meshx_model_send_param_header_t >::add_ven_model | ( | ConstructorsArgs &&... | args | ) |
Add a Vendor model to the element.
| meshXModelT | Type of the model to add |
| ConstructorsArgs | Variadic template parameter pack for constructor arguments |
This function adds a Vendor model to the element using perfect forwarding. It validates the model type, checks capacity constraints, and transfers ownership.
| [in] | args | Constructor arguments for the model |
| meshx_err_t meshXElement< meshx_model_send_param_header_t >::add_ven_models | ( | void | ) |
Add multiple Vendor models to the element.
This function allows adding multiple Vendor models at once to the element. It accepts a vector of unique_ptr to meshXModelIF objects. The function validates input parameters, checks capacity constraints, sets parent element for each model, and transfers ownership.
|
inlinevirtual |
Notify element about state change.
| [in] | param | Pointer to the state change parameter |
| [in] | param_size | Size of the parameter structure |
Reimplemented in meshXCWWWClientElement, meshXCWWWServerElement, meshXRelayClientElement, meshXRelayServerElement, meshXRGBServerElement, meshXRootElement, and meshXSensorElement.
|
inlineoverridevirtual |
Get the element context structure.
Implements meshXElementIF.
|
inlineoverridevirtual |
Get the size of the element context structure.
Implements meshXElementIF.
|
overridevirtual |
Get the name of the element.
Implements meshXElementIF.
Reimplemented in meshXRelayClientElement, meshXRelayServerElement, meshXRGBServerElement, meshXRootElement, and meshXSensorElement.
|
inlinefinalvirtual |
|
inlinefinalvirtual |
|
inlinefinalvirtual |
Get the number of SIG models supported by the element.
Implements meshXElementIF.
|
inlinefinalvirtual |
Get the number of Vendor models supported by the element.
Implements meshXElementIF.
|
inline |
|
inline |
Get the number of SIG models currently added to the element.
|
inlinefinalvirtual |
| MESHX_MODEL * meshXElement< meshx_model_send_param_header_t >::get_sig_plat_model_array | ( | void | ) |
Get the platform model array for SIG models.
|
inline |
Get the Vendor model array.
|
inline |
Get the number of Vendor models currently added to the element.
|
inlinefinalvirtual |
Get the Vendor models vector.
Implements meshXElementIF.
| MESHX_MODEL * meshXElement< meshx_model_send_param_header_t >::get_ven_plat_model_array | ( | void | ) |
Get the platform model array for Vendor models.
|
overridevirtual |
Check if the element contains a specific model by ID.
| model_id | The model ID to check for |
Implements meshXElementIF.
|
overridevirtual |
Initialize the element.
Implements meshXElementIF.
|
overridevirtual |
Check if the element is initialized.
Implements meshXElementIF.
|
inlinevirtual |
Lists and creates all required SIG models for the element.
This function is responsible for creating and populating the sig_models vector with all essential SIG models that the element must have.
The function can be extended to include additional models based on configuration flags or specific requirements.
Implements meshXElementIF.
Reimplemented in meshXCWWWClientElement, meshXCWWWServerElement, meshXRelayClientElement, meshXRelayServerElement, meshXRGBServerElement, meshXRootElement, and meshXSensorElement.
|
inlinevirtual |
Lists and creates all required Vendor models for the element.
This function is responsible for creating and populating the ven_models vector with all essential Vendor models that the element must have.
The function can be extended to include additional models based on configuration flags or specific requirements.
Implements meshXElementIF.
Reimplemented in meshXCWWWClientElement, meshXCWWWServerElement, meshXRelayClientElement, meshXRelayServerElement, meshXRGBServerElement, meshXRootElement, and meshXSensorElement.
|
inlineoverridevirtual |
Called when the composition is baked to update the element's index.
| index | The final platform index of this element. |
Implements meshXElementIF.
|
finalprivatevirtual |
Handle model callback from child models.
This function is called by child models when a state change occurs. It handles the state change by storing in element context, saving to NVS, and notifying the application.
| [in] | param | Pointer to the model callback parameter |
| [in] | param_size | Size of the parameter structure |
Implements meshXElementIF.
|
inline |
Register element context structure.
This function registers the element context structure used to maintain state information for the element.
| [in] | ctx | Pointer to the element context structure |
| [in] | ctx_size | Size of the context structure |
|
static |
Register the global callbacks with the provisioning server.
|
overridevirtual |
|
overridevirtual |
Restore the element's context from NVS.
Implements meshXElementIF.
|
inline |
|
inline |
|
inline |
|
inline |
| meshx_err_t meshXElement< meshx_model_send_param_header_t >::sig_plat_model_array_allocate | ( | void | ) |
Allocate memory for SIG model platform array.
This function allocates memory for the SIG model platform array based on the number of SIG models supported by the element. It reserves capacity for the specified number of models.
|
static |
Global static configuration callback.
|
static |
Global static provisioning callback for Client elements.
|
static |
Global static provisioning callback for Server elements.
| meshx_err_t meshXElement< meshx_model_send_param_header_t >::ven_plat_model_array_allocate | ( | void | ) |
Allocate memory for Vendor model platform array.
This function allocates memory for the Vendor model platform array based on the number of Vendor models supported by the element. It reserves capacity for the specified number of models.
|
private |
Pointer to element context structure
|
private |
Size of the element context structure
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |