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

Implementation of the CW-WW (Cool White - Warm White) client model for BLE Mesh. More...

Include dependency graph for meshx_light_cwww_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  cwww_cli_ctx
 Structure to hold the context of the cwww client. More...
 
struct  cwww_client_msg
 Structure to hold the cwww client message sent from APP layer. More...
 
struct  cwww_client_element
 Structure to hold the cwww client element. More...
 
struct  cwww_client_element_ctrl
 Structure to hold the cwww client elements. More...
 

Macros

#define CWWW_CLI_MODEL_SIG_CNT   CWWW_CLI_SIG_ID_MAX
 Number of SIG models in a CW-WW model element.
 
#define CWWW_CLI_MODEL_VEN_CNT   0
 Number of Vendor models in a CW-WW model element.
 
#define CWWW_CLI_MSG_SET   0
 Message type for setting CW-WW client state.
 
#define CWWW_CLI_MSG_GET   1
 Message type for getting CW-WW client state.
 
#define CWWW_CLI_MSG_ACK   1
 Acknowledgment message type.
 
#define CWWW_CLI_MSG_NO_ACK   0
 Non-acknowledgment message type.
 
#define CWWW_ARG_BMAP_ONOFF_SET   MESHX_BIT(0)
 
#define CWWW_ARG_BMAP_LIGHTNESS_SET   MESHX_BIT(1)
 
#define CWWW_ARG_BMAP_TEMPERATURE_SET   MESHX_BIT(2)
 
#define CWWW_ARG_BMAP_DELTA_UV_SET   MESHX_BIT(3)
 
#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MIN   MESHX_BIT(4)
 
#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MAX   MESHX_BIT(5)
 
#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET   (CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MIN | CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MAX)
 Argument bitmap for setting the temperature range.
 
#define CWWW_ARG_BMAP_CTL_SET   (CWWW_ARG_BMAP_LIGHTNESS_SET | CWWW_ARG_BMAP_TEMPERATURE_SET | CWWW_ARG_BMAP_DELTA_UV_SET)
 Argument bitmap for setting the CW-WW client control state.
 
#define CWWW_ARG_BMAP_ALL   (CWWW_ARG_BMAP_ONOFF_SET | CWWW_ARG_BMAP_CTL_SET | CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET)
 Argument bitmap for setting all CW-WW client states.
 

Typedefs

typedef struct cwww_cli_ctx meshx_cwww_client_model_ctx_t
 Structure to hold the context of the cwww client.
 
typedef struct cwww_client_msg meshx_cwww_client_msg_t
 Structure to hold the cwww client message sent from APP layer.
 
typedef struct cwww_client_element meshx_cwww_client_elements_t
 Structure to hold the cwww client element.
 
typedef struct cwww_client_element_ctrl meshx_cwww_client_elements_ctrl_t
 Structure to hold the cwww client elements.
 

Enumerations

enum  cwww_cli_sig_id_t {
  CWWW_CLI_SIG_ONOFF_MODEL_ID ,
  CWWW_CLI_SIG_L_CTL_MODEL_ID ,
  CWWW_CLI_SIG_ID_MAX
}
 Enumeration of CW-WW SIG model IDs. More...
 

Functions

meshx_err_t meshx_cwww_el_get_state (uint16_t element_id, cwww_cli_sig_id_t model_id)
 Retrieves the current state of the CW/WW (Cool White/Warm White) light element for the specified element ID.
 
meshx_err_t create_cwww_client_elements (dev_struct_t *pdev, uint16_t element_cnt)
 Create Dynamic CW-WW Model Elements.
 

Detailed Description

Implementation of the CW-WW (Cool White - Warm White) client model for BLE Mesh.

Copyright © 2024 - 2025 MeshX

Author
Pranjal Chanda

Definition in file meshx_light_cwww_client_element.h.

Macro Definition Documentation

◆ CWWW_ARG_BMAP_ALL

Argument bitmap for setting all CW-WW client states.

Definition at line 78 of file meshx_light_cwww_client_element.h.

◆ CWWW_ARG_BMAP_CTL_SET

Argument bitmap for setting the CW-WW client control state.

Definition at line 72 of file meshx_light_cwww_client_element.h.

◆ CWWW_ARG_BMAP_DELTA_UV_SET

#define CWWW_ARG_BMAP_DELTA_UV_SET   MESHX_BIT(3)

Definition at line 58 of file meshx_light_cwww_client_element.h.

◆ CWWW_ARG_BMAP_LIGHTNESS_SET

#define CWWW_ARG_BMAP_LIGHTNESS_SET   MESHX_BIT(1)

Definition at line 56 of file meshx_light_cwww_client_element.h.

◆ CWWW_ARG_BMAP_ONOFF_SET

#define CWWW_ARG_BMAP_ONOFF_SET   MESHX_BIT(0)

