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_light_cli.h File Reference

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

Include dependency graph for meshx_gen_light_cli.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_light_client_send_params
 Generic Light 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_light_client_send_params meshx_gen_light_client_send_params_t
 Generic Light 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_light_cli_init (void)
 Initialize the meshxuction generic client.
 
meshx_err_t meshx_gen_light_client_from_ble_reg_cb (uint16_t model_id, meshx_gen_light_client_cb_t cb)
 Registers a callback function for getting Generic Light Client messages from BLE.
 
meshx_err_t meshx_gen_light_send_msg (const meshx_gen_light_client_send_params_t *params)
 Send a message using the generic client model.
 

Detailed Description

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

Copyright (c) 2024 - 2025 MeshX

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

Author
Pranjal Chanda

Definition in file meshx_gen_light_cli.h.

Typedef Documentation

◆ meshx_gen_light_client_send_params_t

Generic Light 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_light_cli_init()

meshx_err_t meshx_gen_light_cli_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

Definition at line 397 of file meshx_gen_light_cli.c.

398{
400 return MESHX_SUCCESS;
402
404 if(err != MESHX_SUCCESS)
405 return err;
406
408}
meshx_err_t meshx_plat_gen_light_client_init(void)
Initialize the Generic Light Client Model. This function sets up the necessary parameters and resourc...
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:39
@ MESHX_SUCCESS
Definition meshx_err.h:40
#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.
static struct @222321174163026111123260040104160030310301145143 g_meshx_gen_light_client_ctrl
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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_gen_light_client_from_ble_reg_cb()

meshx_err_t meshx_gen_light_client_from_ble_reg_cb ( uint16_t model_id,
meshx_gen_light_client_cb_t cb )

Registers a callback function for getting Generic Light Client messages from BLE.

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 472 of file meshx_gen_light_cli.c.

473{
474 if (!cb || meshx_is_gen_light_cli_model(model_id) != MESHX_SUCCESS)
475 {
476 return MESHX_INVALID_ARG;
477 }
478
480 meshx_gen_light_cli_cb_reg_t reg = { .model_id = model_id, .cb = cb };
481
483 if (err != MESHX_SUCCESS)
484 {
485 return err;
486 }
487
490 model_id,
492 );
493}
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.
@ MESHX_INVALID_ARG
Definition meshx_err.h:42
static meshx_err_t meshx_is_gen_light_cli_model(uint32_t model_id)
Checks if the given model ID corresponds to a Generic Light Client model.
struct meshx_gen_light_cli_cb_reg meshx_gen_light_cli_cb_reg_t
static meshx_err_t meshx_gen_light_cli_cb_reg_add(meshx_gen_light_cli_cb_reg_t reg)
Adds a new callback registration to the linked list of registered callbacks.
static meshx_err_t meshx_handle_gen_light_msg(dev_struct_t *pdev, control_task_msg_evt_t model_id, meshx_gen_light_cli_cb_param_t *param)
Handle the Generic Light Client messages.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_gen_light_send_msg()

meshx_err_t meshx_gen_light_send_msg ( const meshx_gen_light_client_send_params_t * params)

Send a message using the generic client model.

This function sends a message using the generic client model, allowing interaction with the BLE mesh network.

Parameters
[in]paramsPointer to the message parameters.
Returns
  • MESHX_SUCCESS: Message sent successfully.
  • Appropriate error code on failure.

Definition at line 423 of file meshx_gen_light_cli.c.

424{
425 if (!params || !params->model || !params->state)
426 {
427 return MESHX_INVALID_ARG;
428 }
429
431 bool is_unack = meshx_is_unack_opcode(params->opcode) == MESHX_SUCCESS;
432 /* Broadcast / Multicast will not be sending an ACK. Hence, it is not required to queue */
433 meshx_txcm_sig_t req_type = (is_unack || (MESHX_ADDR_IS_UNICAST(params->addr) == false)) ?
435
437 {
438 .addr = params->addr,
439 .model = params->model,
440 .opcode = params->opcode,
441 .app_idx = params->app_idx,
442 .net_idx = params->net_idx,
443 };
444 memcpy(&send_msg.state, params->state, sizeof(send_msg.state));
445
447 req_type,
448 send_msg.addr,
449 &send_msg,
450 sizeof(send_msg),
452 );
453 if(err)
454 {
455 MESHX_LOGE(MODULE_ID_MODEL_CLIENT, "Failed to send message: %p", (meshx_ptr_t) err);
456 }
457 return err;
458}
void * meshx_ptr_t
#define MESHX_ADDR_IS_UNICAST(_addr)
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.
static meshx_err_t meshx_is_unack_opcode(uint32_t opcode)
Checks if the given opcode corresponds to an unacknowledged (unack) message in the Generic Light Clie...
struct meshx_gen_light_client_msg_ctx meshx_gen_light_client_msg_ctx_t
#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_light_client_set_state_t state
meshx_light_client_set_state_t * state
Here is the call graph for this function:
Here is the caller graph for this function: