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.
|
Implementation of the CW-WW server model for BLE Mesh. More...
#include <meshx_cwww_server_element.h>
#include <meshx_nvs.h>
#include <meshx_api.h>
#include "meshx_config_server.h"
Go to the source code of this file.
Macros | |
#define | CONFIG_SERVER_CB_MASK |
Configuration server callback event mask for relay server. | |
#define | CONTROL_TASK_EVT_MASK |
#define | CONTROL_TASK_MSG_EVT_TO_BLE_GEN_SRV_MASK |
#define | GET_RELATIVE_EL_IDX(_element_id) |
#define | IS_EL_IN_RANGE(_element_id) |
#define | CWWW_SRV_EL(_el_id) |
#define | CWWW_TEMP_MIN 2700 |
#define | CWWW_TEMP_MAX 6500 |
Functions | |
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. | |
static meshx_err_t | meshx_element_struct_init (uint16_t n_max) |
Initializes the mesh element structure by freeing allocated memory. | |
static meshx_err_t | meshx_element_struct_deinit () |
Deinitializes the mesh element structure by freeing allocated memory. | |
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_restore_model_states (uint16_t element_id) |
Restore saved CW-WW model states. | |
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_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_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. | |
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. | |
meshx_err_t | meshx_create_cwww_elements (dev_struct_t *pdev, uint16_t element_cnt) |
Create Dynamic CWWW Server Model Elements. | |
REG_MESHX_ELEMENT_FN (cwww_srv_el, MESHX_ELEMENT_TYPE_LIGHT_CWWW_SERVER, meshx_create_cwww_elements) | |
Variables | |
static meshx_cwww_elements_ctrl_t | cwww_element_init_ctrl |
Implementation of the CW-WW server model for BLE Mesh.
Copyright © 2024 - 2025 MeshX
This file contains the implementation of the CW-WW server model for BLE Mesh, including initialization, configuration, and event handling.
Definition in file meshx_cwww_server.c.
#define CONFIG_SERVER_CB_MASK |
Configuration server callback event mask for relay server.
Definition at line 25 of file meshx_cwww_server.c.
#define CONTROL_TASK_EVT_MASK |
Definition at line 30 of file meshx_cwww_server.c.
#define CONTROL_TASK_MSG_EVT_TO_BLE_GEN_SRV_MASK |
Definition at line 34 of file meshx_cwww_server.c.
#define CWWW_SRV_EL | ( | _el_id | ) |
Definition at line 40 of file meshx_cwww_server.c.
#define CWWW_TEMP_MAX 6500 |
Definition at line 43 of file meshx_cwww_server.c.
#define CWWW_TEMP_MIN 2700 |
Definition at line 42 of file meshx_cwww_server.c.
#define GET_RELATIVE_EL_IDX | ( | _element_id | ) |
Definition at line 38 of file meshx_cwww_server.c.
#define IS_EL_IN_RANGE | ( | _element_id | ) |
Definition at line 39 of file meshx_cwww_server.c.
|
static |
Callback function for relay server model events for Provisioning events.
[in] | pdev | Pointer to the device structure. |
[in] | evt | Relay server event type. |
[in] | params | Pointer to the parameters for the event. |
Definition at line 455 of file meshx_cwww_server.c.
|
static |
Callback function for configuration server events.
This function handles events from the configuration server, such as model publication and application binding events.
[in] | pdev | Pointer to device struct |
[in] | evt | Configuration event type. |
[in] | params | Pointer to the callback parameter structure. |
Definition at line 58 of file meshx_cwww_server.c.
|
static |
Add CW-WW server models to the element list.
This function adds the CW-WW server models to the specified element list.
pdev | Pointer to the device structure. |
start_idx | Pointer to the starting index. |
n_max | Maximum number of models. |
Definition at line 296 of file meshx_cwww_server.c.
|
static |
CW-WW server model event handler.
This function handles events from the CW-WW server model.
Event Types:
If the element ID is out of range, the function exits without making any changes.
[in] | pdev | Pointer to the device structure. |
[in] | evt | Event type. |
[in] | params | Pointer to the event parameters. |
Definition at line 369 of file meshx_cwww_server.c.
meshx_err_t meshx_create_cwww_elements | ( | dev_struct_t * | pdev, |
uint16_t | element_cnt ) |
Create Dynamic CWWW Server Model Elements.
This function creates dynamic CWWW server model elements for the given device structure.
[in] | pdev | Pointer to device structure |
[in] | element_cnt | Maximum number of CWWW server models |
Definition at line 613 of file meshx_cwww_server.c.
|
static |
Handler for sending messages from the CW-WW server model to BLE.
This function handles the sending of messages from the CW-WW server model to BLE. It processes different events and sends the appropriate status messages based on the event type.
[in] | pdev | Pointer to the device structure. |
[in] | evt | Event type to handle. |
[in] | params | Pointer to the parameters for the event. |
Definition at line 543 of file meshx_cwww_server.c.
|
static |
Create space for CW-WW models.
This function allocates and initializes the space required for CW-WW models.
n_max | Maximum number of models. |
Definition at line 232 of file meshx_cwww_server.c.
|
static |
Deinitializes the mesh element structure by freeing allocated memory.
This function deallocates memory for various components of the mesh element structure, including server context, server signature model list, server publication list, server on/off generic list, server light control list, and light control state. It ensures that all pointers are set to NULL after freeing the memory to avoid dangling pointers..
Definition at line 189 of file meshx_cwww_server.c.
|
static |
Initializes the mesh element structure by freeing allocated memory.
This function allocates memory for various components of the mesh element structure, including server context, server signature model list, server publication list, server on/off generic list, server light control list, and light control state. It ensures that all pointers are set to NULL after freeing the memory to avoid dangling pointers.
[in] | n_max | The maximum number of elements in the server signature model list and server publication list. |
Definition at line 126 of file meshx_cwww_server.c.
|
static |
Restore saved CW-WW model states.
This function restores the CW-WW model states from the NVS.
element_id | Relative Element ID. |
Definition at line 252 of file meshx_cwww_server.c.
REG_MESHX_ELEMENT_FN | ( | cwww_srv_el | , |
MESHX_ELEMENT_TYPE_LIGHT_CWWW_SERVER | , | ||
meshx_create_cwww_elements | ) |
|
static |
Definition at line 45 of file meshx_cwww_server.c.