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_def_trans_time.hpp
Go to the documentation of this file.
1/**
2 * @file meshx_model_def_trans_time.hpp
3 * @brief Implementation of Generic Default Transition Time Model for MeshX
4 *
5 * This file contains the implementation of the Generic Default Transition Time model,
6 * which provides standard Default Transition Time model functionality in the MeshX BLE mesh framework.
7 *
8 * Key Features:
9 * - Implements Bluetooth SIG-defined Generic Default Transition Time model
10 * - Inherits from meshXClientModel and meshXServerModel templates
11 * - Provides standard Default Transition Time control operations
12 * - Integrates with MeshX transmission control
13 *
14 * @author Pranjal Chanda
15 * @date 2024-2025
16 * @copyright Copyright 2024 - 2025 MeshX
17 */
18#ifndef _MESHX_MODEL_DEF_TRANS_TIME_HPP_
19#define _MESHX_MODEL_DEF_TRANS_TIME_HPP_
20
21#include <meshx_model_class.hpp>
23
24#define MESHX_GEN_DEF_TRANS_TIME_CLIENT_MODEL_TEMPLATE_PROTO
25#define MESHX_GEN_DEF_TRANS_TIME_CLIENT_MODEL_TEMPLATE_PARAMS
26
27#define MESHX_GEN_DEF_TRANS_TIME_SERVER_MODEL_TEMPLATE_PROTO
28#define MESHX_GEN_DEF_TRANS_TIME_SERVER_MODEL_TEMPLATE_PARAMS
29
30/**
31 * @brief Structure to hold the Default Transition Time model state.
32 */
34{
35 uint8_t trans_time; /**< The Default Transition Time value. */
36};
38
39/**
40 * @brief Structure to hold the parameters for sending a Generic Default Transition Time message.
41 */
43{
44 meshx_model_t *model; /**< Pointer to the Default Transition Time client model. */
45 meshx_ctx_t *ctx; /**< The context of the message. */
46 uint8_t tid; /**< The transaction ID of the message. Only used by Client*/
47 meshx_gen_def_trans_time_model_state_t state; /**< The state of the message. */
48};
49
51
52#if CONFIG_ENABLE_GEN_DEF_TRANS_TIME_CLIENT
53/**
54 * @brief Structure to hold the Default Transition Time Server to parent element message.
55 * The structure is used by the on_model_cb function to send the Default Transition Time state
56 * change notification to the parent element.
57 */
59{
60 meshx_cli_model_send_param_header_t header; /**< Client model send param header */
61 meshx_gen_def_trans_time_model_state_t state; /**< The state of the message. */
62};
63
65/**
66 * @class meshXGenericDefTransTimeClientModel
67 * @brief A template class for creating Generic Default Transition Time Client models.
68 *
69 * This class is derived from meshXClientModel and provides a convenient interface for
70 * creating Generic Default Transition Time Client models. It handles the Generic Default Transition Time state change
71 * notifications from the MeshX stack and publishes the state change event to the
72 * element layer.
73 */
75class meshXGenericDefTransTimeClientModel : public meshXClientModel<meshXBaseGenericClientModel, meshx_gen_def_trans_time_send_params_t>
76{
77private:
78 /* New or updated model state from BLE layer */
80
81 /* Message to be sent to parent element */
83
86
87public:
90 meshx_err_t prepare_element_msg (meshx_ptr_t *msg_ptr, size_t *msg_size) override;
91
94 meshx_ptr_t parent_element_state = nullptr,
95 uint16_t model_func_id = 0
96 );
98};
99
100#endif /* CONFIG_ENABLE_GEN_DEF_TRANS_TIME_CLIENT */
101
102#if CONFIG_ENABLE_GEN_DEF_TRANS_TIME_SERVER
103/**
104 * @brief Structure to hold the Default Transition Time Server to parent element message.
105 * The structure is used by the on_model_cb function to send the Default Transition Time state
106 * change notification to the parent element.
107 */
109{
110 meshx_srv_model_send_param_header_t header; /**< Server model send param header */
111 meshx_gen_def_trans_time_model_state_t state; /**< The state of the message. */
112};
113
115
116/**
117 * @class meshXGenericDefTransTimeServerModel
118 * @brief A template class for creating Generic Default Transition Time Server models.
119 *
120 * This class is derived from meshXServerModel and provides a convenient interface for
121 * creating Generic Default Transition Time Server models. It handles the Generic Default Transition Time state change
122 * notifications from the MeshX stack and publishes the state change event to the
123 * element layer.
124 */
126class meshXGenericDefTransTimeServerModel : public meshXServerModel<meshXBaseGenericServerModel, meshx_gen_def_trans_time_send_params_t>
127{
128private:
129 /* New or updated model state from BLE layer */
131
132 /* Message to be sent to parent element */
134
135 /* Flag to indicate if element message has been prepared */
137
138 meshx_err_t plat_model_create (MESHX_MODEL* p_plat_model_ptr = nullptr) override;
139 meshx_err_t plat_model_delete (void) override;
140
141public:
144 meshx_err_t prepare_element_msg (meshx_ptr_t *msg_ptr, size_t *msg_size) override;
145
146 // Virtual method implementation from meshXModelIF
148
151 meshx_ptr_t parent_element_state = nullptr,
152 uint16_t model_func_id = 0
153 );
155};
156#endif /* CONFIG_ENABLE_GEN_DEF_TRANS_TIME_SERVER */
157
158#endif /* _MESHX_MODEL_DEF_TRANS_TIME_HPP_ */
Interface class for MeshX elements.
Definition meshx_fwd_decl.hpp:82
meshXGenericDefTransTimeClientModel(meshXElementIF *parent_element=nullptr, meshx_ptr_t parent_element_state=nullptr, uint16_t model_func_id=0)
A template class for creating Generic Default Transition Time Client models.
Definition meshx_model_def_trans_time.cpp:223
meshx_gen_def_trans_time_model_state_t model_state
Definition meshx_model_def_trans_time.hpp:79
meshx_err_t prepare_element_msg(meshx_ptr_t *msg_ptr, size_t *msg_size) override
Prepare message for element notification.
Definition meshx_model_def_trans_time.cpp:70
meshx_err_t model_send(meshx_gen_def_trans_time_send_params_t *params) override
Send a packet to the MeshX stack based on the given parameters.
Definition meshx_model_def_trans_time.cpp:167
meshx_def_trans_time_cli_el_msg_t element_msg
Definition meshx_model_def_trans_time.hpp:82
meshx_err_t element_state_change_handle(void) override
Handle state change request from element.
Definition meshx_model_def_trans_time.cpp:97
meshx_err_t model_from_ble_cb(dev_struct_t *, control_task_msg_evt_t, meshx_ptr_t) override
Creates a meshXGenericDefTransTimeClientModel instance based on a BLE device.
Definition meshx_model_def_trans_time.cpp:133
meshx_err_t meshx_state_change_notify(const meshx_gen_cli_cb_param_t *param, uint8_t status)
Handle Generic Default Transition Time state change notifications from the MeshX stack.
Definition meshx_model_def_trans_time.cpp:38
meshx_err_t element_state_change_handle(void) override
Handle state change request from element.
Definition meshx_model_def_trans_time.cpp:354
meshx_err_t prepare_element_msg(meshx_ptr_t *msg_ptr, size_t *msg_size) override
Prepare message for element notification.
Definition meshx_model_def_trans_time.cpp:322
meshXGenericDefTransTimeServerModel(meshXElementIF *parent_element=nullptr, meshx_ptr_t parent_element_state=nullptr, uint16_t model_func_id=0)
Constructor for Generic Default Transition Time Server Model.
Definition meshx_model_def_trans_time.cpp:388
meshx_gen_def_trans_time_model_state_t model_state
Definition meshx_model_def_trans_time.hpp:130
meshx_err_t model_send(meshx_gen_def_trans_time_send_params_t *params) override
Send a packet to the MeshX stack based on the given parameters.
Definition meshx_model_def_trans_time.cpp:247
meshx_err_t plat_model_delete(void) override
Deletes the Generic Default Transition Time Server model and its associated resources.
Definition meshx_model_def_trans_time.cpp:446
meshx_err_t model_from_ble_cb(dev_struct_t *, control_task_msg_evt_t, meshx_ptr_t) override
Callback function for handling BLE mesh events for Generic Default Transition Time Server Model.
Definition meshx_model_def_trans_time.cpp:278
meshx_err_t plat_model_create(MESHX_MODEL *p_plat_model_ptr=nullptr) override
Creates and initializes a server model instance for Generic Default Transition Time Server.
Definition meshx_model_def_trans_time.cpp:411
bool element_msg_prepared
Definition meshx_model_def_trans_time.hpp:136
meshx_def_trans_time_srv_el_msg_t element_msg
Definition meshx_model_def_trans_time.hpp:133
meshXElementIF * parent_element
Definition meshx_model_class.hpp:42
meshXClientModel(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:216
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 Generic Client and Server model declarations.
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_gen_cli_cb_param meshx_gen_cli_cb_param_t
Callback parameters for Generic Client Model events. This structure is used to pass information about...
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
Template declarations for MeshX model wrapper classes.
struct meshx_cli_model_send_param_header meshx_cli_model_send_param_header_t
Definition meshx_model_class.hpp:417
struct meshx_srv_model_send_param_header meshx_srv_model_send_param_header_t
Definition meshx_model_class.hpp:354
struct meshx_def_trans_time_srv_el_msg meshx_def_trans_time_srv_el_msg_t
Definition meshx_model_def_trans_time.hpp:114
struct meshx_def_trans_time_cli_el_msg meshx_def_trans_time_cli_el_msg_t
Definition meshx_model_def_trans_time.hpp:64
#define MESHX_GEN_DEF_TRANS_TIME_CLIENT_MODEL_TEMPLATE_PROTO
Definition meshx_model_def_trans_time.hpp:24
struct meshx_gen_def_trans_time_model_state meshx_gen_def_trans_time_model_state_t
Definition meshx_model_def_trans_time.hpp:37
struct meshx_gen_def_trans_time_send_params meshx_gen_def_trans_time_send_params_t
Definition meshx_model_def_trans_time.hpp:50
#define MESHX_GEN_DEF_TRANS_TIME_SERVER_MODEL_TEMPLATE_PROTO
Definition meshx_model_def_trans_time.hpp:27
Structure to hold the Default Transition Time Server to parent element message. The structure is used...
Definition meshx_model_def_trans_time.hpp:59
meshx_gen_def_trans_time_model_state_t state
Definition meshx_model_def_trans_time.hpp:61
meshx_cli_model_send_param_header_t header
Definition meshx_model_def_trans_time.hpp:60
Structure to hold the Default Transition Time Server to parent element message. The structure is used...
Definition meshx_model_def_trans_time.hpp:109
meshx_gen_def_trans_time_model_state_t state
Definition meshx_model_def_trans_time.hpp:111
meshx_srv_model_send_param_header_t header
Definition meshx_model_def_trans_time.hpp:110
Structure to hold the Default Transition Time model state.
Definition meshx_model_def_trans_time.hpp:34
uint8_t trans_time
Definition meshx_model_def_trans_time.hpp:35
Structure to hold the parameters for sending a Generic Default Transition Time message.
Definition meshx_model_def_trans_time.hpp:43
meshx_ctx_t * ctx
Definition meshx_model_def_trans_time.hpp:45
meshx_gen_def_trans_time_model_state_t state
Definition meshx_model_def_trans_time.hpp:47
meshx_model_t * model
Definition meshx_model_def_trans_time.hpp:44
uint8_t tid
Definition meshx_model_def_trans_time.hpp:46