TinyMeasurement HEADER FILE¶
Info
This is the main header file of the TinyMeasurement library. It includes all necessary header files and provides a unified interface to use the functions of the library. After completing the porting of this library in the project, you can insert this header file where you want to use the relevant functions to use all functions in the library. The documentation update speed is slow and may not be consistent with the actual code, please refer to the actual code.
OVERVIEW¶
The tiny_measurement.h header file serves as the unified entry point for all measurement functionality in the TinyMeasurement middleware. By including this single header file, you gain access to:
- Online Sensing: Real-time continuous sensor data acquisition with configurable sampling rates, supporting MQTT transmission, serial output, and optional LCD display
- Offline Sensing: High-frequency batch data collection for detailed analysis, with support for memory buffer and SD card storage
- Real-Time Processing Architecture: High-performance real-time data processing with three architecture options (Producer-Consumer, DMA + Double Buffer, DMA + Dual Core)
- Command Handler: MQTT-based remote control interface for managing sensing operations
MODULE STRUCTURE¶
The header file organizes functionality into four main modules, each with its own sub-header file that is automatically included when you include tiny_measurement.h.
The following diagram illustrates the module hierarchy and dependencies:
tiny_measurement_config.h
(Configuration & Macros)
|
+------------------+------------------+------------------+
| | | |
v v v v
online_sensing.h offline_sensing.h real-time-process-arch.h sensing_command.h
(Online Sensing) (Offline Sensing) (RT Processing) (Command Handler)
| | | |
+------------------+------------------+------------------+
|
v
tiny_measurement.h
(Unified Entry Point)
Structure Explanation:
-
tiny_measurement_config.h: The foundation configuration file that defines all default settings and macros. It is included by all sub-modules.
-
Sub-modules: Four independent modules that depend on the configuration:
online_sensing.h: Real-time continuous data acquisitionoffline_sensing.h: High-frequency batch data collectionreal-time-process-arch.h: Real-time data processing with three architecture optionssensing_command.h: MQTT command handling interface
-
tiny_measurement.h: The main header file that includes the configuration and all four sub-modules, providing a unified interface for the entire measurement system.
CODE¶
/**
* @file tiny_measurement.h
* @author SHUAIWEN CUI (SHUAIWEN001@e.ntu.edu.sg)
* @brief tiny_measurement | Main header file - Unified entry point for all measurement functionality
* @version 1.0
* @date 2025-12-17
* @copyright Copyright (c) 2025
*
* @details
* This header file provides a unified interface to all measurement functionality
* in the tiny_measurement middleware. It includes:
*
* - Online Sensing: Continuous sensor data acquisition and transmission
* - Offline Sensing: Batch data collection and processing
* - Real-Time Processing Architecture: High-performance real-time data processing
* - Command Handler: MQTT remote control command handler for sensing modules
*
* Usage:
* Simply include this header to access all measurement functions:
* @code
* #include "tiny_measurement.h"
* @endcode
*/
#pragma once
/* ============================================================================
* DEPENDENCIES
* ============================================================================ */
// Core configuration
#include "tiny_measurement_config.h"
/* ============================================================================
* ONLINE SENSING MODULES
* ============================================================================ */
/**
* @name Online Sensing
* @brief Continuous sensor data acquisition and transmission
* @details
* - Configurable sampling frequency
* - MQTT transmission support
* - Serial output support
* - Online data streaming
*/
#include "online_sensing.h"
/* ============================================================================
* OFFLINE SENSING MODULES
* ============================================================================ */
/**
* @name Offline Sensing
* @brief High-frequency batch sensor data acquisition and storage
* @details
* - High-frequency sampling (default: 100 Hz)
* - Configurable sampling duration
* - Memory buffer storage
* - SD card storage
* - MQTT report after sampling
*/
#include "offline_sensing.h"
/* ============================================================================
* COMMAND HANDLER MODULE
* ============================================================================ */
/**
* @name Sensing Command Handler
* @brief MQTT remote control command handler for sensing modules
* @details
* - Parse and execute MQTT commands
* - Control online and offline sensing
* - Support for scheduled and delayed sensing
*/
#include "sensing_command.h"
/* ============================================================================
* REAL-TIME PROCESSING ARCHITECTURE MODULE
* ============================================================================ */
/**
* @name Real-Time Processing Architecture
* @brief High-performance real-time data processing architectures
* @details
* Provides three real-time processing architectures:
* - Producer-Consumer Queue: Simple queue-based architecture with circular buffer
* - DMA + Double Buffer: DMA-accelerated double buffering with multi-task support
* - DMA + Dual Core Division: Dual-core parallel processing with DMA acceleration
*
* Features:
* - Configurable sampling frequency
* - Real-time acceleration detection with LCD feedback
* - Circular buffer for historical data access
* - Performance statistics and monitoring
* - Architecture selection at compile time
*
* Architecture Selection:
* Define RT_PROCESS_ARCH_TYPE before including this header:
* @code
* #define RT_PROCESS_ARCH_TYPE RT_ARCH_PRODUCER_CONSUMER
* // or RT_ARCH_DMA_DOUBLE_BUFFER
* // or RT_ARCH_DMA_DUAL_CORE
* #include "tiny_measurement.h"
* @endcode
*/
#include "real-time-process-arch.h"
/* ============================================================================
* C++ COMPATIBILITY
* ============================================================================ */
#ifdef __cplusplus
extern "C"
{
#endif
// All measurement functions are C-compatible and can be called from C++
#ifdef __cplusplus
}
#endif