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_model_config.hpp
Go to the documentation of this file.
1/**
2 * @file meshx_model_config.hpp
3 * @brief MeshX Model Configuration Header File
4 * This file contains configuration settings and macros for MeshX models.
5 * It defines various model-related parameters and options used throughout the MeshX BLE mesh framework.
6 *
7 *
8 * @author Pranjal Chanda
9 * @date 2024-2025
10 * @copyright Copyright 2024 - 2025 MeshX
11 */
12
13#ifndef _MESHX_MODEL_CONFIG_HPP_
14#define _MESHX_MODEL_CONFIG_HPP_
15
16#include <meshx_fwd_decl.hpp>
17#include <meshx_model_class.hpp>
19
20/*********************************************************************************
21 * Model Configuration Macros
22 *********************************************************************************/
23
24#if CONFIG_ENABLE_CONFIG_SERVER
25
26#define MESHX_CONFIG_SERVER_MODEL_TEMPLATE_PROTO
27#define MESHX_CONFIG_SERVER_MODEL_TEMPLATE_PARAMS
28
29/**
30 * @brief Structure to hold the Config model state.
31 */
33{
34 meshx_cfg_srv_state_change_t state_change; /**< State change information. */
35};
37
38/**
39 * @brief Structure to hold the parameters for sending a Generic OnOff message.
40 */
42{
43 meshx_model_t *model; /**< Pointer to the On/Off client model. */
44 meshx_ctx_t *ctx; /**< The context of the message. */
45 uint8_t stub; /**< No Params to send hence placing a stub */
46 meshx_config_model_state_t state; /**< The state of the message. */
47};
48
50
51/**
52 * @brief Structure to hold config server element message parameters.
53 */
55{
56 meshx_srv_model_send_param_header_t header; /**< Server model send param header */
57 meshx_config_model_state_t state; /**< The state of the message. */
58};
59
61
63class meshXConfigModel : public meshXServerModel<meshXBaseConfigServerModel, meshx_config_send_params_t>
64{
65private:
66 /* New or updated model state from BLE layer */
68
69 /* Message to be sent to parent element */
71
72 meshx_err_t plat_model_create (MESHX_MODEL* p_plat_model_ptr = nullptr) override;
73 meshx_err_t plat_model_delete (void) override;
75 {
76 /* Nothing to do here */
77 return MESHX_SUCCESS;
78 };
79
80public:
83 meshx_err_t prepare_element_msg (meshx_ptr_t *msg_ptr, size_t *msg_size) override;
84
85 explicit meshXConfigModel(
87 meshx_ptr_t parent_element_state,
88 uint16_t model_func_id
89 );
90 ~meshXConfigModel() override = default;
91 // Configuration model related members and methods would be defined here.
92};
93
94#endif /* CONFIG_ENABLE_CONFIG_SERVER */
95
96#endif /* _MESHX_MODEL_CONFIG_HPP_ */
meshx_err_t element_state_change_handle(void) override
Handle state change request from element.
Definition meshx_model_config.hpp:74
meshx_config_srv_el_msg_t element_msg
Definition meshx_model_config.hpp:70
meshx_err_t model_from_ble_cb(dev_struct_t *, control_task_msg_evt_t, meshx_ptr_t) override
This function is the callback for the Config Server model.
Definition meshx_model_config.cpp:128
meshx_err_t plat_model_delete(void) override
Deletes the Config Server model and its associated resources.
Definition meshx_model_config.cpp:66
meshx_err_t model_send(meshx_config_send_params_t *params) override
Send a packet to the MeshX stack based on the given parameters.
Definition meshx_model_config.cpp:87
meshx_err_t prepare_element_msg(meshx_ptr_t *msg_ptr, size_t *msg_size) override
Prepare message for element notification.
Definition meshx_model_config.cpp:247
meshXConfigModel(meshXElementIF *parent_element, meshx_ptr_t parent_element_state, uint16_t model_func_id)
Constructor for meshXConfigModel class.
Definition meshx_model_config.cpp:269
~meshXConfigModel() override=default
meshx_err_t plat_model_create(MESHX_MODEL *p_plat_model_ptr=nullptr) override
Creates and initializes a config server model instance.
Definition meshx_model_config.cpp:22
meshx_config_model_state_t model_state
Definition meshx_model_config.hpp:67
Interface class for MeshX elements.
Definition meshx_fwd_decl.hpp:82
meshXElementIF * parent_element
Definition meshx_model_class.hpp:42
uint16_t model_func_id
Definition meshx_model_class.hpp:181
meshXServerModel(MESHX_MODEL *p_plat_model, uint32_t model_id, meshXElementIF *parent_element=nullptr, meshx_ptr_t parent_element_state=nullptr, uint16_t model_func_id=0)
Definition meshx_model_class.cpp:200
Header file for MeshX Config Server base class implementation.
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 dev_struct dev_struct_t
Structure representing the device composition and elements.
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
Forward declaration of MeshX classes.
Template declarations for MeshX model wrapper classes.
struct meshx_srv_model_send_param_header meshx_srv_model_send_param_header_t
Definition meshx_model_class.hpp:354
struct meshx_config_send_params meshx_config_send_params_t
Definition meshx_model_config.hpp:49
struct meshx_config_model_state meshx_config_model_state_t
Definition meshx_model_config.hpp:36
#define MESHX_CONFIG_SERVER_MODEL_TEMPLATE_PROTO
Definition meshx_model_config.hpp:26
struct meshx_config_srv_el_msg meshx_config_srv_el_msg_t
Definition meshx_model_config.hpp:60
**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
Structure to hold the Config model state.
Definition meshx_model_config.hpp:33
meshx_cfg_srv_state_change_t state_change
Definition meshx_model_config.hpp:34
Structure to hold the parameters for sending a Generic OnOff message.
Definition meshx_model_config.hpp:42
meshx_model_t * model
Definition meshx_model_config.hpp:43
uint8_t stub
Definition meshx_model_config.hpp:45
meshx_config_model_state_t state
Definition meshx_model_config.hpp:46
meshx_ctx_t * ctx
Definition meshx_model_config.hpp:44
Structure to hold config server element message parameters.
Definition meshx_model_config.hpp:55
meshx_srv_model_send_param_header_t header
Definition meshx_model_config.hpp:56
meshx_config_model_state_t state
Definition meshx_model_config.hpp:57
Configuration Server model state change value union.
Definition meshx_ble_mesh_config_srv.h:131