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
meshXGenericDefTransTimeClientModel Class Reference

A template class for creating Generic Default Transition Time Client models. More...

#include <meshx_model_def_trans_time.hpp>

Inheritance diagram for meshXGenericDefTransTimeClientModel:
meshXClientModel< meshXBaseGenericClientModel, meshx_gen_def_trans_time_send_params_t > meshXModel< meshXBaseGenericClientModel, meshx_gen_def_trans_time_send_params_t > meshXModelIF

Public Member Functions

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.
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.
meshx_err_t prepare_element_msg (meshx_ptr_t *msg_ptr, size_t *msg_size) override
 Prepare message for element notification.
 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.
 ~meshXGenericDefTransTimeClientModel ()=default
Public Member Functions inherited from meshXClientModel< meshXBaseGenericClientModel, meshx_gen_def_trans_time_send_params_t >
 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)
 Construct a new meshXClientModel.
Public Member Functions inherited from meshXModel< meshXBaseGenericClientModel, meshx_gen_def_trans_time_send_params_t >
void set_plat_model (MESHX_MODEL *p_model) override
 Set the platform-specific model instance.
meshx_err_t model_handle_from_ble_cb (dev_struct_t *p_dev, evt_model_id_t evt_model_id, meshx_ptr_t params)
 Handle upstream BLE Mesh events.
void on_baked (void) override
 Called when the model's parent element is baked.
virtual ~meshXModel ()
 Destructor for meshXModel.
meshx_err_t send_to_parent_element (meshx_ptr_t msg_ptr, size_t msg_size)
 Send message to parent element.
uint16_t get_model_func_id (void) const
 Get the model function identifier.
void set_model_func_id (uint16_t func_id)
 Set the model function identifier.
uint16_t get_model_id (void) const override
 Get the model identifier.
bool is_initialized (void) const override
 Check if the model is successfully initialized.
void set_model_id (uint16_t id)
 Set the model identifier.
meshx_err_t get_init_status (void) const
 Get the model initialization status.
meshXBaseGenericClientModelget_base_model (void) const
 Get the base model instance.
 meshXModel (MESHX_MODEL *p_plat_model, uint32_t model_id, meshXElementIF *parent_element=nullptr, uint16_t model_func_id=0)
 Constructs a new meshXModel instance.
Public Member Functions inherited from meshXModelIF
 meshXModelIF ()
 meshXModelIF (MESHX_MODEL *p_plat_model)
virtual ~meshXModelIF ()=default
MESHX_MODEL * get_plat_model (void) const
 Get the platform-specific model instance.
meshx_ptr_t get_pub_struct (void) const
 Get the publication structures.
meshx_ptr_t get_gen_struct (void) const
 Get the generic structures.
void set_pub_struct (meshx_ptr_t pub)
 Set the publication structures.
void set_gen_struct (meshx_ptr_t gen)
 Set the generic structures.
void set_parent_element (meshXElementIF *parent)
 Set the parent element for this model.
meshXElementIFget_parent_element (void) const
 Get the parent element of this model.
void set_parent_element_state (meshx_ptr_t state)
 Set the parent element state pointer.
meshx_ptr_t get_parent_element_state (void) const
 Get the parent element state pointer.

Private Member Functions

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.
meshx_err_t element_state_change_handle (void) override
 Handle state change request from element.

Private Attributes

meshx_gen_def_trans_time_model_state_t model_state
meshx_def_trans_time_cli_el_msg_t element_msg

Additional Inherited Members

Protected Member Functions inherited from meshXClientModel< meshXBaseGenericClientModel, meshx_gen_def_trans_time_send_params_t >
void update_element_state_change_header (meshx_err_t element_state_change, meshx_ptr_t msg_ptr) override
 Update element_state_change field in client message header.

Detailed Description

A template class for creating Generic Default Transition Time Client models.

This class is derived from meshXClientModel and provides a convenient interface for creating Generic Default Transition Time Client models. It handles the Generic Default Transition Time state change notifications from the MeshX stack and publishes the state change event to the element layer.