Definition at line 55 of file meshx_light_cwww_client_element.h.

◆ CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET

#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET   (CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MIN | CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MAX)

Argument bitmap for setting the temperature range.

Definition at line 66 of file meshx_light_cwww_client_element.h.

◆ CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MAX

#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MAX   MESHX_BIT(5)

Definition at line 60 of file meshx_light_cwww_client_element.h.

◆ CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MIN

#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MIN   MESHX_BIT(4)

Definition at line 59 of file meshx_light_cwww_client_element.h.

◆ CWWW_ARG_BMAP_TEMPERATURE_SET

#define CWWW_ARG_BMAP_TEMPERATURE_SET   MESHX_BIT(2)

Definition at line 57 of file meshx_light_cwww_client_element.h.

◆ CWWW_CLI_MODEL_SIG_CNT

#define CWWW_CLI_MODEL_SIG_CNT   CWWW_CLI_SIG_ID_MAX

Number of SIG models in a CW-WW model element.

Definition at line 23 of file meshx_light_cwww_client_element.h.

◆ CWWW_CLI_MODEL_VEN_CNT

#define CWWW_CLI_MODEL_VEN_CNT   0

Number of Vendor models in a CW-WW model element.

Definition at line 29 of file meshx_light_cwww_client_element.h.

◆ CWWW_CLI_MSG_ACK

#define CWWW_CLI_MSG_ACK   1

Acknowledgment message type.

Definition at line 47 of file meshx_light_cwww_client_element.h.

◆ CWWW_CLI_MSG_GET

#define CWWW_CLI_MSG_GET   1

Message type for getting CW-WW client state.

Definition at line 41 of file meshx_light_cwww_client_element.h.

◆ CWWW_CLI_MSG_NO_ACK

#define CWWW_CLI_MSG_NO_ACK   0

Non-acknowledgment message type.

Definition at line 53 of file meshx_light_cwww_client_element.h.

◆ CWWW_CLI_MSG_SET

#define CWWW_CLI_MSG_SET   0

Message type for setting CW-WW client state.

Definition at line 35 of file meshx_light_cwww_client_element.h.

Typedef Documentation

◆ meshx_cwww_client_elements_ctrl_t

Structure to hold the cwww client elements.

◆ meshx_cwww_client_elements_t

Structure to hold the cwww client element.

◆ meshx_cwww_client_model_ctx_t

Structure to hold the context of the cwww client.

◆ meshx_cwww_client_msg_t

Structure to hold the cwww client message sent from APP layer.

Enumeration Type Documentation

◆ cwww_cli_sig_id_t

Enumeration of CW-WW SIG model IDs.

Enumerator
CWWW_CLI_SIG_ONOFF_MODEL_ID 

On/Off model ID

CWWW_CLI_SIG_L_CTL_MODEL_ID 

Light CTL model ID

CWWW_CLI_SIG_ID_MAX 

Maximum number of model IDs

Definition at line 83 of file meshx_light_cwww_client_element.h.

Function Documentation

◆ create_cwww_client_elements()

meshx_err_t create_cwww_client_elements ( dev_struct_t * pdev,
uint16_t element_cnt )

Create Dynamic CW-WW Model Elements.

Parameters
[in]pdevPointer to device structure
[in]element_cntMaximum number of CW-WW models
Returns
meshx_err_t

Definition at line 998 of file meshx_light_cwww_client.c.

