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.
Loading...
Searching...
No Matches
meshx_api.h File Reference

This file contains the API definitions for the MeshX application. More...

#include <meshx_common.h>
#include <meshx_elements.h>
#include <meshx_control_task.h>
Include dependency graph for meshx_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  meshx_api_relay_server_evt
 Structure defines the payload for MESHX_ELEMENT_TYPE_RELAY_SERVER. More...
 
struct  meshx_api_light_cwww_server_evt
 Structure defines the payload for MESHX_ELEMENT_TYPE_LIGHT_CWWW_SERVER. More...
 
struct  meshx_api_relay_client_state
 Structure defines the payload for MESHX_ELEMENT_TYPE_RELAY_CLIENT. More...
 
struct  meshx_api_light_cwww_client_evt
 Structure defines the payload for MESHX_ELEMENT_TYPE_LIGHT_CWWW_CLIENT. More...
 
union  meshx_data_payload
 Structure for the BLE Mesh application control message. More...
 
union  meshx_ctrl_payload
 Structure defines the payload for meshx_ctrl_payload. More...
 
struct  meshx_app_element_msg_header
 Structure for the BLE Mesh application element message header. More...
 
struct  meshx_ctrl_msg_header
 Structure for the BLE Mesh application control message header. More...
 
struct  meshx_app_api_msg
 Structure for the BLE Mesh application API message. More...
 

Macros

#define MESHX_APP_API_MSG_MAX_SIZE   sizeof(meshx_data_payload_t)
 
#define MESHX_ELEMENT_FUNC_ID_RELAY_SERVER_ONN_OFF   0x00
 
#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_SERVER_ONN_OFF   0x00
 
#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_SERVER_CTL   0x01
 
#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_CLIENT_ONN_OFF   0x00
 
#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_CLIENT_CTL   0x01
 

Typedefs

typedef enum meshx_api_type meshx_api_type_t
 Enumeration of BLE Mesh application API message types.
 
typedef enum meshx_element_type meshx_element_type_t
 Enumeration of BLE Mesh application API message types.
 
typedef struct meshx_api_relay_server_evt meshx_api_relay_server_evt_t
 Structure defines the payload for MESHX_ELEMENT_TYPE_RELAY_SERVER.
 
typedef 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.
 
typedef struct meshx_api_relay_client_state meshx_api_relay_client_evt_t
 Structure defines the payload for MESHX_ELEMENT_TYPE_RELAY_CLIENT.
 
typedef 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.
 
typedef union meshx_data_payload meshx_data_payload_t
 Structure for the BLE Mesh application control message.
 
typedef union meshx_ctrl_payload meshx_ctrl_payload_t
 Structure defines the payload for meshx_ctrl_payload.
 
typedef struct meshx_app_element_msg_header meshx_app_element_msg_header_t
 Structure for the BLE Mesh application element message header.
 
typedef struct meshx_ctrl_msg_header meshx_ctrl_msg_header_t
 Structure for the BLE Mesh application control message header.
 
typedef struct meshx_app_api_msg meshx_app_api_msg_t
 Structure for the BLE Mesh application API message.
 
typedef meshx_err_t(* meshx_app_data_cb_t) (const meshx_app_element_msg_header_t *msg_hdr, const meshx_data_payload_t *msg)
 BLE Mesh application callback function.
 
typedef meshx_err_t(* meshx_app_ctrl_cb_t) (const meshx_ctrl_msg_header_t *msg_hdr, const meshx_ctrl_payload_t *msg)
 BLE Mesh application control callback function.
 

Enumerations

enum  meshx_api_type {
  MESHX_API_TYPE_DATA = CONTROL_TASK_MSG_EVT_DATA ,
  MESHX_API_TYPE_CTRL = CONTROL_TASK_MSG_EVT_CTRL
}
 Enumeration of BLE Mesh application API message types. More...
 
enum  meshx_element_type {
  MESHX_ELEMENT_TYPE_RELAY_SERVER ,
  MESHX_ELEMENT_TYPE_RELAY_CLIENT ,
  MESHX_ELEMENT_TYPE_LIGHT_CWWW_SERVER ,
  MESHX_ELEMENT_TYPE_LIGHT_CWWW_CLIENT ,
  MESHX_ELEMENT_TYPE_MAX
}
 Enumeration of BLE Mesh application API message types. More...
 

Functions

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_err_t meshx_send_msg_to_element (uint16_t element_id, uint16_t element_type, uint16_t func_id, uint16_t msg_len, const void *msg)
 Sends a message to the element.
 
meshx_err_t meshx_app_reg_element_callback (meshx_app_data_cb_t cb)
 Registers the BLE Mesh application callback.
 
meshx_err_t meshx_app_reg_system_events_callback (meshx_app_ctrl_cb_t cb)
 Registers the BLE Mesh application control callback.
 

Detailed Description