Constructor & Destructor Documentation

◆ meshXGenericDefTransTimeClientModel()

meshXGenericDefTransTimeClientModel::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.

This class is derived from meshXClientModel and provides a convenient interface for creating Generic Default Transition Time Client models. It handles the Generic Default Transition Time state change notifications from the MeshX stack and publishes the state change event to the element layer.

Template Parameters
meshxBaseClientModel_tThe type of the meshXBaseClientModel class to be used.
meshx_send_packet_params_tThe type of the meshXSendPacketParams structure used for sending packets.
Parameters
[in]parent_elementA pointer to the parent element (meshXElementIF).
[in]parent_element_statePointer to the parent element's state structure.
[in]model_func_idFunctional ID for the model instance.
229{
230 /* Used only for initialization of Parent Class */
231}
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
#define MESHX_MODEL_ID_GEN_DEF_TRANS_TIME_CLI
Definition meshx_ble_mesh_cmn_def.h:75

◆ ~meshXGenericDefTransTimeClientModel()

meshXGenericDefTransTimeClientModel::~meshXGenericDefTransTimeClientModel ( )
default

Member Function Documentation

◆ element_state_change_handle()

meshx_err_t meshXGenericDefTransTimeClientModel::element_state_change_handle ( void )
overrideprivatevirtual

Handle state change request from element.

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. Note: The actual state is maintained in the element layer, not the model layer.

Returns
  • MESHX_SUCCESS: State change handled successfully
  • MESHX_INVALID_ARG: Invalid parameter

Implements meshXModelIF.

98{
101 if(!el_state)
102 {
103 MESHX_LOGE(MODULE_ID_MODEL_SERVER, "Invalid parameter in element_state_change_handle");
104 return MESHX_INVALID_ARG;
105 }
106 if(memcmp(&model_state, el_state, sizeof(meshx_gen_def_trans_time_model_state_t)) != 0)
107 {
109 "Def Trans Time state change request: trans_time=%d",
110 el_state->trans_time);
111 model_state = *el_state;
112 }
113 else
114 {
115 return MESHX_INVALID_STATE;
116 }
117 return MESHX_SUCCESS;
118}
meshx_gen_def_trans_time_model_state_t model_state
Definition meshx_model_def_trans_time.hpp:79
meshx_ptr_t get_parent_element_state(void) const
Get the parent element state pointer.
Definition meshx_model_class.hpp:154
@ MESHX_INVALID_ARG
Definition meshx_err.h:46
@ MESHX_INVALID_STATE
Definition meshx_err.h:49
#define MESHX_LOGI(module_id, format,...)
Definition meshx_log.h:126
#define MESHX_LOGE(module_id, format,...)
Definition meshx_log.h:114
struct meshx_gen_def_trans_time_model_state meshx_gen_def_trans_time_model_state_t
Definition meshx_model_def_trans_time.hpp:37
**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
@ MODULE_ID_MODEL_SERVER
Definition module_id.h:34
uint8_t trans_time
Definition meshx_model_def_trans_time.hpp:35

◆ meshx_state_change_notify()

meshx_err_t meshXGenericDefTransTimeClientModel::meshx_state_change_notify ( const meshx_gen_cli_cb_param_t * param,
uint8_t status )
private

Handle Generic Default Transition Time state change notifications from the MeshX stack.

This function is responsible for handling Generic Default Transition Time state change notifications from the MeshX stack. It is called when the MeshX stack receives a state change event from the Generic Default Transition Time server model. The function publishes the state change event to the control task framework, which in turn notifies the application about the state change.

Parameters
[in]paramPointer to the Generic Default Transition Time client callback parameter structure.
[in]statusStatus of the state change event (success or timeout).
Returns
  • MESHX_SUCCESS: Successfully handled the state change notification.
  • MESHX_INVALID_ARG: One or more arguments are invalid.
