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.
|
Header file for the control task in the BLE mesh node application. More...
#include "stdio.h"
#include "string.h"
#include "meshx_common.h"
#include "interface/rtos/meshx_task.h"
#include "interface/rtos/meshx_msg_q.h"
#include "interface/rtos/meshx_rtos_utils.h"
Go to the source code of this file.
Data Structures | |
struct | control_task_msg |
Structure for control task message. More... | |
struct | control_task_evt_cb_reg |
Structure for control task event callback registration. More... | |
Macros | |
#define | CONFIG_CONTROL_TASK_NAME "meshx_control_task" |
Control task name configuration. | |
#define | CONFIG_CONTROL_TASK_PRIO configTIMER_TASK_PRIORITY + 1 |
Control task priority configuration. | |
#define | CONFIG_CONTROL_TASK_STACK_SIZE 4096 |
Control task stack size configuration. | |
#define | CONFIG_CONTROL_TASK_QUEUE_LEN 10 |
Control task queue length configuration. | |
Typedefs | |
typedef enum control_task_msg_code | control_task_msg_code_t |
Enumeration for control task message codes. | |
typedef uint32_t | control_task_msg_evt_t |
Type definition for control task message event. | |
typedef enum __packed control_task_msg_evt_to_app_meshx | control_task_msg_evt_to_app_meshx_t |
Enumeration for control task message events to application. | |
typedef enum __packed control_task_msg_evt_el_state_ch | control_task_msg_evt_el_state_ch_t |
Enumeration for control task message events to HAL. | |
typedef enum __packed control_task_msg_evt_to_ble | control_task_msg_evt_to_ble_t |
Enumeration for control task message events to BLE. | |
typedef enum __packed control_task_msg_evt_system | control_task_msg_evt_system_t |
Enumeration for control task system events. | |
typedef enum __packed control_task_msg_evt_config | control_task_msg_evt_config_t |
Enumeration for control task config srv events. | |
typedef enum __packed control_task_msg_evt_provision | control_task_msg_evt_provision_t |
Enumeration for control task provisioning events. | |
typedef enum __packed control_task_msg_evt_txcm | control_task_msg_evt_txcm_t |
Enumeration for control task TXCM events. | |
typedef 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. | |
typedef struct control_task_msg | control_task_msg_t |
Structure for control task message. | |
typedef struct control_task_evt_cb_reg | control_task_evt_cb_reg_t |
Structure for control task event callback registration. | |
Enumerations | |
enum | control_task_msg_code { CONTROL_TASK_MSG_CODE_EL_STATE_CH , CONTROL_TASK_MSG_CODE_SYSTEM , CONTROL_TASK_MSG_CODE_TO_BLE , CONTROL_TASK_MSG_CODE_FRM_BLE , CONTROL_TASK_MSG_CODE_CONFIG , CONTROL_TASK_MSG_CODE_PROVISION , CONTROL_TASK_MSG_CODE_TO_APP , CONTROL_TASK_MSG_CODE_TO_MESHX , CONTROL_TASK_MSG_CODE_TXCM , CONTROL_TASK_MSG_CODE_MAX } |
Enumeration for control task message codes. More... | |
Functions | |
meshx_err_t | create_control_task (dev_struct_t *pdev) |
Create the control task. | |
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. | |
meshx_err_t | control_task_msg_unsubscribe (control_task_msg_code_t msg_code, control_task_msg_evt_t evt_bmap, control_task_msg_handle_t callback) |
Deregister a callback for a specific message code and event bitmap. | |
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. | |
Header file for the control task in the BLE mesh node application.
Copyright © 2024 - 2025 MeshX
This file contains the definitions and function prototypes for the control task, which handles various control messages and events in the BLE mesh node application.
Definition in file meshx_control_task.h.
#define CONFIG_CONTROL_TASK_NAME "meshx_control_task" |
Control task name configuration.
Definition at line 26 of file meshx_control_task.h.
#define CONFIG_CONTROL_TASK_PRIO configTIMER_TASK_PRIORITY + 1 |
Control task priority configuration.
Definition at line 32 of file meshx_control_task.h.
#define CONFIG_CONTROL_TASK_QUEUE_LEN 10 |
Control task queue length configuration.
Definition at line 46 of file meshx_control_task.h.
#define CONFIG_CONTROL_TASK_STACK_SIZE 4096 |
Control task stack size configuration.
Definition at line 39 of file meshx_control_task.h.
typedef struct control_task_evt_cb_reg control_task_evt_cb_reg_t |
Structure for control task event callback registration.
typedef enum control_task_msg_code control_task_msg_code_t |
Enumeration for control task message codes.
typedef enum __packed control_task_msg_evt_config control_task_msg_evt_config_t |
Enumeration for control task config srv events.
typedef enum __packed control_task_msg_evt_el_state_ch control_task_msg_evt_el_state_ch_t |
Enumeration for control task message events to HAL.
typedef enum __packed control_task_msg_evt_provision control_task_msg_evt_provision_t |
Enumeration for control task provisioning events.
typedef enum __packed control_task_msg_evt_system control_task_msg_evt_system_t |
Enumeration for control task system events.
typedef uint32_t control_task_msg_evt_t |
Type definition for control task message event.
Definition at line 69 of file meshx_control_task.h.
typedef enum __packed control_task_msg_evt_to_app_meshx control_task_msg_evt_to_app_meshx_t |
Enumeration for control task message events to application.
typedef enum __packed control_task_msg_evt_to_ble control_task_msg_evt_to_ble_t |
Enumeration for control task message events to BLE.
typedef enum __packed control_task_msg_evt_txcm control_task_msg_evt_txcm_t |
Enumeration for control task TXCM events.
typedef 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.
pdev | Pointer to the device structure. |
evt | Event code. |
params | Pointer to the event parameters. |
Definition at line 171 of file meshx_control_task.h.
typedef struct control_task_msg control_task_msg_t |
Structure for control task message.
Enumeration for control task message codes.
Definition at line 52 of file meshx_control_task.h.
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.
This function allows you to publish a control task message with the given message code, event, and event parameters. The message will be sent to the control task for processing.
[in] | msg_code | The message code to publish. |
[in] | msg_evt | The event associated with the message. |
[in] | msg_evt_params | Pointer to the event parameters. |
[in] | sizeof_msg_evt_params | Size of the event parameters. |
Definition at line 66 of file meshx_control_task.c.
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.
This function allows you to subscribe to a specific control task message identified by the given message code. When the message is received, the specified callback function will be invoked.
[in] | msg_code | The message code to subscribe to. |
[in] | evt_bmap | The event bitmap associated with the message. |
[in] | callback | The callback function to be called when the message is received. |
Definition at line 122 of file meshx_control_task.c.
meshx_err_t control_task_msg_unsubscribe | ( | control_task_msg_code_t | msg_code, |
control_task_msg_evt_t | evt_bmap, | ||
control_task_msg_handle_t | callback ) |
Deregister a callback for a specific message code and event bitmap.
This function allows deregistering a callback handler for a specific message code and event type.
[in] | msg_code | The message code to deregister the handler for. |
[in] | evt_bmap | Bitmap of events to deregister for. |
[in] | callback | Callback function to deregister. |
Definition at line 152 of file meshx_control_task.c.
meshx_err_t create_control_task | ( | dev_struct_t * | pdev | ) |
Create the control task.
This function creates a FreeRTOS task to handle control events.
[in] | pdev | Pointer to the device structure (dev_struct_t). |
Definition at line 40 of file meshx_control_task.c.
CONTROL_TASK_MSG_EVT_APP_KEY_ADD = MESHX_BIT(0) |
Event for adding an application key.
Definition at line 126 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_APP_KEY_BIND = MESHX_BIT(2) |
Event for binding an application key.
Definition at line 128 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_APP_KEY_DEL = MESHX_BIT(1) |
Event for deleting an application key.
Definition at line 127 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_APP_KEY_UNBIND = MESHX_BIT(3) |
Event for unbinding an application key.
Definition at line 129 of file meshx_control_task.h.
enum __packed control_task_msg_evt_config |
Enumeration for control task config srv events.
Definition at line 124 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_CONFIG_ALL = 0xFF |
Event for all configuration events.
Definition at line 136 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_CTRL = MESHX_BIT(1) |
Control message
Definition at line 77 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_DATA = MESHX_BIT(0) |
Data message
Definition at line 76 of file meshx_control_task.h.
enum __packed control_task_msg_evt_el_state_ch |
Enumeration for control task message events to HAL.
Definition at line 84 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_EL_STATE_CH_MAX |
Maximum HAL event value.
Definition at line 88 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_CTL = MESHX_BIT(1) |
Event to set CTL state.
Definition at line 87 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_ON_OFF = MESHX_BIT(0) |
Event to set on/off state.
Definition at line 86 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_EN_NODE_PROV = MESHX_BIT(7) |
ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT
Definition at line 150 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_IDENTIFY_START = MESHX_BIT(2) |
EESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT
Definition at line 145 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_IDENTIFY_STOP = MESHX_BIT(3) |
ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT
Definition at line 146 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_MAX |
Maximum event value
Definition at line 78 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_NET_KEY_ADD = MESHX_BIT(8) |
Event for adding a network key.
Definition at line 134 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_NET_KEY_DEL = MESHX_BIT(9) |
Event for deleting a network key.
Definition at line 135 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_NODE_RESET = MESHX_BIT(4) |
CONTROL_TASK_MSG_EVT_NODE_RESET
Definition at line 147 of file meshx_control_task.h.
enum __packed control_task_msg_evt_provision |
Enumeration for control task provisioning events.
Definition at line 142 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_PROVISION_ALL = 0xFFFF |
Maximum provisioning event value.
Definition at line 152 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_PROVISION_STOP = MESHX_BIT(1) |
ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT
Definition at line 144 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_PROXY_CONNECT = MESHX_BIT(5) |
ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT
Definition at line 148 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_PROXY_DISCONN = MESHX_BIT(6) |
ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT
Definition at line 149 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_PUB_ADD = MESHX_BIT(6) |
Event for adding a publication.
Definition at line 132 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_PUB_DEL = MESHX_BIT(7) |
Event for deleting a publication.
Definition at line 133 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SUB_ADD = MESHX_BIT(4) |
Event for adding a subscription.
Definition at line 130 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SUB_DEL = MESHX_BIT(5) |
Event for deleting a subscription.
Definition at line 131 of file meshx_control_task.h.
enum __packed control_task_msg_evt_system |
Enumeration for control task system events.
Definition at line 110 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SYSTEM_FRESH_BOOT = MESHX_BIT(8) |
Event to indicate fresh boot
Definition at line 151 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SYSTEM_MAX |
Maximum system event value.
Definition at line 118 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SYSTEM_RESTART = MESHX_BIT(0) |
Event to restart the system.
Definition at line 112 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_ARM = MESHX_BIT(1) |
Event to arm an OS Timer
Definition at line 113 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_DISARM = MESHX_BIT(3) |
Event to stop an OS Timer
Definition at line 115 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_FIRE = MESHX_BIT(4) |
Event to fire timedout OS Timer
Definition at line 116 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_PERIOD = MESHX_BIT(5) |
Event to set timedout OS Timer
Definition at line 117 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_REARM = MESHX_BIT(2) |
Event to re-arm an OS Timer
Definition at line 114 of file meshx_control_task.h.
enum __packed control_task_msg_evt_to_app_meshx |
Enumeration for control task message events to application.
Definition at line 74 of file meshx_control_task.h.
enum __packed control_task_msg_evt_to_ble |
Enumeration for control task message events to BLE.
Definition at line 94 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL = MESHX_BIT(1) |
Event to set CTL state.
Definition at line 98 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL_SRV = MESHX_BIT(17) |
Event to send out CTL status
Definition at line 103 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_TO_BLE_SET_LIGHTNESS = MESHX_BIT(2) |
Event to set lightness state.
Definition at line 99 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF = MESHX_BIT(0) |
Event to set on/off state.
Definition at line 97 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF_SRV = MESHX_BIT(16) |
Event to send out on/off status
Definition at line 102 of file meshx_control_task.h.
enum __packed control_task_msg_evt_txcm |
Enumeration for control task TXCM events.
Definition at line 158 of file meshx_control_task.h.
CONTROL_TASK_MSG_EVT_TXCM_MSG_TIMEOUT = MESHX_BIT(1) |
Event for TXCM message timeout
Definition at line 160 of file meshx_control_task.h.