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

Header file for the Relay Client Model in BLE Mesh. More...

#include "meshx_common.h"
#include "meshx_onoff_client.h"
Include dependency graph for meshx_relay_client_element.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_on_off_cli_msg
 Structure to hold the relay client message. More...
 
struct  meshx_relay_client_model_ctx
 Structure to hold the context of the relay client. More...
 
struct  relay_client_element
 Structure to hold the context and configuration for the relay client element. More...
 
struct  relay_client_element_ctrl
 

Macros

#define RELAY_CLI_MODEL_SIG_CNT   RELAY_CLI_SIG_MAX_ID
 Number of SIG models in a relay model element.
 
#define RELAY_CLI_MODEL_VEN_CNT   0
 Number of Vendor models in a relay model element.
 

Typedefs

typedef struct meshx_gen_on_off_cli_msg meshx_gen_on_off_cli_msg_t
 Structure to hold the relay client message.
 
typedef struct meshx_relay_client_model_ctx meshx_relay_client_model_ctx_t
 Structure to hold the context of the relay client.
 
typedef struct relay_client_element relay_client_elements_t
 Structure to hold the context and configuration for the relay client element.
 
typedef struct relay_client_element_ctrl relay_client_element_ctrl_t
 

Enumerations

enum  relay_cli_sig_id_t {
  RELAY_CLI_SIG_ONOFF_MODEL_ID ,
  RELAY_CLI_SIG_MAX_ID
}
 

Functions

meshx_err_t meshx_relay_el_get_state (uint16_t el_id)
 Retrieves the current state of the relay element.
 
meshx_err_t meshx_relay_el_set_state (uint16_t el_id, bool ack)
 Set the On/Off state for a specific element in the BLE mesh network.
 
meshx_err_t create_relay_client_elements (dev_struct_t *pdev, uint16_t element_cnt)
 Create Dynamic Relay Model Elements.
 

Detailed Description

Header file for the Relay Client Model in BLE Mesh.

Copyright © 2024 - 2025 MeshX

This file contains the definitions and function declarations for the Relay Client Model used in BLE Mesh applications. The Relay Client Model is responsible for managing relay client elements, sending messages to relay nodes or groups, and handling the state and context of relay clients.

The file defines constants, data structures, and function prototypes for creating and managing relay client elements. It includes the following key components:

  • Definitions for the number of relay client elements, SIG models, and message types.
  • Data structures for relay client context, messages, and elements.
  • Function prototypes for creating relay client elements and sending messages.
Author
Pranjal Chanda

Definition in file meshx_relay_client_element.h.

Macro Definition Documentation

◆ RELAY_CLI_MODEL_SIG_CNT

#define RELAY_CLI_MODEL_SIG_CNT   RELAY_CLI_SIG_MAX_ID

Number of SIG models in a relay model element.

Definition at line 34 of file meshx_relay_client_element.h.

◆ RELAY_CLI_MODEL_VEN_CNT

#define RELAY_CLI_MODEL_VEN_CNT   0

Number of Vendor models in a relay model element.

Definition at line 39 of file meshx_relay_client_element.h.

Typedef Documentation

◆ meshx_gen_on_off_cli_msg_t

Structure to hold the relay client message.

◆ meshx_relay_client_model_ctx_t

Structure to hold the context of the relay client.

◆ relay_client_element_ctrl_t

◆ relay_client_elements_t

Structure to hold the context and configuration for the relay client element.

Enumeration Type Documentation

◆ relay_cli_sig_id_t

Enumerator
RELAY_CLI_SIG_ONOFF_MODEL_ID 

On/Off model ID

RELAY_CLI_SIG_MAX_ID 

Maximum model ID

Definition at line 41 of file meshx_relay_client_element.h.

Function Documentation

◆ create_relay_client_elements()

meshx_err_t create_relay_client_elements ( dev_struct_t * pdev,
uint16_t element_cnt )

Create Dynamic Relay Model Elements.

Parameters
[in]pdevPointer to device structure
[in]element_cntMaximum number of relay models
Returns
meshx_err_t

Definition at line 635 of file meshx_relay_client.c.

