MeshX 0.3
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_gen_client.h File Reference

Implementation of the MeshX generic client model for BLE mesh nodes. This file contains functions for registering, deregistering, and initializing the generic client model. More...

Include dependency graph for meshx_gen_client.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  meshx_gen_client_send_params
 Generic Client Model send parameters. This structure is used to pass parameters to the Generic Client Model for sending messages. It includes the element ID, model pointer, state parameters, opcode, destination address, network index, and application index. More...
 

Typedefs

typedef struct meshx_gen_client_send_params meshx_gen_client_send_params_t
 Generic Client Model send parameters. This structure is used to pass parameters to the Generic Client Model for sending messages. It includes the element ID, model pointer, state parameters, opcode, destination address, network index, and application index.
 

Functions

meshx_err_t meshx_gen_client_from_ble_reg_cb (uint32_t model_id, meshx_gen_client_cb_t cb)
 Registers a callback function for a specific generic server model.
 
meshx_err_t meshx_gen_client_init (void)
 Initialize the meshxuction generic client.
 
meshx_err_t meshx_gen_cli_send_msg (meshx_gen_client_send_params_t *params)
 Sends a Generic Client message over BLE Mesh.
 

Detailed Description

Implementation of the MeshX generic client model for BLE mesh nodes. This file contains functions for registering, deregistering, and initializing the generic client model.

Copyright (c) 2024 - 2025 MeshX

The MeshX generic client model provides an interface for handling BLE mesh client operations, including callback registration and initialization.

Author
Pranjal Chanda

Definition in file meshx_gen_client.h.

Typedef Documentation

◆ meshx_gen_client_send_params_t

Generic Client Model send parameters. This structure is used to pass parameters to the Generic Client Model for sending messages. It includes the element ID, model pointer, state parameters, opcode, destination address, network index, and application index.

Function Documentation

◆ meshx_gen_cli_send_msg()

meshx_err_t meshx_gen_cli_send_msg ( meshx_gen_client_send_params_t * params)

Sends a Generic Client message over BLE Mesh.

This function sends a message from a Generic Client model to a specified address within the BLE Mesh network, using the provided opcode and parameters.

Parameters
[in]paramsPointer to the structure containing the message parameters to set.
Returns
meshx_err_t Result of the operation. Returns MESHX_OK on success or an error code on failure.

Definition at line 426 of file meshx_gen_client.c.

427{
428 if (!params || !params->model || !params->state)
429 {
430 return MESHX_INVALID_ARG;
431 }
432
434 bool is_unack = meshx_is_unack_opcode(params->opcode) == MESHX_SUCCESS;
435 /* Broadcast / Multicast will not be sending an ACK. Hence, it is not required to queue */
436 meshx_txcm_sig_t req_type = (is_unack || (MESHX_ADDR_IS_UNICAST(params->addr) == false)) ?
438
440 {
441 .addr = params->addr,
442 .model = params->model,
443 .opcode = params->opcode,
444 .app_idx = params->app_idx,
445 .net_idx = params->net_idx,
446 };
447 memcpy(&send_msg.state, params->state, sizeof(send_msg.state));
448
450 req_type,
451 send_msg.addr,
452 &send_msg,
453 sizeof(send_msg),
455 );
456 if(err)
457 {
458 MESHX_LOGE(MODULE_ID_MODEL_CLIENT, "Failed to send message: %p", (meshx_ptr_t) err);
459 }
460 return err;
461}
void * meshx_ptr_t
#define MESHX_ADDR_IS_UNICAST(_addr)
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:39
@ MESHX_SUCCESS
Definition meshx_err.h:40
@ MESHX_INVALID_ARG
Definition meshx_err.h:42
struct meshx_gen_client_msg_ctx meshx_gen_client_msg_ctx_t
static meshx_err_t meshx_is_unack_opcode(uint32_t opcode)
Checks if the given opcode corresponds to an unacknowledged (unack) message.
static meshx_err_t meshx_gen_client_txcm_fn_model_send(meshx_gen_client_msg_ctx_t *msg_param, size_t msg_param_len)
Transmit callback handler for sending Generic Client model messages.
#define MESHX_LOGE(module_id, format,...)
Definition meshx_log.h:73
meshx_err_t meshx_txcm_request_send(meshx_txcm_sig_t request_type, uint16_t dest_addr, meshx_cptr_t msg_param, uint16_t msg_param_len, meshx_txcm_fn_model_send_t send_fn)
Sends a request to the Tx Control module.
meshx_txcm_sig_t
Enumeration of signal types for the Tx Control Module.
Definition meshx_txcm.h:57
@ MESHX_TXCM_SIG_ENQ_SEND
Definition meshx_txcm.h:58
@ MESHX_TXCM_SIG_DIRECT_SEND
Definition meshx_txcm.h:59
meshx_err_t(* meshx_txcm_fn_model_send_t)(meshx_cptr_t msg_param, size_t msg_param_len)
Function pointer the Model client layer needs to provide for the msg to be sent for both MESHX_TXCM_S...
Definition meshx_txcm.h:94
@ MODULE_ID_MODEL_CLIENT
Definition module_id.h:31
meshx_gen_cli_set_t state
meshx_gen_cli_set_t * state
Here is the call graph for this function:

