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.
|
Common BLE Mesh interface definitions and utility functions. More...
#include "stdlib.h"
#include "string.h"
#include "meshx_err.h"
#include "meshx_ble_mesh_cmn_def.h"
#include "interface/meshx_platform.h"
Go to the source code of this file.
Data Structures | |
struct | meshx_model |
Structure as Interface for meshx models. More... | |
struct | meshx_ctx |
Structure to hold context information for BLE Mesh operations. More... | |
struct | meshx_prov_params |
Structure to hold provisioning parameters. More... | |
Typedefs | |
typedef struct meshx_model | meshx_model_t |
typedef struct meshx_ctx | meshx_ctx_t |
Structure to hold context information for BLE Mesh operations. | |
typedef struct meshx_prov_params | meshx_prov_params_t |
Structure to hold provisioning parameters. | |
Functions | |
meshx_err_t | meshx_is_group_subscribed (meshx_model_t *p_model, uint16_t addr) |
Checks if a model is subscribed to a specific group address. | |
meshx_err_t | meshx_plat_create_model_pub (meshx_ptr_t *p_pub, uint16_t nmax) |
Creates and initializes model and publication structures. | |
meshx_err_t | meshx_plat_del_model_pub (meshx_ptr_t *p_pub) |
Deletes the model and publication objects. | |
meshx_err_t | meshx_plat_client_create (meshx_ptr_t p_model, meshx_ptr_t *p_pub, meshx_ptr_t *p_cli) |
Creates and initializes a generic client model for BLE Mesh. | |
meshx_err_t | meshx_get_model_id (meshx_ptr_t p_model, uint16_t *model_id) |
Retrieve the model ID of a generic server model. | |
meshx_err_t | meshx_create_plat_composition (meshx_ptr_t *p_comp) |
Creates a platform-specific BLE Mesh composition object. | |
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_plat_composition_init (meshx_ptr_t p_composition, meshx_ptr_t p_elements, uint16_t cid, uint16_t pid, uint16_t element_idx) |
Initializes a platform-specific BLE Mesh composition. | |
meshx_err_t | meshx_platform_bt_init (meshx_uuid_addr_t uuid) |
Initializes the Bluetooth subsystem of the MeshX platform. | |
meshx_err_t | meshx_plat_ble_mesh_init (const meshx_prov_params_t *prov_cfg, meshx_ptr_t comp) |
Initializes the BLE Mesh stack with the given provisioning parameters. | |
meshx_err_t | meshx_get_base_element_id (uint16_t *base_el_id) |
Retrieves the base element ID for the BLE Mesh platform. | |
Common BLE Mesh interface definitions and utility functions.
Copyright (c) 2024 - 2025 MeshX
This header file contains the definitions and function declarations for managing BLE Mesh models, contexts, and compositions. It provides utilities for checking model subscriptions, creating and deleting model structures, retrieving model IDs, and managing BLE Mesh compositions.
The functions defined here facilitate the initialization, manipulation, and cleanup of BLE Mesh components, ensuring efficient memory management and error handling.
Definition in file meshx_ble_mesh_cmn.h.
typedef struct meshx_ctx meshx_ctx_t |
Structure to hold context information for BLE Mesh operations.
typedef struct meshx_model meshx_model_t |
typedef struct meshx_prov_params meshx_prov_params_t |
Structure to hold provisioning parameters.
meshx_err_t meshx_create_plat_composition | ( | meshx_ptr_t * | p_comp | ) |
Creates a platform-specific BLE Mesh composition object.
This function allocates memory for a MESHX_COMPOSITION object and assigns its pointer to the provided pointer argument. It checks for invalid arguments and memory allocation failures, returning appropriate error codes.
[out] | p_comp | Pointer to the location where the composition object pointer will be stored. |
Definition at line 99 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_get_base_element_id | ( | uint16_t * | base_el_id | ) |
Retrieves the base element ID for the BLE Mesh platform.
This function fetches the base element ID, which is used as a reference point for other elements in the BLE Mesh composition.
[out] | base_el_id | Pointer to a variable where the base element ID will be stored. |
Definition at line 153 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_get_model_id | ( | meshx_ptr_t | p_model, |
uint16_t * | model_id ) |
Retrieve the model ID of a generic server model.
This function obtains the model ID associated with a specified generic server model.
[in] | p_model | Pointer to the model whose ID is to be retrieved. |
[out] | model_id | Pointer to a variable where the retrieved model ID will be stored. |
Definition at line 88 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_is_group_subscribed | ( | meshx_model_t * | p_model, |
uint16_t | addr ) |
Checks if a model is subscribed to a specific group address.
This function determines whether the specified BLE Mesh model is subscribed to a given group address by utilizing the internal function esp_ble_mesh_is_model_subscribed_to_group.
[in] | p_model | Pointer to the BLE Mesh model structure. |
[in] | addr | The group address to check for subscription. |
Definition at line 23 of file esp_platform_ble_mesh.c.
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.
This function adds a new element to the BLE Mesh composition at the specified index. It assigns the provided SIG and vendor models to the element and sets their respective counts.
[in] | index | Index at which the element is to be added. |
[in,out] | p_element_list | Pointer to the list of elements. |
[in] | p_sig_models | Pointer to the SIG models to be assigned to the element. |
[in] | p_ven_models | Pointer to the vendor models to be assigned to the element. |
[in] | sig_cnt | Number of SIG models. |
[in] | ven_cnt | Number of vendor models. |
Definition at line 111 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_plat_ble_mesh_init | ( | const meshx_prov_params_t * | prov_cfg, |
meshx_ptr_t | comp ) |
Initializes the BLE Mesh stack with the given provisioning parameters.
This function sets up the BLE Mesh stack and initializes it with the provided provisioning parameters.
[in] | prov_cfg | Pointer to the provisioning parameters structure. |
[in] | comp | Pointer to the composition data. |
Definition at line 193 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_plat_client_create | ( | meshx_ptr_t | p_model, |
meshx_ptr_t * | p_pub, | ||
meshx_ptr_t * | p_cli ) |
Creates and initializes a generic client model for BLE Mesh.
This function sets up the necessary structures and resources for a generic client model in the BLE Mesh stack. It initializes the model, publication context, and the on/off client instance.
[in] | p_model | Pointer to the model structure to be initialized. |
[out] | p_pub | Pointer to a location where the address of the publication context will be stored. |
[out] | p_cli | Pointer to a location where the address of the on/off client instance will be stored. |
Definition at line 56 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_plat_composition_init | ( | meshx_ptr_t | p_composition, |
meshx_ptr_t | p_elements, | ||
uint16_t | cid, | ||
uint16_t | pid, | ||
uint16_t | element_idx ) |
Initializes a platform-specific BLE Mesh composition.
This function sets up a BLE Mesh composition object with the specified company ID, product ID, and element index. It assigns the provided elements to the composition.
[out] | p_composition | Pointer to the composition object to be initialized. |
[in] | p_elements | Pointer to the elements to be included in the composition. |
[in] | cid | Company ID for the composition. |
[in] | pid | Product ID for the composition. |
[in] | element_idx | Index of the element within the composition. |
Definition at line 133 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_plat_create_model_pub | ( | meshx_ptr_t * | p_pub, |
uint16_t | nmax ) |
Creates and initializes model and publication structures.
This function allocates memory for model and publication structures based on the specified maximum number of elements. It initializes the provided pointers to point to the newly allocated memory.
[out] | p_pub | Pointer to the publication structure to be created. |
[in] | nmax | Maximum number of elements for the model and publication. |
Definition at line 31 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_plat_del_model_pub | ( | meshx_ptr_t * | p_pub | ) |
Deletes the model and publication objects.
This function frees the memory allocated for the model and publication objects pointed to by the provided pointers and sets them to NULL.
[in,out] | p_pub | Pointer to the publication object to be deleted. |
Definition at line 43 of file esp_platform_ble_mesh.c.
meshx_err_t meshx_platform_bt_init | ( | meshx_uuid_addr_t | uuid | ) |
Initializes the Bluetooth subsystem of the MeshX platform.
This function sets up the Bluetooth-related components necessary for MeshX operation, such as BLE Mesh provisioning and communication.
[in] | uuid | Pointer to the UUID address to be used for the Bluetooth initialization. |
Definition at line 165 of file esp_platform_ble_mesh.c.