636{
637 meshx_err_t err;
638
639 err = meshx_dev_create_relay_model_space(pdev, element_cnt);
640 if (err)
641 {
642 MESHX_LOGE(MOD_SRC, "Relay Model space create failed: (%d)", err);
643 return err;
644 }
645
646 err = meshx_add_relay_cli_model_to_element_list(pdev, (uint16_t *)&pdev->element_idx, element_cnt);
647 if (err)
648 {
649 MESHX_LOGE(MOD_SRC, "Relay Model add to element create failed: (%d)", err);
650 return err;
651 }
652
653#if CONFIG_ENABLE_CONFIG_SERVER
657 if (err)
658 {
659 MESHX_LOGE(MOD_SRC, "Relay Model config client callback reg failed: (%d)", err);
660 return err;
661 }
662#endif /* CONFIG_ENABLE_CONFIG_SERVER */
664 if (err)
665 {
666 MESHX_LOGE(MOD_SRC, "Relay Client app req callback reg failed: (%d)", err);
667 return err;
668 }
671 if (err)
672 {
673 MESHX_LOGE(MOD_SRC, "Relay Client freshboot callback reg failed: (%d)", err);
674 return err;
675 }
677 if (err)
678 {
679 MESHX_LOGE(MOD_SRC, "Relay Client element state change callback reg failed: (%d)", err);
680 return err;
681 }
682#if CONFIG_ENABLE_UNIT_TEST
684 if (err)
685 {
686 MESHX_LOGE(MOD_SRC, "unit_test reg failed: (%d)", err);
687 return err;
688 }
689#endif /* CONFIG_ENABLE_UNIT_TEST */
690
691 err = meshx_on_off_client_init();
692 if (err)
693 {
694 MESHX_LOGE(MOD_SRC, "meshx_onoff_client_init failed: (%d)", err);
695 return err;
696 }
697
698 return MESHX_SUCCESS;
699}
control_task_msg_handle_t config_srv_cb_t
control_task_msg_handle_t prov_srv_cb_t
meshx_err_t meshx_config_server_cb_reg(config_srv_cb_t cb, uint32_t config_evt_bmap)
Registers a configuration server callback for specific events.
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:39
@ MESHX_SUCCESS
Definition meshx_err.h:40
#define CONFIG_SERVER_CB_MASK
Configuration server callback event mask for cwww server.
#define MESHX_LOGE(module_id, format,...)
Definition meshx_log.h:73
meshx_err_t meshx_prov_srv_reg_el_client_cb(prov_srv_cb_t cb)
Register a callback function for provisioning events.
#define MOD_SRC
static meshx_err_t meshx_add_relay_cli_model_to_element_list(dev_struct_t *pdev, uint16_t *start_idx, uint16_t n_max)
Add relay client models to the element list.
static meshx_err_t relay_cli_unit_test_cb_handler(int cmd_id, int argc, char **argv)
Callback handler for the Relay client unit test command.
static meshx_err_t meshx_relay_cli_reg_app_req_cb()
Registers a callback handler for relay application requests.
static meshx_err_t relay_cli_prov_srv_msg_handle(const dev_struct_t *pdev, control_task_msg_evt_t evt, const void *params)
Relay Client Provisioning Server Control Task Message Handler.
static meshx_err_t relay_client_config_cli_cb(const dev_struct_t *pdev, control_task_msg_evt_t evt, const meshx_config_srv_cb_param_t *params)
Callback function for configuration client events.
static meshx_err_t meshx_relay_cli_el_state_change_reg_cb()
Registers a callback for relay element state change events.
static meshx_err_t meshx_dev_create_relay_model_space(dev_struct_t const *pdev, uint16_t n_max)
Create Dynamic Relay Model Elements.
size_t element_idx
meshx_err_t register_unit_test(module_id_t module_id, module_callback_t callback)
Register a unit test for a specific module.
Definition unit_test.c:149
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_relay_el_get_state()

meshx_err_t meshx_relay_el_get_state ( uint16_t el_id)

Retrieves the current state of the relay element.

This function constructs a generic On/Off client message to request the current state of a relay element identified by the given element ID. It then publishes this message to the control task for BLE communication.

Parameters
[in]el_idThe element ID of the relay whose state is to be retrieved.
Returns
meshx_err_t Returns the result of the message publish operation.

Definition at line 613 of file meshx_relay_client.c.

614{
616 .ack = MESHX_GEN_ON_OFF_CLI_MSG_ACK,
617 .set_get = MESHX_GEN_ON_OFF_CLI_MSG_GET,
618 .element_id = el_id
619 };
623 &msg,
624 sizeof(msg));
625}
@ CONTROL_TASK_MSG_CODE_TO_BLE
CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF
meshx_err_t control_task_msg_publish(control_task_msg_code_t msg_code, control_task_msg_evt_t msg_evt, const void *msg_evt_params, size_t sizeof_msg_evt_params)
Publish a control task message.
struct meshx_gen_on_off_cli_msg meshx_gen_on_off_cli_msg_t
Structure to hold the relay client message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_relay_el_set_state()

meshx_err_t meshx_relay_el_set_state ( uint16_t el_id,
bool ack )

Set the On/Off state for a specific element in the BLE mesh network.

This function sets the On/Off state of the specified element, optionally waiting for an acknowledgment.

Parameters
[in]el_idThe ID of the element for which to set the On/Off state.
[in]ackWhether to wait for an acknowledgment (true) or not (false).
Returns
  • MESHX_SUCCESS: Successfully set the state.
  • MESHX_INVALID_ARG: Invalid element ID or parameters.
  • MESHX_FAIL: Failed to set the state.

Definition at line 589 of file meshx_relay_client.c.

590{
592 .ack = ack == MESHX_GEN_ON_OFF_CLI_MSG_ACK,
593 .set_get = MESHX_GEN_ON_OFF_CLI_MSG_SET,
594 .element_id = el_id
595 };
599 &msg,
600 sizeof(msg));
601}
Here is the call graph for this function:
Here is the caller graph for this function: