17#if CONFIG_LIGHT_CWWW_SRV_COUNT > 0
19#if CONFIG_ENABLE_CONFIG_SERVER
25#define CONFIG_SERVER_CB_MASK \
26 CONTROL_TASK_MSG_EVT_PUB_ADD \
27 | CONTROL_TASK_MSG_EVT_SUB_ADD | CONTROL_TASK_MSG_EVT_APP_KEY_BIND
30#define CONTROL_TASK_EVT_MASK \
31 CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_ON_OFF \
32 | CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_CTL
34#define CONTROL_TASK_MSG_EVT_TO_BLE_GEN_SRV_MASK \
35 CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF_SRV \
36 | CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL_SRV
38#define GET_RELATIVE_EL_IDX(_element_id) _element_id - cwww_element_init_ctrl.element_id_start
39#define IS_EL_IN_RANGE(_element_id) (_element_id >= cwww_element_init_ctrl.element_id_start && _element_id < cwww_element_init_ctrl.element_id_end)
40#define CWWW_SRV_EL(_el_id) cwww_element_init_ctrl.el_list[_el_id]
42#define CWWW_TEMP_MIN 2700
43#define CWWW_TEMP_MAX 6500
47#if CONFIG_ENABLE_CONFIG_SERVER
66 uint16_t element_id = 0;
67 bool nvs_save =
false;
68 uint16_t base_el_id = 0;
156 err = meshx_on_off_server_create(&
CWWW_SRV_EL(i).onoff_srv_model,
204 err = meshx_on_off_server_delete(&
CWWW_SRV_EL(i).onoff_srv_model);
261 err = meshx_gen_on_off_srv_state_restore(
CWWW_SRV_EL(element_id).onoff_srv_model->meshx_sig,
309 for (uint16_t i = *start_idx; i < (n_max + *start_idx); i++)
373 uint16_t element_id = 0;
383 const meshx_on_off_srv_el_msg_t *p_onoff_srv = (
const meshx_on_off_srv_el_msg_t *)params;
384 element_id = p_onoff_srv->model.el_id;
386 goto el_ctrl_task_hndlr_exit;
390 if (el_ctx->
prev_state.on_off == p_onoff_srv->on_off_state)
391 goto el_ctrl_task_hndlr_exit;
394 el_ctx->
prev_state.on_off = p_onoff_srv->on_off_state;
404 goto el_ctrl_task_hndlr_exit;
410 goto el_ctrl_task_hndlr_exit;
443el_ctrl_task_hndlr_exit:
459 size_t rel_el_id = 0;
471 err = meshx_gen_on_off_srv_send_pack_create(
551 uint16_t element_id = 0;
562 goto cwww_srv_msg_handler_exit;
563 err = meshx_gen_on_off_srv_status_send(
564 &gen_srv_send->
model,
580 goto cwww_srv_msg_handler_exit;
582 &light_srv_send->
model,
583 &light_srv_send->
ctx,
599cwww_srv_msg_handler_exit:
628#if CONFIG_ENABLE_CONFIG_SERVER
662 err = meshx_on_off_server_init();
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_SERVER
struct meshx_api_light_cwww_server_evt meshx_api_light_cwww_server_evt_t
Structure defines the payload for MESHX_ELEMENT_TYPE_LIGHT_CWWW_SERVER.
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_ADDR_UNASSIGNED
struct meshx_config_srv_cb_param meshx_config_srv_cb_param_t
control_task_msg_handle_t config_srv_cb_t
struct meshx_gen_srv_cb_param meshx_gen_srv_cb_param_t
struct meshx_light_ctl_srv_state meshx_light_ctl_srv_state_t
struct meshx_light_ctl_srv meshx_light_ctl_srv_t
Structure representing the Light CTL Server model.
struct meshx_lighting_server_cb_param meshx_lighting_server_cb_param_t
control_task_msg_handle_t prov_srv_cb_t
#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.
CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL_SRV
CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF_SRV
enum __packed control_task_msg_evt_to_ble control_task_msg_evt_to_ble_t
Enumeration for control task message events to BLE.
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_EN_NODE_PROV
CONTROL_TASK_MSG_EVT_APP_KEY_BIND
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.
static meshx_err_t meshx_cwww_srv_msg_send_handler(const dev_struct_t *pdev, control_task_msg_evt_to_ble_t evt, void *params)
Handler for sending messages from the CW-WW server model to BLE.
#define CWWW_SRV_EL(_el_id)
static meshx_cwww_elements_ctrl_t cwww_element_init_ctrl
#define CONTROL_TASK_EVT_MASK
#define GET_RELATIVE_EL_IDX(_element_id)
static meshx_err_t meshx_restore_model_states(uint16_t element_id)
Restore saved CW-WW model states.
#define CONTROL_TASK_MSG_EVT_TO_BLE_GEN_SRV_MASK
static meshx_err_t meshx_dev_create_cwww_model_space(uint16_t n_max)
Create space for CW-WW models.
static meshx_err_t meshx_api_control_task_handler(const dev_struct_t *pdev, const control_task_msg_evt_t evt, const void *params)
CW-WW server model event handler.
static meshx_err_t cwww_server_config_srv_cb(const dev_struct_t *pdev, control_task_msg_evt_t evt, const meshx_config_srv_cb_param_t *params)
Callback function for configuration server events.
meshx_err_t meshx_create_cwww_elements(dev_struct_t *pdev, uint16_t element_cnt)
Create Dynamic CWWW Server Model Elements.
static meshx_err_t meshx_element_struct_init(uint16_t n_max)
Initializes the mesh element structure by freeing allocated memory.
#define IS_EL_IN_RANGE(_element_id)
static meshx_err_t meshx_add_cwww_srv_model_to_element_list(dev_struct_t *pdev, uint16_t *start_idx, uint16_t n_max)
Add CW-WW server models to the element list.
static meshx_err_t meshx_element_struct_deinit()
Deinitializes the mesh element structure by freeing allocated memory.
static meshx_err_t cwww_prov_control_task_handler(dev_struct_t const *pdev, control_task_msg_evt_t evt, void const *params)
Callback function for relay server model events for Provisioning events.
Header file for CWWW Server Model.
#define CWWW_SRV_MODEL_VEN_CNT
struct meshx_cwww_elements_ctrl meshx_cwww_elements_ctrl_t
Structure representing a CW-WW element in the BLE mesh network.
#define CWWW_SRV_MODEL_SIG_CNT
cwww_sig_id_t
Enumeration of CW-WW SIG model IDs.
@ CWWW_SIG_ONOFF_MODEL_ID
@ CWWW_SIG_L_CTL_MODEL_ID
meshx_err_t meshx_create_cwww_elements(dev_struct_t *pdev, uint16_t element_cnt)
Create Dynamic CWWW Server Model Elements.
struct cwww_srv_ctx meshx_cwww_server_ctx_t
Structure to hold the context of the cwww client.
struct meshx_cwww_element meshx_cwww_element_t
Structure to manage CWWW element initialization.
meshx_err_t
MeshX Error Codes.
meshx_err_t meshx_gen_srv_send_msg_to_ble(control_task_msg_evt_to_ble_t evt, const meshx_gen_srv_cb_param_t *params)
Sends a message to the BLE subsystem via the control task.
meshx_err_t meshx_light_ctl_server_create(meshx_ctl_server_model_t **p_model, meshx_ptr_t p_sig_model)
Create and initialize a new CTL server model instance.
meshx_err_t meshx_light_ctl_srv_state_restore(meshx_ctl_server_model_t *p_model, meshx_light_ctl_srv_state_t ctl_state)
Restore the CTL state for the generic server model.
meshx_err_t meshx_light_ctl_srv_status_send(meshx_model_t *p_model, meshx_ctx_t *ctx, int16_t delta_uv, uint16_t lightness, uint16_t temperature)
Send the Light CTL status message.
meshx_err_t meshx_light_ctl_srv_send_pack_create(meshx_ptr_t p_model, uint16_t element_id, uint16_t net_idx, uint16_t app_idx, uint16_t pub_addr, meshx_light_ctl_srv_state_t ctl_state, meshx_lighting_server_cb_param_t *light_srv_send)
Create a Light CTL Server send message packet.
meshx_err_t meshx_light_ctl_server_init(void)
Initialize the CTL server model.
meshx_err_t meshx_light_ctl_server_delete(meshx_ctl_server_model_t **p_model)
Delete the CTL server model instance.
#define CONFIG_SERVER_CB_MASK
Configuration server callback event mask for cwww server.
meshx_err_t meshx_gen_light_srv_send_msg_to_ble(control_task_msg_evt_to_ble_t evt, const meshx_lighting_server_cb_param_t *params)
Sends a message to the BLE subsystem via the control task.
#define MESHX_LOGW(module_id, format,...)
#define MESHX_LOGI(module_id, format,...)
#define MESHX_LOGE(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_server_cb(prov_srv_cb_t cb)
Register a callback function for provisioning events.
@ MODULE_ID_ELEMENT_SWITCH_RELAY_SERVER
meshx_light_ctl_srv_state_t prev_ctl_state
meshx_on_off_srv_el_state_t prev_state
meshx_app_store_t meshx_store
MESHX_ELEMENT elements[MAX_ELE_CNT]
union meshx_api_light_cwww_server_evt::@257165005032013366004013204037032016036030275264 state_change
struct meshx_api_light_cwww_server_evt::@257165005032013366004013204037032016036030275264::@375004001161356005102054253202024137247030164222 on_off
struct meshx_api_light_cwww_server_evt::@257165005032013366004013204037032016036030275264::@245341060156102221224175046143367317210200103050 ctl
meshx_cfg_srv_state_change_t state_change
meshx_gen_srv_state_change_t state_change
uint16_t temperature_range_min
uint16_t temperature_range_max
meshx_light_ctl_srv_state_t state
meshx_lighting_server_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_state_change_gen_onoff_set_t onoff_set
meshx_state_change_light_ctl_set_t ctl_set