◆ meshx_gen_client_from_ble_reg_cb()

meshx_err_t meshx_gen_client_from_ble_reg_cb ( uint32_t model_id,
meshx_gen_client_cb_t cb )

Registers a callback function for a specific generic server model.

This function associates a callback with the given model ID, allowing the server to handle events or messages related to that model.

Parameters
[in]model_idThe unique identifier of the generic server model.
[in]cbThe callback function to be registered for the model.
Returns
meshx_err_t Returns an error code indicating the result of the registration. Possible values include success or specific error codes.

Definition at line 475 of file meshx_gen_client.c.

476{
477 if (!cb || meshx_is_gen_cli_model(model_id) != MESHX_SUCCESS)
478 {
479 return MESHX_INVALID_ARG;
480 }
481
483 meshx_gen_cli_cb_reg_t reg = { .model_id = (uint16_t)model_id, .cb = cb };
484
485 err = meshx_gen_cli_cb_reg_add(reg);
486 if (err != MESHX_SUCCESS)
487 {
488 return err;
489 }
490
493 model_id,
495 );
496}
meshx_err_t(* control_task_msg_handle_t)(dev_struct_t *pdev, control_task_msg_evt_t evt, void *params)
Function pointer type for control task message handler.
@ CONTROL_TASK_MSG_CODE_FRM_BLE
meshx_err_t control_task_msg_subscribe(control_task_msg_code_t msg_code, control_task_msg_evt_t evt_bmap, control_task_msg_handle_t callback)
Subscribe to a control task message.
struct meshx_gen_cli_cb_reg meshx_gen_cli_cb_reg_t
static meshx_err_t meshx_is_gen_cli_model(uint32_t model_id)
Checks if the given model ID corresponds to a Generic Client model.
static meshx_err_t meshx_handle_gen_onoff_msg(dev_struct_t *pdev, control_task_msg_evt_t model_id, meshx_gen_cli_cb_param_t *param)
Handle the Generic OnOff Client messages.
static meshx_err_t meshx_gen_cli_cb_reg_add(meshx_gen_cli_cb_reg_t reg)
Adds a new callback registration to the linked list of registered callbacks.
Here is the call graph for this function:

◆ meshx_gen_client_init()

meshx_err_t meshx_gen_client_init ( void )

Initialize the meshxuction generic client.

This function sets up the necessary configurations and initializes the meshxuction generic client for the BLE mesh node.

Returns
  • MESHX_SUCCESS: Success
  • MESHX_FAIL: Failed to initialize the client

Initialize the meshxuction generic client.

This function sets up the necessary configurations and initializes the meshxuction generic client for the BLE mesh node.

Returns
  • MESHX_SUCCESS: Success
  • MESHX_FAIL: Failed to initialize the client

Definition at line 404 of file meshx_gen_client.c.

405{
407 return MESHX_SUCCESS;
409
411 if(err != MESHX_SUCCESS)
412 return err;
414}
meshx_err_t meshx_plat_gen_cli_init(void)
Initialize the meshxuction generic client.
#define MESHX_CLIENT_INIT_MAGIC_NO
static meshx_err_t meshx_handle_txcm_msg(dev_struct_t *pdev, control_task_msg_evt_t evt, meshx_gen_cli_resend_ctx *param)
Handles a control task message for a generic client model.
control_task_msg_handle_t meshx_txcm_cb_t
Definition meshx_txcm.h:49
meshx_err_t meshx_txcm_event_cb_reg(meshx_txcm_cb_t event_cb)
Registers a callback function for handling Tx Control module events.
Structure containing control variables for the generic client model.
Here is the call graph for this function: