|
MeshX 0.4
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 + 2 |
| Control task priority configuration. | |
| #define | CONFIG_MESHX_LOG_TASK_PRIO configTIMER_TASK_PRIORITY + 1 |
| Logging task priority configuration. | |
| #define | CONFIG_CONTROL_TASK_STACK_SIZE 8192 |
| 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_PROV_PLAT , 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 | control_task_init (void) |
| Initialize the control task messaging system. | |
| 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.
| #define CONFIG_CONTROL_TASK_NAME "meshx_control_task" |
Control task name configuration.
| #define CONFIG_CONTROL_TASK_PRIO configTIMER_TASK_PRIORITY + 2 |
Control task priority configuration.
| #define CONFIG_CONTROL_TASK_QUEUE_LEN 10 |
Control task queue length configuration.
| #define CONFIG_CONTROL_TASK_STACK_SIZE 8192 |
Control task stack size configuration.
| #define CONFIG_MESHX_LOG_TASK_PRIO configTIMER_TASK_PRIORITY + 1 |
Logging task priority configuration.
| 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.
| 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. |
| typedef struct control_task_msg control_task_msg_t |
Structure for control task message.
Enumeration for control task message codes.
| meshx_err_t control_task_init | ( | void | ) |
Initialize the control task messaging system.
This function initializes the message queue used by the control task. It must be called before any component attempts to publish messages.
| 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. |
| 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. |
| 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. |
| 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). |
| CONTROL_TASK_MSG_EVT_APP_KEY_ADD = (1UL << (0)) |
Event for adding an application key.
| CONTROL_TASK_MSG_EVT_APP_KEY_BIND = (1UL << (2)) |
Event for binding an application key.
| CONTROL_TASK_MSG_EVT_APP_KEY_DEL = (1UL << (1)) |
Event for deleting an application key.
| CONTROL_TASK_MSG_EVT_APP_KEY_UNBIND = (1UL << (3)) |
Event for unbinding an application key.
| enum __packed control_task_msg_evt_config |
Enumeration for control task config srv events.
| CONTROL_TASK_MSG_EVT_CONFIG_ALL = 0xFF |
Event for all configuration events.
| CONTROL_TASK_MSG_EVT_CTRL = (1UL << (1)) |
Control message
| CONTROL_TASK_MSG_EVT_DATA = (1UL << (0)) |
Data message
| enum __packed control_task_msg_evt_el_state_ch |
Enumeration for control task message events to HAL.
| CONTROL_TASK_MSG_EVT_EL_STATE_CH_MAX |
Maximum HAL event value.
| CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_CTL = (1UL << (1)) |
Event to set CTL state.
| CONTROL_TASK_MSG_EVT_EL_STATE_CH_SET_ON_OFF = (1UL << (0)) |
Event to set on/off state.
| CONTROL_TASK_MSG_EVT_EN_NODE_PROV = (1UL << (8)) |
ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT
| CONTROL_TASK_MSG_EVT_IDENTIFY_START = (1UL << (3)) |
EESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT
| CONTROL_TASK_MSG_EVT_IDENTIFY_STOP = (1UL << (4)) |
ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT
| CONTROL_TASK_MSG_EVT_MAX |
Maximum event value
| CONTROL_TASK_MSG_EVT_NET_KEY_ADD = (1UL << (8)) |
Event for adding a network key.
| CONTROL_TASK_MSG_EVT_NET_KEY_DEL = (1UL << (9)) |
Event for deleting a network key.
| CONTROL_TASK_MSG_EVT_NODE_RESET = (1UL << (5)) |
CONTROL_TASK_MSG_EVT_NODE_RESET
| CONTROL_TASK_MSG_EVT_PROV_REG_COMP = (1UL << (0)) |
ESP_BLE_MESH_PROV_REGISTER_COMP_EVT
| enum __packed control_task_msg_evt_provision |
Enumeration for control task provisioning events.
| CONTROL_TASK_MSG_EVT_PROVISION_ALL = 0xFFFF |
Maximum provisioning event value.
| CONTROL_TASK_MSG_EVT_PROVISION_STOP = (1UL << (2)) |
ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT
| CONTROL_TASK_MSG_EVT_PROXY_CONNECT = (1UL << (6)) |
ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT
| CONTROL_TASK_MSG_EVT_PROXY_DISCONN = (1UL << (7)) |
ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT
| CONTROL_TASK_MSG_EVT_PUB_ADD = (1UL << (6)) |
Event for adding a publication.
| CONTROL_TASK_MSG_EVT_PUB_DEL = (1UL << (7)) |
Event for deleting a publication.
| CONTROL_TASK_MSG_EVT_SET_NAME_COMP = (1UL << (1)) |
ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT
| CONTROL_TASK_MSG_EVT_SUB_ADD = (1UL << (4)) |
Event for adding a subscription.
| CONTROL_TASK_MSG_EVT_SUB_DEL = (1UL << (5)) |
Event for deleting a subscription.
| enum __packed control_task_msg_evt_system |
Enumeration for control task system events.
| CONTROL_TASK_MSG_EVT_SYSTEM_FRESH_BOOT = (1UL << (9)) |
Event to indicate fresh boot
| CONTROL_TASK_MSG_EVT_SYSTEM_MAX |
Maximum system event value.
| CONTROL_TASK_MSG_EVT_SYSTEM_NVS_COMMIT = (1UL << (6)) |
Event for NVS commit operation
| CONTROL_TASK_MSG_EVT_SYSTEM_RESTART = (1UL << (0)) |
Event to restart the system.
| CONTROL_TASK_MSG_EVT_SYSTEM_STACK_READY = (1UL << (10)) |
Event to indicate stack is ready for TX
| CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_ARM = (1UL << (1)) |
Event to arm an OS Timer
| CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_DISARM = (1UL << (3)) |
Event to stop an OS Timer
| CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_FIRE = (1UL << (4)) |
Event to fire timedout OS Timer
| CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_PERIOD = (1UL << (5)) |
Event to set timedout OS Timer
| CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_REARM = (1UL << (2)) |
Event to re-arm an OS Timer
| enum __packed control_task_msg_evt_to_app_meshx |
Enumeration for control task message events to application.
| enum __packed control_task_msg_evt_to_ble |
Enumeration for control task message events to BLE.
| CONTROL_TASK_MSG_EVT_TO_BLE_SENSOR_SRV = (1UL << (18)) |
Event to send out Sensor status
| CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL = (1UL << (1)) |
Event to set CTL state.
| CONTROL_TASK_MSG_EVT_TO_BLE_SET_CTL_SRV = (1UL << (17)) |
Event to send out CTL status
| CONTROL_TASK_MSG_EVT_TO_BLE_SET_LIGHTNESS = (1UL << (2)) |
Event to set lightness state.
| CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF = (1UL << (0)) |
Event to set on/off state.
| CONTROL_TASK_MSG_EVT_TO_BLE_SET_ON_OFF_SRV = (1UL << (16)) |
Event to send out on/off status
| enum __packed control_task_msg_evt_txcm |
Enumeration for control task TXCM events.
| CONTROL_TASK_MSG_EVT_TXCM_MSG_TIMEOUT = (1UL << (1)) |
Event for TXCM message timeout