This file contains the API definitions for the MeshX application.

The MeshX API provides functions and structures to interact with the BLE Mesh application. It includes message types, payload structures, and callback function definitions.

Author
Pranjal Chanda

Definition in file meshx_api.h.

Macro Definition Documentation

◆ MESHX_APP_API_MSG_MAX_SIZE

#define MESHX_APP_API_MSG_MAX_SIZE   sizeof(meshx_data_payload_t)

Definition at line 18 of file meshx_api.h.

◆ MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_CLIENT_CTL

#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_CLIENT_CTL   0x01

Definition at line 29 of file meshx_api.h.

◆ MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_CLIENT_ONN_OFF

#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_CLIENT_ONN_OFF   0x00

Definition at line 28 of file meshx_api.h.

◆ MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_SERVER_CTL

#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_SERVER_CTL   0x01

Definition at line 25 of file meshx_api.h.

◆ MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_SERVER_ONN_OFF

#define MESHX_ELEMENT_FUNC_ID_LIGHT_CWWW_SERVER_ONN_OFF   0x00

Definition at line 24 of file meshx_api.h.

◆ MESHX_ELEMENT_FUNC_ID_RELAY_SERVER_ONN_OFF

#define MESHX_ELEMENT_FUNC_ID_RELAY_SERVER_ONN_OFF   0x00

Definition at line 21 of file meshx_api.h.

Typedef Documentation

◆ meshx_api_light_cwww_client_evt_t

Structure defines the payload for MESHX_ELEMENT_TYPE_LIGHT_CWWW_CLIENT.

◆ meshx_api_light_cwww_server_evt_t

Structure defines the payload for MESHX_ELEMENT_TYPE_LIGHT_CWWW_SERVER.

◆ meshx_api_relay_client_evt_t

Structure defines the payload for MESHX_ELEMENT_TYPE_RELAY_CLIENT.

◆ meshx_api_relay_server_evt_t

Structure defines the payload for MESHX_ELEMENT_TYPE_RELAY_SERVER.

◆ meshx_api_type_t

Enumeration of BLE Mesh application API message types.

◆ meshx_app_api_msg_t

Structure for the BLE Mesh application API message.

This structure defines the BLE Mesh application API message.

◆ meshx_app_ctrl_cb_t

typedef meshx_err_t(* meshx_app_ctrl_cb_t) (const meshx_ctrl_msg_header_t *msg_hdr, const meshx_ctrl_payload_t *msg)

BLE Mesh application control callback function.

This function is the BLE Mesh application control callback function.

Parameters
[in]msg_hdrPointer to the BLE Mesh application control message header.
[in]msgPointer to the message.
Returns
MESHX_SUCCESS on success, error code otherwise.

Definition at line 199 of file meshx_api.h.

◆ meshx_app_data_cb_t

typedef meshx_err_t(* meshx_app_data_cb_t) (const meshx_app_element_msg_header_t *msg_hdr, const meshx_data_payload_t *msg)

BLE Mesh application callback function.

This function is the BLE Mesh application callback function.

Parameters
[in]msg_hdrPointer to the BLE Mesh application message header.
[in]msgPointer to the message.
Returns
MESHX_SUCCESS on success, error code otherwise.

Definition at line 187 of file meshx_api.h.

◆ meshx_app_element_msg_header_t

Structure for the BLE Mesh application element message header.

This structure defines the header for BLE Mesh application element messages.

◆ meshx_ctrl_msg_header_t

Structure for the BLE Mesh application control message header.

This structure defines the header for BLE Mesh application control messages.

◆ meshx_ctrl_payload_t

Structure defines the payload for meshx_ctrl_payload.

◆ meshx_data_payload_t

Structure for the BLE Mesh application control message.

This structure defines the BLE Mesh application control payloads.

◆ meshx_element_type_t

Enumeration of BLE Mesh application API message types.

Enumeration Type Documentation

◆ meshx_api_type

Enumeration of BLE Mesh application API message types.

Enumerator
MESHX_API_TYPE_DATA CONTROL_TASK_MSG_EVT_DATA 

Data message : All msg rekated to BLE mesh elements

MESHX_API_TYPE_CTRL CONTROL_TASK_MSG_EVT_CTRL 

Control message : All msg related to System control

Definition at line 33 of file meshx_api.h.

