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.
|
Relay server model implementation for BLE Mesh networks. More...
#include "meshx_relay_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 CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_ON_OFF |
#define | CONTROL_TASK_MSG_EVT_TO_BLE_GEN_SRV_MASK CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF_SRV |
#define | GET_RELATIVE_EL_IDX(_element_id) |
Get the relative index of an element ID. | |
#define | IS_EL_IN_RANGE(_element_id) |
Check if an element ID is within range. | |
#define | RELAY_SRV_EL(_el_id) |
Functions | |
static meshx_err_t | relay_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) |
Initialize the mesh element structure by allocating memory for various components. | |
static meshx_err_t | meshx_element_struct_deinit (void) |
Deinitializes the mesh element structure by freeing allocated memory. | |
static meshx_err_t | meshx_dev_create_relay_model_space (uint16_t n_max) |
Create relay model space. | |
static meshx_err_t | meshx_restore_model_states (uint16_t element_id) |
Restore saved relay model states. | |
static meshx_err_t | meshx_add_relay_srv_model_to_element_list (dev_struct_t *pdev, uint16_t *start_idx, uint16_t n_max) |
Add relay server models to the element list. | |
static meshx_err_t | meshx_api_control_task_handler (dev_struct_t const *pdev, control_task_msg_evt_t evt, void *params) |
Callback function for relay server model events. | |
static meshx_err_t | relay_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_relay_srv_msg_send_handler (const dev_struct_t *pdev, control_task_msg_evt_to_ble_t evt, meshx_gen_srv_cb_param_t *params) |
Handles the BLE message sending for the Generic OnOff Server model. | |
meshx_err_t | meshx_create_relay_elements (dev_struct_t *pdev, uint16_t element_cnt) |
Create Dynamic Relay Model Elements. | |
REG_MESHX_ELEMENT_FN (relay_srv_el, MESHX_ELEMENT_TYPE_RELAY_SERVER, meshx_create_relay_elements) | |
Variables | |
static meshx_relay_element_ctrl_t | relay_element_init_ctrl |
Structure to manage relay element initialization. | |
Relay server model implementation for BLE Mesh networks.
Copyright © 2024 - 2025 MeshX
This file contains the implementation of the relay server model for BLE Mesh. It includes functions to initialize, configure, and manage relay server elements.
Definition in file meshx_relay_server.c.
#define CONFIG_SERVER_CB_MASK |
Configuration server callback event mask for relay server.
Definition at line 25 of file meshx_relay_server.c.
#define CONTROL_TASK_EVT_MASK CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_ON_OFF |
Definition at line 30 of file meshx_relay_server.c.
#define CONTROL_TASK_MSG_EVT_TO_BLE_GEN_SRV_MASK CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF_SRV |
Definition at line 32 of file meshx_relay_server.c.
#define GET_RELATIVE_EL_IDX | ( | _element_id | ) |
Get the relative index of an element ID.
_element_id | The element ID. |
Definition at line 39 of file meshx_relay_server.c.
#define IS_EL_IN_RANGE | ( | _element_id | ) |
Check if an element ID is within range.
_element_id | The element ID. |
Definition at line 46 of file meshx_relay_server.c.
#define RELAY_SRV_EL | ( | _el_id | ) |
Definition at line 47 of file meshx_relay_server.c.
|
static |
Add relay server models to the element list.
Registers the relay server models to the BLE Mesh element list.
pdev | Pointer to the device structure. |
start_idx | Pointer to the start index of elements. |
n_max | Maximum number of elements to add. |
Definition at line 289 of file meshx_relay_server.c.
|
static |
Callback function for relay server model events.
This function handles events from the relay server model, such as setting the relay state.
[in] | pdev | Pointer to the callback parameter structure. |
[in] | evt | Relay server event type. |
[in] | params | Pointer to the parameters for the event. |
Definition at line 351 of file meshx_relay_server.c.
meshx_err_t meshx_create_relay_elements | ( | dev_struct_t * | pdev, |
uint16_t | element_cnt ) |
Create Dynamic Relay Model Elements.
[in] | pdev | Pointer to device structure |
[in] | element_cnt | Maximum number of relay models |
Definition at line 497 of file meshx_relay_server.c.
|
static |
Create relay model space.
Allocates memory and initializes space for relay models.
n_max | Maximum number of relay models. |
Definition at line 231 of file meshx_relay_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 192 of file meshx_relay_server.c.
|
static |
Initialize the mesh element structure by allocating memory for various components.
This function initializes the mesh element structure by allocating memory for various components, including server context, server signature model list, server publication list, server on/off generic list, and server light control list.
n_max | The maximum number of elements in the server signature model list and server publication list. |
Definition at line 135 of file meshx_relay_server.c.
|
static |
Handles the BLE message sending for the Generic OnOff Server model.
This function processes the event to send a BLE Mesh message for the Generic Server model.
[in] | pdev | Pointer to the device structure. |
[in] | evt | Event type for the control task message to BLE. |
[in] | params | Parameters for the BLE Mesh Generic Server model. |
Definition at line 461 of file meshx_relay_server.c.
|
static |
Restore saved relay model states.
Restores the relay model states from the NVS.
element_id | Relative element ID. |
Definition at line 251 of file meshx_relay_server.c.
REG_MESHX_ELEMENT_FN | ( | relay_srv_el | , |
MESHX_ELEMENT_TYPE_RELAY_SERVER | , | ||
meshx_create_relay_elements | ) |
|
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 396 of file meshx_relay_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 67 of file meshx_relay_server.c.
|
static |
Structure to manage relay element initialization.
Definition at line 51 of file meshx_relay_server.c.