999{
1000 meshx_err_t err;
1001
1002 err = meshx_dev_create_cwww_model_space(pdev, element_cnt);
1003 if (err)
1004 {
1005 MESHX_LOGE(MOD_LCC, "CWWW Model space create failed: (%d)", err);
1006 return err;
1007 }
1008
1009 err = meshx_add_cwww_cli_model_to_element_list(pdev, (uint16_t *)&pdev->element_idx, element_cnt);
1010 if (err)
1011 {
1012 MESHX_LOGE(MOD_LCC, "CWWW Model add to element create failed: (%d)", err);
1013 return err;
1014 }
1015
1016 err = meshx_on_off_client_init();
1017 if (err)
1018 {
1019 MESHX_LOGE(MOD_LCC, "meshx_onoff_client_init failed: (%d)", err);
1020 return err;
1021 }
1022
1024 if (err)
1025 {
1026 MESHX_LOGE(MOD_LCC, "meshx_light_ctl_client_init failed: (%d)", err);
1027 return err;
1028 }
1029
1030#if CONFIG_ENABLE_CONFIG_SERVER
1032 (config_srv_cb_t) &cwww_client_config_srv_cb,
1034 if (err)
1035 {
1036 MESHX_LOGE(MOD_LCC, "Light CWWW config server callback reg failed: (%d)", err);
1037 return err;
1038 }
1039#endif /* CONFIG_ENABLE_CONFIG_SERVER */
1040
1041#if defined(__MESHX_CONTROL_TASK__)
1042 /* Register control task callback */
1044 if (err)
1045 {
1046 MESHX_LOGE(MOD_LCC, "control task callback reg failed: (%d)", err);
1047 return err;
1048 }
1049 /* Register element state change callback */
1051 if (err)
1052 {
1053 MESHX_LOGE(MOD_LCC, "element state change callback reg failed: (%d)", err);
1054 return err;
1055 }
1056 /* Register freshboot control task callback */
1058 (prov_srv_cb_t)&cwww_cli_prov_srv_msg_handle);
1059 if (err)
1060 {
1061 MESHX_LOGE(MOD_LCC, "control task callback reg failed: (%d)", err);
1062 return err;
1063 }
1064
1065#endif /* __MESHX_CONTROL_TASK__ */
1066#if CONFIG_ENABLE_UNIT_TEST
1067 err = register_unit_test(MODULE_ID_ELEMENT_LIGHT_CWWWW_CLIENT, &cwww_cli_unit_test_cb_handler);
1068 if (err)
1069 {
1070 MESHX_LOGE(MOD_LCC, "unit_test reg failed: (%d)", err);
1071 return err;
1072 }
1073#endif /* CONFIG_ENABLE_UNIT_TEST */
1074
1075 return MESHX_SUCCESS;
1076}
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
meshx_err_t meshx_light_ctl_client_init()
Initialize the Light CTL Client model.
#define CONFIG_SERVER_CB_MASK
Configuration server callback event mask for cwww server.
static meshx_err_t meshx_cwww_cli_el_state_change_reg_cb()
static meshx_err_t meshx_cwww_cli_reg_app_req_cb()
Registers a callback handler for CW-WW application requests.
#define MOD_LCC
static meshx_err_t meshx_dev_create_cwww_model_space(dev_struct_t const *pdev, uint16_t n_max)
Creates a CW-WW model space for the given device.
static meshx_err_t meshx_add_cwww_cli_model_to_element_list(dev_struct_t *pdev, uint16_t *start_idx, uint16_t n_max)
This function adds the CW-WW client models to the element list of the specified device....
#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.
@ MODULE_ID_ELEMENT_LIGHT_CWWWW_CLIENT
Definition module_id.h:25
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_cwww_el_get_state()

meshx_err_t meshx_cwww_el_get_state ( uint16_t element_id,
cwww_cli_sig_id_t model_id )

Retrieves the current state of the CW/WW (Cool White/Warm White) light element for the specified element ID.

This function queries the state of a light element identified by the given element_id.

Parameters
[in]element_idThe unique identifier of the light element whose state is to be retrieved.
[in]model_idThe model ID to specify which model's state to retrieve. If set to CWWW_CLI_SIG_ID_MAX, it retrieves the state for all models.
Returns
meshx_err_t Returns MESHX_OK on success, or an appropriate error code on failure.

Definition at line 931 of file meshx_light_cwww_client.c.

932{
933 if (!IS_EL_IN_RANGE(element_id))
934 {
935 MESHX_LOGE(MOD_LCC, "Invalid element id: %d", element_id);
936 return MESHX_INVALID_ARG;
937 }
938 meshx_cwww_client_msg_t msg = {0};
939 msg.ack = CWWW_CLI_MSG_ACK;
941 msg.element_id = element_id;
942
943 if (model_id != CWWW_CLI_SIG_ID_MAX)
944 {
945 MESHX_LOGD(MOD_LCC, "Sending GET for model: %d", model_id);
946 if(model_id == CWWW_CLI_SIG_L_CTL_MODEL_ID)
947 {
951 &msg,
952 sizeof(msg));
953 }
954 else
955 {
959 &msg,
960 sizeof(msg));
961 }
962 }
963 else
964 {
965 for(model_id = CWWW_CLI_SIG_ONOFF_MODEL_ID; model_id < CWWW_CLI_SIG_ID_MAX; model_id++)
966 {
967
968 MESHX_LOGD(MOD_LCC, "Sending GET for model: %d", model_id);
969 if(model_id == CWWW_CLI_SIG_L_CTL_MODEL_ID)
970 {
974 &msg,
975 sizeof(msg));
976 }
977 else
978 {
982 &msg,
983 sizeof(msg));
984 }
985 }
986 }
987 return MESHX_SUCCESS;
988}
CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL
@ 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.
@ MESHX_INVALID_ARG
Definition meshx_err.h:42
#define IS_EL_IN_RANGE(_element_id)
#define CWWW_CLI_MSG_ACK
Acknowledgment message type.
struct cwww_client_msg meshx_cwww_client_msg_t
Structure to hold the cwww client message sent from APP layer.
#define CWWW_CLI_MSG_GET
Message type for getting CW-WW client state.
#define MESHX_LOGD(module_id, format,...)
Definition meshx_log.h:113
Here is the call graph for this function: