29#if CONFIG_LIGHT_CWWW_CLIENT_COUNT > 0
32#if CONFIG_ENABLE_CONFIG_SERVER
38#define CONFIG_SERVER_CB_MASK \
39 CONTROL_TASK_MSG_EVT_PUB_ADD \
40 | CONTROL_TASK_MSG_EVT_SUB_ADD \
41 | CONTROL_TASK_MSG_EVT_APP_KEY_BIND
47#if defined(__MESHX_CONTROL_TASK__)
48#define CONTROL_TASK_MSG_CODE_EVT_MASK \
49 CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF \
50 | CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL
53#define MOD_LCC MODULE_ID_ELEMENT_LIGHT_CWWWW_CLIENT
54#define CWWW_CLI_MESHX_ONOFF_ENABLE_CB true
55#define CWWW_CLI_EL_STATE_CH_EVT_MASK CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_ON_OFF | CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_CTL
57#define IS_EL_IN_RANGE(_element_id) ((_element_id) >= cwww_client_element_init_ctrl.element_id_start && (_element_id) < cwww_client_element_init_ctrl.element_id_end)
58#define GET_RELATIVE_EL_IDX(_element_id) ((_element_id) - cwww_client_element_init_ctrl.element_id_start)
59#define CWWW_CLI_EL(_el_id) cwww_client_element_init_ctrl.el_list[_el_id]
63#if CWWW_CLI_MESHX_ONOFF_ENABLE_CB
65static meshx_err_t meshx_cwww_cli_send_onoff_msg(
const dev_struct_t *pdev, uint16_t element_id, uint8_t set_get, uint8_t ack);
66static meshx_err_t meshx_cwww_cli_send_ctl_msg(
const dev_struct_t *pdev, uint16_t element_id, uint8_t set_get, uint8_t is_temp_range, uint8_t ack);
79static meshx_err_t cwww_client_on_off_state_change_handler(
80 const meshx_on_off_cli_el_msg_t *param)
82 uint16_t element_id = param->model.el_id;
88 err = meshx_gen_on_off_state_change_handle(param, &el_ctx->
prev_state, &el_ctx->
state);
91 app_notify.
err_code = param->err_code;
119static meshx_err_t cwww_light_ctl_state_change_handler(
175static meshx_err_t meshx_cwww_client_element_state_change_handler(
181 if (!pdev || !params)
186 uint16_t element_id = ((
const meshx_on_off_cli_el_msg_t *)params)->model.el_id;
194 err = cwww_client_on_off_state_change_handler(
195 (meshx_on_off_cli_el_msg_t *)params);
198 err = cwww_light_ctl_state_change_handler(
215#if CONFIG_ENABLE_CONFIG_SERVER
233 size_t rel_el_id = 0;
234 uint16_t element_id = 0;
235 uint16_t base_el_id = 0;
236 bool nvs_save =
false;
278#if defined(__MESHX_CONTROL_TASK__)
338 meshx_onoff_client_model_t *model =
CWWW_CLI_EL(rel_el_id).onoff_cli_model;
343 if (MESHX_GEN_ON_OFF_CLI_MSG_SET == set_get)
350 meshx_gen_onoff_send_params_t params = {
351 .element_id = element_id,
356 .app_idx = el_ctx->
app_id,
357 .state = el_ctx->
state.on_off,
361 err = meshx_onoff_client_send_msg(¶ms);
396 uint8_t is_temp_range,
410 .element_id = element_id,
412 .app_idx = el_ctx->
app_id,
417 if(is_temp_range ==
false)
489static meshx_err_t meshx_cwww_client_element_to_ble_handler(
494 if (!pdev || !params)
497 bool is_temp_range =
false;
514 err = meshx_cwww_cli_send_onoff_msg(
522 MESHX_LOGE(
MOD_LCC,
"CWWW Client Control Task: Set OnOff failed (%p)", (
void *)err);
537 err = meshx_cwww_cli_send_ctl_msg(
546 MESHX_LOGE(
MOD_LCC,
"CWWW Client Control Task: Set CTL failed (%p)", (
void *)err);
554#if CONFIG_ENABLE_UNIT_TEST
559typedef enum cwww_cli_cmd
562 CWWW_CLI_UT_CMD_ONOFF_GET = 0,
563 CWWW_CLI_UT_CMD_ONOFF_SET,
564 CWWW_CLI_UT_CMD_ONOFF_SET_UNACK,
566 CWWW_CLI_UT_CMD_CTL_GET,
567 CWWW_CLI_UT_CMD_CTL_SET,
568 CWWW_CLI_UT_CMD_CTL_SET_UNACK,
569 CWWW_CLI_UT_CMD_LIGHTNESS_SET,
570 CWWW_CLI_UT_CMD_LIGHTNESS_SET_UNACK,
571 CWWW_CLI_UT_CMD_TEMPERATURE_SET,
572 CWWW_CLI_UT_CMD_TEMPERATURE_SET_UNACK,
573 CWWW_CLI_UT_CMD_DELTA_UV_SET,
574 CWWW_CLI_UT_CMD_DELTA_UV_SET_UNACK,
575 CWWW_CLI_UT_CMD_TEMPERATURE_RANGE_SET,
576 CWWW_CLI_UT_CMD_TEMPERATURE_RANGE_SET_UNACK,
595static meshx_err_t cwww_cli_unit_test_cb_handler(
int cmd_id,
int argc,
char **argv)
600 cwww_cli_cmd_t cmd = (cwww_cli_cmd_t)cmd_id;
603 if (argc < 1 || cmd_id >= CWWW_CLI_MAX_CMD)
612 case CWWW_CLI_UT_CMD_ONOFF_GET:
618 case CWWW_CLI_UT_CMD_ONOFF_SET:
620 case CWWW_CLI_UT_CMD_ONOFF_SET_UNACK:
627 case CWWW_CLI_UT_CMD_CTL_GET:
633 case CWWW_CLI_UT_CMD_CTL_SET:
635 case CWWW_CLI_UT_CMD_CTL_SET_UNACK:
648 case CWWW_CLI_UT_CMD_LIGHTNESS_SET:
650 case CWWW_CLI_UT_CMD_LIGHTNESS_SET_UNACK:
659 case CWWW_CLI_UT_CMD_TEMPERATURE_SET:
661 case CWWW_CLI_UT_CMD_TEMPERATURE_SET_UNACK:
670 case CWWW_CLI_UT_CMD_DELTA_UV_SET:
672 case CWWW_CLI_UT_CMD_DELTA_UV_SET_UNACK:
681 case CWWW_CLI_UT_CMD_TEMPERATURE_RANGE_SET:
683 case CWWW_CLI_UT_CMD_TEMPERATURE_RANGE_SET_UNACK:
751 err = meshx_on_off_client_create(&
CWWW_CLI_EL(i).onoff_cli_model,
792 for (
size_t i = 0; i < n_max; i++)
856 if (!pdev || !start_idx || !n_max)
875 CWWW_CLI_EL(i - *start_idx).cwww_cli_sig_model_list,
1016 err = meshx_on_off_client_init();
1030#if CONFIG_ENABLE_CONFIG_SERVER
1041#if defined(__MESHX_CONTROL_TASK__)
1066#if CONFIG_ENABLE_UNIT_TEST
This file contains the API definitions for the MeshX application.
meshx_err_t meshx_send_msg_to_app(uint16_t element_id, uint16_t element_type, uint16_t func_id, uint16_t msg_len, const void *msg)
Sends a message to the BLE Mesh application.
@ MESHX_ELEMENT_TYPE_LIGHT_CWWW_CLIENT
#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_CLIENT_ONN_OFF
struct meshx_api_light_cwww_client_evt meshx_api_light_cwww_client_evt_t
Structure defines the payload for MESHX_ELEMENT_TYPE_LIGHT_CWWW_CLIENT.
#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_CLIENT_CTL
meshx_err_t meshx_plat_add_element_to_composition(uint16_t index, meshx_ptr_t p_element_list, meshx_ptr_t p_sig_models, meshx_ptr_t p_ven_models, uint8_t sig_cnt, uint8_t ven_cnt)
Adds an element to the BLE Mesh composition.
meshx_err_t meshx_get_base_element_id(uint16_t *base_el_id)
Retrieves the base element ID for the BLE Mesh platform.
#define MESHX_MODEL_OP_LIGHT_CTL_SET
#define MESHX_MODEL_OP_GEN_ONOFF_SET_UNACK
#define MESHX_ADDR_UNASSIGNED
#define MESHX_MODEL_OP_GEN_ONOFF_GET
#define MESHX_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK
#define MESHX_MODEL_OP_GEN_ONOFF_SET
#define MESHX_MODEL_OP_LIGHT_CTL_SET_UNACK
#define MESHX_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET
#define MESHX_MODEL_OP_LIGHT_CTL_GET
#define MESHX_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET
struct meshx_config_srv_cb_param meshx_config_srv_cb_param_t
control_task_msg_handle_t config_srv_cb_t
control_task_msg_handle_t prov_srv_cb_t
Common application definitions and includes for BLE Mesh Node.
#define REG_MESHX_ELEMENT_FN(_name, _type, _fn)
Register an element composition function.
struct dev_struct dev_struct_t
Structure representing the device composition and elements.
#define CONFIG_MAX_ELEMENT_COUNT
Total Element Count in the Composition.
Header file for the meshxuction configuration server model.
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.
Header file for the control task in the BLE mesh node application.
CONTROL_TASK_MSG_EVT_SYSTEM_FRESH_BOOT
enum __packed control_task_msg_evt_to_ble control_task_msg_evt_to_ble_t
Enumeration for control task message events to BLE.
CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL
uint32_t control_task_msg_evt_t
Type definition for control task message event.
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_EVT_EL_STATE_CH_SET_ON_OFF
@ CONTROL_TASK_MSG_CODE_EL_STATE_CH
@ CONTROL_TASK_MSG_CODE_TO_BLE
CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_CTL
CONTROL_TASK_MSG_EVT_PUB_ADD
CONTROL_TASK_MSG_EVT_APP_KEY_BIND
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.
CONTROL_TASK_MSG_EVT_PUB_DEL
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_err_t
MeshX Error Codes.
struct meshx_ctl_cli_el_msg meshx_ctl_cli_el_msg_t
Structure to hold the On/Off Server to element message.
meshx_err_t meshx_light_ctl_state_change_handle(const meshx_ctl_cli_el_msg_t *param, meshx_ctl_el_state_t *p_ctl_prev_state, const meshx_ctl_el_state_t *p_ctl_next_state)
Handles state changes for the Light CTL client element.
meshx_err_t meshx_light_ctl_client_create(meshx_light_ctl_client_model_t **p_model, void *p_sig_model)
Creates and initializes a Generic Light Client model instance.
meshx_err_t meshx_light_ctl_client_init()
Initialize the Light CTL Client model.
#define MESHX_LIGHT_CTL_CLI_MSG_SET
meshx_err_t meshx_light_ctl_temp_range_client_send_msg(meshx_gen_ctl_send_params_t *params)
Sends a Light CTL Temperature Range message from the client model.
struct meshx_gen_ctl_send_params meshx_gen_ctl_send_params_t
Structure to hold the parameters for sending a Generic Ctl message.
meshx_err_t meshx_light_ctl_client_send_msg(meshx_gen_ctl_send_params_t *params)
Sends a Light CTL (Color Temperature Lightness) message from the Light CTL Client model.
meshx_model_interface_t meshx_light_ctl_client_model_t
Structure representing the Light CTL (Color Temperature Lightness) client model in MeshX.
#define CWWW_CLI_EL_STATE_CH_EVT_MASK
#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()
meshx_err_t create_cwww_client_elements(dev_struct_t *pdev, uint16_t element_cnt)
Create Dynamic CW-WW Model Elements.
#define CWWW_CLI_EL(_el_id)
#define GET_RELATIVE_EL_IDX(_element_id)
static meshx_err_t meshx_cwww_cli_reg_app_req_cb()
Registers a callback handler for CW-WW application requests.
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 elem...
static meshx_err_t meshx_element_struct_init(uint16_t n_max)
Initializes the CW-WW client model.
#define IS_EL_IN_RANGE(_element_id)
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....
static meshx_cwww_client_elements_ctrl_t cwww_client_element_init_ctrl
Implementation of the CW-WW (Cool White - Warm White) client model for BLE Mesh.
#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_ARG_BMAP_LIGHTNESS_SET
struct cwww_client_element_ctrl meshx_cwww_client_elements_ctrl_t
Structure to hold the cwww client elements.
#define CWWW_CLI_MSG_GET
Message type for getting CW-WW client state.
meshx_err_t create_cwww_client_elements(dev_struct_t *pdev, uint16_t element_cnt)
Create Dynamic CW-WW Model Elements.
#define CWWW_ARG_BMAP_DELTA_UV_SET
struct cwww_client_element meshx_cwww_client_elements_t
Structure to hold the cwww client element.
#define CWWW_CLI_MSG_SET
Message type for setting CW-WW client state.
#define CWWW_CLI_MODEL_VEN_CNT
Number of Vendor models in a CW-WW model element.
#define CWWW_ARG_BMAP_TEMPERATURE_SET
#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MIN
#define CWWW_CLI_MSG_NO_ACK
Non-acknowledgment message type.
cwww_cli_sig_id_t
Enumeration of CW-WW SIG model IDs.
@ CWWW_CLI_SIG_ONOFF_MODEL_ID
@ CWWW_CLI_SIG_L_CTL_MODEL_ID
#define CWWW_CLI_MODEL_SIG_CNT
Number of SIG models in a CW-WW model element.
#define CWWW_ARG_BMAP_CTL_SET
Argument bitmap for setting the CW-WW client control state.
#define CWWW_ARG_BMAP_ONOFF_SET
#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET_MAX
struct cwww_cli_ctx meshx_cwww_client_model_ctx_t
Structure to hold the context of the cwww client.
#define CWWW_ARG_BMAP_TEMPERATURE_RANGE_SET
Argument bitmap for setting the temperature range.
#define MESHX_LOGW(module_id, format,...)
#define MESHX_LOGI(module_id, format,...)
#define MESHX_LOGE(module_id, format,...)
#define MESHX_LOGD(module_id, format,...)
Header file for MeshX Non-Volatile Storage (NVS) operations.
meshx_err_t meshx_nvs_element_ctx_set(uint16_t element_id, const void *blob, size_t blob_size)
Store the context of a specific element to NVS.
meshx_err_t meshx_nvs_element_ctx_get(uint16_t element_id, void *blob, size_t blob_size)
Retrieve the context of a specific element from NVS.
meshx_err_t meshx_prov_srv_reg_el_client_cb(prov_srv_cb_t cb)
Register a callback function for provisioning events.
#define CONTROL_TASK_MSG_CODE_EVT_MASK
static meshx_err_t meshx_element_struct_deinit(void)
Deinitializes the mesh element structure.
@ MODULE_ID_ELEMENT_LIGHT_CWWWW_CLIENT
Structure to hold the context of the cwww client.
meshx_on_off_cli_state_t state
meshx_ctl_el_state_t prev_ctl_state
meshx_ctl_el_state_t ctl_state
meshx_on_off_cli_state_t prev_state
meshx_app_store_t meshx_store
MESHX_ELEMENT elements[MAX_ELE_CNT]
struct meshx_api_light_cwww_client_evt::@347235105244230326232000270243372246073133053316::@202375373323027037070222212050326072162342057303 on_off
struct meshx_api_light_cwww_client_evt::@347235105244230326232000270243372246073133053316::@153162234125000074275266213156212277206313354032 ctl
union meshx_api_light_cwww_client_evt::@347235105244230326232000270243372246073133053316 state_change
meshx_cfg_srv_state_change_t state_change
meshx_state_change_cfg_model_app_bind_t mod_app_bind
meshx_state_change_cfg_mod_pub_set_t mod_pub_set
meshx_state_change_cfg_appkey_add_t appkey_add
meshx_err_t register_unit_test(module_id_t module_id, module_callback_t callback)
Register a unit test for a specific module.
#define UT_GET_ARG(_x, _type, _argv)
Macro to extract an argument from the argument list.