|
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.
|
Implementation of control task for event handling and messaging. More...
#include <meshx_control_task.h>Macros | |
| #define | CONFIG_CT_DEBUG_LOG 0 |
Functions | |
| static void | control_task_handler (void *args) |
| Task handler function for processing control task messages. | |
| static meshx_err_t | create_control_task_msg_q (void) |
| Create the control task message queue. | |
| 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_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. | |
| 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. | |
| static meshx_err_t | control_task_msg_dispatch (dev_struct_t *pdev, control_task_msg_code_t msg_code, control_task_msg_evt_t evt, const void *params) |
| Dispatch a message to the registered callbacks. | |
Variables | |
| static meshx_msg_q_t | control_task_queue |
| Queue handle for control task messages. | |
| static control_task_evt_cb_reg_t * | control_task_msg_code_list_heads [CONTROL_TASK_MSG_CODE_MAX] |
| Linked list heads for registered callbacks per message code. | |
Implementation of control task for event handling and messaging.
Copyright © 2024 - 2025 MeshX
This file contains the implementation of a control task, including functions for creating the task, sending messages, registering message handlers, and handling events. The control task uses FreeRTOS for inter-task communication and event-driven architecture.
| #define CONFIG_CT_DEBUG_LOG 0 |
|
static |
Task handler function for processing control task messages.
This function runs in a loop, receiving messages from the queue and dispatching them to registered handlers. Allocated memory for message parameters is freed after processing.
| [in] | args | Pointer to the device structure (dev_struct_t) passed during task creation. |
| 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.
|
static |
Dispatch a message to the registered callbacks.
This function dispatches a message to the registered handlers based on the message code and event type.
| [in] | pdev | Pointer to the device structure (dev_struct_t). |
| [in] | msg_code | The message code of the received message. |
| [in] | evt | The event type of the received message. |
| [in] | params | Pointer to the message parameters. |
| 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). |
|
static |
Create the control task message queue.
This function initializes the FreeRTOS queue for handling control task messages.
|
static |
Linked list heads for registered callbacks per message code.
|
static |
Queue handle for control task messages.