34{
@ MESHX_API_TYPE_DATA
Definition meshx_api.h:35
@ MESHX_API_TYPE_CTRL
Definition meshx_api.h:36
enum meshx_api_type meshx_api_type_t
Enumeration of BLE Mesh application API message types.
CONTROL_TASK_MSG_EVT_CTRL
CONTROL_TASK_MSG_EVT_DATA

◆ meshx_element_type

Enumeration of BLE Mesh application API message types.

Enumerator
MESHX_ELEMENT_TYPE_RELAY_SERVER 
MESHX_ELEMENT_TYPE_RELAY_CLIENT 
MESHX_ELEMENT_TYPE_LIGHT_CWWW_SERVER 
MESHX_ELEMENT_TYPE_LIGHT_CWWW_CLIENT 
MESHX_ELEMENT_TYPE_MAX 

Definition at line 42 of file meshx_api.h.

43{
enum meshx_element_type meshx_element_type_t
Enumeration of BLE Mesh application API message types.
@ MESHX_ELEMENT_TYPE_LIGHT_CWWW_CLIENT
Definition meshx_api.h:47
@ MESHX_ELEMENT_TYPE_RELAY_CLIENT
Definition meshx_api.h:45
@ MESHX_ELEMENT_TYPE_MAX
Definition meshx_api.h:48
@ MESHX_ELEMENT_TYPE_LIGHT_CWWW_SERVER
Definition meshx_api.h:46
@ MESHX_ELEMENT_TYPE_RELAY_SERVER
Definition meshx_api.h:44

Function Documentation

◆ meshx_app_reg_element_callback()

meshx_err_t meshx_app_reg_element_callback ( meshx_app_data_cb_t cb)

Registers the BLE Mesh application callback.

This function registers the BLE Mesh application data path callback.

Parameters
[in]cbPointer to the application callback.
Returns
MESHX_SUCCESS on success, error code otherwise.

Definition at line 148 of file meshx_api.c.

149{
151
156 if (err)
157 {
158 MESHX_LOGE(MODULE_ID_COMMON, "Failed to register control task callback: (%d)", err);
159 return err;
160 }
161
162 meshx_api_ctrl.app_data_cb = cb;
163
164 return err;
165}
static struct @116303252105212016000076260223147336330304166341 meshx_api_ctrl
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_CODE_TO_APP
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_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.
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:39
@ MESHX_SUCCESS
Definition meshx_err.h:40
#define MESHX_LOGE(module_id, format,...)
Definition meshx_log.h:73
@ MODULE_ID_COMMON
Definition module_id.h:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_app_reg_system_events_callback()

meshx_err_t meshx_app_reg_system_events_callback ( meshx_app_ctrl_cb_t cb)

Registers the BLE Mesh application control callback.

This function registers the BLE Mesh application control callback.

Parameters
[in]cbPointer to the control callback.
Returns
MESHX_SUCCESS on success, error code otherwise.

Definition at line 176 of file meshx_api.c.

177{
179
184 if (err)
185 {
186 MESHX_LOGE(MODULE_ID_COMMON, "Failed to register control task callback: (%d)", err);
187 return err;
188 }
189
190 meshx_api_ctrl.app_ctrl_cb = cb;
191
192 return err;
193}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_send_msg_to_app()

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.

This function sends a message to the BLE Mesh application.

Parameters
[in]element_idThe element ID.
[in]element_typeThe element type.
[in]func_idThe function ID.
[in]msg_lenThe message length.
[in]msgPointer to the message.
Returns
MESHX_SUCCESS on success, error code otherwise.

Definition at line 96 of file meshx_api.c.

97{
99
100 err = meshx_prepare_data_message(element_id, element_type, func_id, msg_len,msg);
101 if(err)
102 MESHX_LOGE(MODULE_ID_COMMON, "Failed to create message: (0x%x)", err);
103
105 if(err)
106 MESHX_LOGE(MODULE_ID_COMMON, "Failed to send message to app: (0x%x)", err);
107
108 return err;
109}
static meshx_err_t meshx_prepare_data_message(uint16_t element_id, uint16_t element_type, uint16_t func_id, uint16_t msg_len, const void *msg)
Prepares a message to be sent to the BLE Mesh application.
Definition meshx_api.c:66
struct meshx_app_api_msg meshx_app_api_msg_t
Structure for the BLE Mesh application API message.
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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ meshx_send_msg_to_element()

meshx_err_t meshx_send_msg_to_element ( uint16_t element_id,
uint16_t element_type,
uint16_t func_id,
uint16_t msg_len,
const void * msg )

Sends a message to the element.

This function sends a message to the element from BLE mesh Application

Parameters
[in]element_idThe element ID.
[in]element_typeThe element type.
[in]func_idThe function ID.
[in]msg_lenThe message length.
[in]msgPointer to the message.
Returns
MESHX_SUCCESS on success, error code otherwise.

Definition at line 124 of file meshx_api.c.

125{
127
128 err = meshx_prepare_data_message(element_id, element_type, func_id, msg_len,msg);
129 if(err)
130 MESHX_LOGE(MODULE_ID_COMMON, "Failed to create message: (0x%x)", err);
131
133 if(err)
134 MESHX_LOGE(MODULE_ID_COMMON, "Failed to send message to app: (0x%x)", err);
135
136 return err;
137}
@ CONTROL_TASK_MSG_CODE_TO_MESHX
Here is the call graph for this function: