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

Header file for MeshX RTOS Timer interface. Provides APIs for creating, starting, stopping, deleting, and managing RTOS timers in the MeshX framework. More...

#include <stdint.h>
#include <stdbool.h>
#include "meshx_err.h"

Go to the source code of this file.

Data Structures

struct  meshx_rtos_timer

Typedefs

typedef void(* meshx_rtos_timer_callback_t) (void *)
typedef struct meshx_rtos_timer meshx_rtos_timer_t

Functions

meshx_err_t meshx_rtos_timer_create (meshx_rtos_timer_t *timer, const char *name, meshx_rtos_timer_callback_t cb, void *arg, uint32_t period_ms, bool reload)
 Creates a new RTOS timer.
meshx_err_t meshx_rtos_timer_start (meshx_rtos_timer_t *timer)
 Starts the RTOS timer.
meshx_err_t meshx_rtos_timer_stop (meshx_rtos_timer_t *timer)
 Stops the RTOS timer.
meshx_err_t meshx_rtos_timer_delete (meshx_rtos_timer_t *timer)
 Deletes the RTOS timer.
meshx_err_t meshx_rtos_timer_change_period (meshx_rtos_timer_t *timer, uint32_t new_period_ms)
 Changes the period of the RTOS timer.
meshx_err_t meshx_rtos_timer_reset (meshx_rtos_timer_t *timer)
 Resets the RTOS timer.
void meshx_os_timer_fire_cb (const void *timer_handle)

Detailed Description

Header file for MeshX RTOS Timer interface. Provides APIs for creating, starting, stopping, deleting, and managing RTOS timers in the MeshX framework.

Copyright (c) 2024 - 2025 MeshX

This module abstracts the RTOS timer functionalities and provides a unified interface for timer management, including support for auto-reload timers, callback functions, and dynamic period changes.

Author
Pranjal Chanda

Typedef Documentation

◆ meshx_rtos_timer_callback_t

typedef void(* meshx_rtos_timer_callback_t) (void *)

◆ meshx_rtos_timer_t

Function Documentation

◆ meshx_os_timer_fire_cb()

void meshx_os_timer_fire_cb ( const void * timer_handle)
150{
151 meshx_os_timer_t *msg_params;
152 SLIST_FOREACH(msg_params, &meshx_os_timer_reg_table_head, next)
153 {
154 if (msg_params->timer_handle.__timer_handle == timer_handle)
155 {
159 msg_params,
161 break;
162 }
163 }
164}
CONTROL_TASK_MSG_EVT_SYSTEM_TIMER_FIRE
Definition meshx_control_task.h:129
@ CONTROL_TASK_MSG_CODE_SYSTEM
Definition meshx_control_task.h:66
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.
Definition meshx_control_task.c:84
static struct meshx_os_timer_reg_head meshx_os_timer_reg_table_head
Head of the OS timer registration table.
Definition meshx_os_timer.c:44
struct meshx_os_timer meshx_os_timer_t
Alias for the meshx_os_timer structure.
Definition meshx_os_timer.h:47
#define OS_TIMER_SIZE
return meshx_os_timer_t size
Definition meshx_os_timer.h:24
meshx_os_timer_handle_t timer_handle
Definition meshx_os_timer.h:70
void * __timer_handle
Definition meshx_rtos_timer.h:35

◆ meshx_rtos_timer_change_period()

meshx_err_t meshx_rtos_timer_change_period ( meshx_rtos_timer_t * timer,
uint32_t new_period_ms )

Changes the period of the RTOS timer.

This function changes the period of an active or dormant RTOS timer.

Parameters
[in]timerPointer to the meshx_rtos_timer_t structure.
[in]new_period_msNew timer period in milliseconds.
Returns
meshx_err_t Returns MESHX_SUCCESS if the timer period was changed successfully, or an error code if the change operation failed.

◆ meshx_rtos_timer_create()

meshx_err_t meshx_rtos_timer_create ( meshx_rtos_timer_t * timer,
const char * name,
meshx_rtos_timer_callback_t cb,
void * arg,
uint32_t period_ms,
bool reload )

Creates a new RTOS timer.

This function initializes and creates a new RTOS timer with the specified parameters.

Parameters
[out]timerPointer to the meshx_rtos_timer_t structure to be initialized.
[in]nameTimer Name String
[in]cbCallback function to be invoked when the timer expires.
[in]argArgument to be passed to the callback function.
[in]period_msTimer period in milliseconds.
[in]reloadFlag set if timer is a auto reload type.
Returns
meshx_err_t Returns MESHX_SUCCESS if the timer was created successfully, or an error code if the creation failed.

◆ meshx_rtos_timer_delete()

meshx_err_t meshx_rtos_timer_delete ( meshx_rtos_timer_t * timer)

Deletes the RTOS timer.

This function deletes the RTOS timer and frees associated resources.

Parameters
[in]timerPointer to the meshx_rtos_timer_t structure.
Returns
meshx_err_t Returns MESHX_SUCCESS if the timer was deleted successfully, or an error code if the delete operation failed.

◆ meshx_rtos_timer_reset()

meshx_err_t meshx_rtos_timer_reset ( meshx_rtos_timer_t * timer)

Resets the RTOS timer.

This function resets the RTOS timer, causing it to restart from its beginning.

Parameters
[in]timerPointer to the meshx_rtos_timer_t structure.
Returns
meshx_err_t Returns MESHX_SUCCESS if the timer was reset successfully, or an error code if the reset operation failed.

◆ meshx_rtos_timer_start()

meshx_err_t meshx_rtos_timer_start ( meshx_rtos_timer_t * timer)

Starts the RTOS timer.

This function starts the RTOS timer.

Parameters
[in]timerPointer to the meshx_rtos_timer_t structure.
Returns
meshx_err_t Returns MESHX_SUCCESS if the timer was started successfully, or an error code if the start operation failed.

◆ meshx_rtos_timer_stop()

meshx_err_t meshx_rtos_timer_stop ( meshx_rtos_timer_t * timer)

Stops the RTOS timer.

This function stops the RTOS timer.

Parameters
[in]timerPointer to the meshx_rtos_timer_t structure.
Returns
meshx_err_t Returns MESHX_SUCCESS if the timer was stopped successfully, or an error code if the stop operation failed.