39{
40 if (!param){
41 return MESHX_INVALID_ARG;
42 }
43
45
46 // Store the message in member variable for later use by prepare_element_msg
47 element_msg = {
48 .header = {
49 .err_code = param->err_code,
50 .model = param->model,
51 .ctx = param->ctx,
52 .element_state_change = MESHX_SUCCESS,
53 },
54 .state = model_state,
55 };
56
57 return MESHX_SUCCESS;
58}
meshx_def_trans_time_cli_el_msg_t element_msg
Definition meshx_model_def_trans_time.hpp:82
uint8_t err_code
Definition meshx_ble_mesh_gen_cli.h:285
meshx_gen_client_status_cb_t status
Definition meshx_ble_mesh_gen_cli.h:289
meshx_model_t model
Definition meshx_ble_mesh_gen_cli.h:287
meshx_ctx_t ctx
Definition meshx_ble_mesh_gen_cli.h:286
uint8_t trans_time
Definition meshx_ble_mesh_gen_cli.h:148
meshx_gen_def_trans_time_status_cb_t def_trans_time_status
Definition meshx_ble_mesh_gen_cli.h:255

◆ model_from_ble_cb()

meshx_err_t meshXGenericDefTransTimeClientModel::model_from_ble_cb ( dev_struct_t * p_dev,
control_task_msg_evt_t model_id,
meshx_ptr_t params )
overridevirtual

Creates a meshXGenericDefTransTimeClientModel instance based on a BLE device.

This function is used to create a meshXGenericDefTransTimeClientModel instance based on a BLE device. It takes the device structure, model ID, and parameters as input and returns a pointer to the created instance.

Parameters
[in]p_devPointer to the device structure
[in]model_idModel ID associated with the device
[in]paramsPointer to the parameters associated with the device
Returns
Pointer to the created meshXGenericDefTransTimeClientModel instance

Implements meshXModel< meshXBaseGenericClientModel, meshx_gen_def_trans_time_send_params_t >.

138{
139 if(!params || !p_dev)
140 {
141 MESHX_LOGE(MODULE_ID_MODEL_CLIENT, "Invalid parameters");
142 return MESHX_INVALID_ARG;
143 }
145 {
146 /* Callback triggered not for this model */
147 return MESHX_SUCCESS;
148 }
149 const auto *param = static_cast<const meshx_gen_cli_cb_param_t *>(params);
150
151 return static_cast<int>(param->evt) == static_cast<int>(meshx_base_cli_evt::MESHX_BASE_CLI_TIMEOUT) ?
154}
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_BASE_CLI_TIMEOUT
Definition meshx_base_model_class.hpp:233
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...
@ MESHX_TIMEOUT
Definition meshx_err.h:52
@ MODULE_ID_MODEL_CLIENT
Definition module_id.h:35

◆ model_send()

meshx_err_t meshXGenericDefTransTimeClientModel::model_send ( meshx_gen_def_trans_time_send_params_t * params)
overridevirtual

Send a packet to the MeshX stack based on the given parameters.

This function takes a pointer to a meshx_gen_def_trans_time_send_params_t structure as input and sends the corresponding packet to the MeshX stack for processing.

Parameters
[in]paramsPointer to the meshx_gen_def_trans_time_send_params_t structure containing the parameters
Returns
MESHX_SUCCESS on success, or an error code on failure

Implements meshXModel< meshXBaseGenericClientModel, meshx_gen_def_trans_time_send_params_t >.

168{
169 meshx_err_t err;
170 meshx_gen_cli_set_t set;
171 if (!params || !params->model || !params->model->p_model)
172 {
173 return MESHX_INVALID_ARG;
174 }
175
177
178 send_params.state = &set;
179 send_params.opcode = static_cast<uint16_t>(params->ctx->opcode);
180 send_params.net_idx = params->ctx->net_idx;
181 send_params.app_idx = params->ctx->app_idx;
182 send_params.addr = params->model->pub_addr;
183 send_params.model = params->model->p_model;
184
186 {
187 err = this->get_base_model()->plat_send_msg(&send_params);
188 }
189
190 else if (params->ctx->opcode == MESHX_MODEL_OP_GEN_DEF_TRANS_TIME_SET ||
192 {
193 set.def_trans_time_set.trans_time = params->trans_time;
194 // Note: Default Transition Time SET operations don't use TID
195
196 err = this->get_base_model()->plat_send_msg(&send_params);
197 }
198 else
199 {
200 err = MESHX_INVALID_ARG; // Invalid opcode
201 MESHX_LOGE(MODULE_ID_MODEL_CLIENT, "Invalid opcode for Generic Default Transition Time Client: %04x", params->ctx->opcode);
202 }
203 return err;
204}
meshx_err_t plat_send_msg(meshx_gen_client_send_params_t *params) override
Send a message using the generic client model.
Definition meshx_base_model_generic.cpp:263
meshXBaseGenericClientModel * get_base_model(void) const
Definition meshx_model_class.hpp:315
#define MESHX_MODEL_OP_GEN_DEF_TRANS_TIME_GET
Definition meshx_ble_mesh_cmn_def.h:257
#define MESHX_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK
Definition meshx_ble_mesh_cmn_def.h:259
#define MESHX_MODEL_OP_GEN_DEF_TRANS_TIME_SET
Definition meshx_ble_mesh_cmn_def.h:258
struct meshx_gen_client_send_params meshx_gen_client_send_params_t
Generic Client Model send parameters.
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
uint16_t app_idx
Definition meshx_ble_mesh_cmn.h:47
uint32_t opcode
Definition meshx_ble_mesh_cmn.h:49
uint16_t net_idx
Definition meshx_ble_mesh_cmn.h:48
uint16_t addr
Definition meshx_ble_mesh_gen_cli.h:299
uint16_t net_idx
Definition meshx_ble_mesh_gen_cli.h:300
meshx_gen_cli_set_t * state
Definition meshx_ble_mesh_gen_cli.h:302
meshx_ptr_t model
Definition meshx_ble_mesh_gen_cli.h:297
uint16_t opcode
Definition meshx_ble_mesh_gen_cli.h:298
uint16_t app_idx
Definition meshx_ble_mesh_gen_cli.h:301
meshx_ctx_t * ctx
Definition meshx_model_def_trans_time.hpp:45
meshx_model_t * model
Definition meshx_model_def_trans_time.hpp:44
uint8_t trans_time
Definition meshx_ble_mesh_gen_cli.h:69
meshx_ptr_t p_model
Definition meshx_ble_mesh_cmn.h:39
uint16_t pub_addr
Definition meshx_ble_mesh_cmn.h:38
meshx_gen_def_trans_time_set_t def_trans_time_set
Definition meshx_ble_mesh_gen_cli.h:121

◆ prepare_element_msg()

meshx_err_t meshXGenericDefTransTimeClientModel::prepare_element_msg ( meshx_ptr_t * msg_ptr,
size_t * msg_size )
overridevirtual

Prepare message for element notification.

Returns pointer to the stored element message

Parameters
[out]msg_ptrPointer to message structure (output parameter)
[out]msg_sizeSize of the message structure (output parameter)
Returns
MESHX_SUCCESS if message prepared successfully, error code otherwise

Implements meshXModelIF.

71{
72 if (!msg_ptr || !msg_size)
73 {
74 return MESHX_INVALID_ARG;
75 }
76
77 *msg_ptr = &element_msg;
78 *msg_size = sizeof(element_msg);
79
80 return MESHX_SUCCESS;
81}

Field Documentation

◆ element_msg

meshx_def_trans_time_cli_el_msg_t meshXGenericDefTransTimeClientModel::element_msg
private

◆ model_state

meshx_gen_def_trans_time_model_state_t meshXGenericDefTransTimeClientModel::model_state
private

The documentation for this class was generated from the following files: