HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
BaseTemperature Class Referenceabstract

Abstract base class for all temperature sensor implementations. More...

#include <BaseTemperature.h>

Inheritance diagram for BaseTemperature:
[legend]

Public Member Functions

 BaseTemperature (const BaseTemperature &)=delete
 Copy constructor is deleted to avoid copying instances.
 
BaseTemperatureoperator= (const BaseTemperature &)=delete
 Assignment operator is deleted to avoid copying instances.
 
virtual ~BaseTemperature () noexcept=default
 Virtual destructor for proper cleanup of derived classes.
 
bool IsInitialized () const noexcept
 Check if the temperature sensor is initialized.
 
bool EnsureInitialized () noexcept
 Ensures the sensor is initialized (lazy initialization).
 
bool EnsureDeinitialized () noexcept
 Ensures the sensor is deinitialized (lazy deinitialization).
 
hf_temp_state_t GetState () const noexcept
 Get current sensor state.
 
hf_temp_err_t ReadTemperatureCelsius (float *temperature_celsius) noexcept
 Read temperature in Celsius (blocking)
 
hf_temp_err_t ReadTemperature (hf_temp_reading_t *reading) noexcept
 Read temperature with full information (blocking)
 
hf_temp_err_t ReadTemperatureFahrenheit (float *temperature_fahrenheit) noexcept
 Read temperature in Fahrenheit.
 
hf_temp_err_t ReadTemperatureKelvin (float *temperature_kelvin) noexcept
 Read temperature in Kelvin.
 
hf_temp_err_t ReadTemperatureUnit (float *temperature, hf_temp_unit_t unit) noexcept
 Read temperature in specified unit.
 
virtual hf_temp_err_t GetSensorInfo (hf_temp_sensor_info_t *info) const noexcept=0
 Get sensor information.
 
virtual hf_u32_t GetCapabilities () const noexcept=0
 Get sensor capabilities.
 
bool HasCapability (hf_temp_capabilities_t capability) const noexcept
 Check if a specific capability is supported.
 
virtual hf_temp_err_t SetRange (float min_celsius, float max_celsius) noexcept
 Set temperature measurement range (advanced feature)
 
virtual hf_temp_err_t GetRange (float *min_celsius, float *max_celsius) const noexcept
 Get temperature measurement range (advanced feature)
 
virtual hf_temp_err_t SetResolution (float resolution_celsius) noexcept
 Set measurement resolution (advanced feature)
 
virtual hf_temp_err_t GetResolution (float *resolution_celsius) const noexcept
 Get measurement resolution (advanced feature)
 
virtual hf_temp_err_t SetThresholds (float low_threshold_celsius, float high_threshold_celsius) noexcept
 Set temperature thresholds (advanced feature)
 
virtual hf_temp_err_t GetThresholds (float *low_threshold_celsius, float *high_threshold_celsius) const noexcept
 Get temperature thresholds (advanced feature)
 
virtual hf_temp_err_t EnableThresholdMonitoring (hf_temp_threshold_callback_t callback, void *user_data) noexcept
 Enable threshold monitoring (advanced feature)
 
virtual hf_temp_err_t DisableThresholdMonitoring () noexcept
 Disable threshold monitoring (advanced feature)
 
virtual hf_temp_err_t StartContinuousMonitoring (hf_u32_t sample_rate_hz, hf_temp_reading_callback_t callback, void *user_data) noexcept
 Start continuous temperature monitoring (advanced feature)
 
virtual hf_temp_err_t StopContinuousMonitoring () noexcept
 Stop continuous temperature monitoring (advanced feature)
 
virtual bool IsMonitoringActive () const noexcept
 Check if continuous monitoring is active (advanced feature)
 
virtual hf_temp_err_t Calibrate (float reference_temperature_celsius) noexcept
 Perform sensor calibration (advanced feature)
 
virtual hf_temp_err_t SetCalibrationOffset (float offset_celsius) noexcept
 Set calibration offset (advanced feature)
 
virtual hf_temp_err_t GetCalibrationOffset (float *offset_celsius) const noexcept
 Get calibration offset (advanced feature)
 
virtual hf_temp_err_t ResetCalibration () noexcept
 Reset calibration to default (advanced feature)
 
virtual hf_temp_err_t EnterSleepMode () noexcept
 Enter low power mode (advanced feature)
 
virtual hf_temp_err_t ExitSleepMode () noexcept
 Exit low power mode (advanced feature)
 
virtual bool IsSleeping () const noexcept
 Check if sensor is in sleep mode (advanced feature)
 
virtual hf_temp_err_t SelfTest () noexcept
 Perform sensor self-test (advanced feature)
 
virtual hf_temp_err_t CheckHealth () noexcept
 Check sensor health status (advanced feature)
 
virtual hf_temp_err_t GetStatistics (hf_temp_statistics_t &statistics) noexcept
 Get operation statistics (advanced feature)
 
virtual hf_temp_err_t GetDiagnostics (hf_temp_diagnostics_t &diagnostics) noexcept
 Get diagnostic information (advanced feature)
 
virtual hf_temp_err_t ResetStatistics () noexcept
 Reset operation statistics (advanced feature)
 
virtual hf_temp_err_t ResetDiagnostics () noexcept
 Reset diagnostic information (advanced feature)
 

Protected Member Functions

virtual bool Initialize () noexcept=0
 Platform-specific implementation for initialization.
 
virtual bool Deinitialize () noexcept=0
 Platform-specific implementation for deinitialization.
 
virtual hf_temp_err_t ReadTemperatureCelsiusImpl (float *temperature_celsius) noexcept=0
 Platform-specific implementation for reading temperature in Celsius.
 
 BaseTemperature () noexcept
 Protected default constructor.
 
hf_temp_err_t ValidateBasicOperation () const noexcept
 Protected helper to validate basic operation preconditions.
 

Protected Attributes

bool initialized_
 Initialization status.
 
hf_temp_state_t current_state_
 Current sensor state.
 

Detailed Description

Abstract base class for all temperature sensor implementations.

This class defines the common interface that all temperature sensor implementations must follow. It provides a consistent API for temperature measurement, configuration, and monitoring across different sensor types and platforms.

Key features:

  • Abstract interface for temperature reading
  • Standardized error handling
  • Support for various temperature units
  • Threshold monitoring capabilities (advanced feature)
  • Power management support (advanced feature)
  • Calibration interface (advanced feature)
  • Lazy initialization pattern
Note
This is a header-only abstract base class
All concrete implementations must inherit from this class
Thread safety is implementation-dependent
Advanced features return TEMP_ERR_UNSUPPORTED_OPERATION if not supported

Constructor & Destructor Documentation

◆ BaseTemperature() [1/2]

BaseTemperature::BaseTemperature ( const BaseTemperature & )
delete

Copy constructor is deleted to avoid copying instances.

◆ ~BaseTemperature()

virtual BaseTemperature::~BaseTemperature ( )
virtualdefaultnoexcept

Virtual destructor for proper cleanup of derived classes.

◆ BaseTemperature() [2/2]

BaseTemperature::BaseTemperature ( )
inlineprotectednoexcept

Protected default constructor.

Member Function Documentation

◆ Calibrate()

virtual hf_temp_err_t BaseTemperature::Calibrate ( float reference_temperature_celsius)
inlinevirtualnoexcept

Perform sensor calibration (advanced feature)

Parameters
reference_temperature_celsiusKnown reference temperature
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

◆ CheckHealth()

virtual hf_temp_err_t BaseTemperature::CheckHealth ( )
inlinevirtualnoexcept

Check sensor health status (advanced feature)

Returns
Error code (TEMP_SUCCESS if healthy, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ Deinitialize()

virtual bool BaseTemperature::Deinitialize ( )
protectedpure virtualnoexcept

Platform-specific implementation for deinitialization.

Returns
true if deinitialization successful, false otherwise

Implemented in EspTemperature, and StmTemperature.

◆ DisableThresholdMonitoring()

virtual hf_temp_err_t BaseTemperature::DisableThresholdMonitoring ( )
inlinevirtualnoexcept

Disable threshold monitoring (advanced feature)

Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ EnableThresholdMonitoring()

virtual hf_temp_err_t BaseTemperature::EnableThresholdMonitoring ( hf_temp_threshold_callback_t callback,
void * user_data )
inlinevirtualnoexcept

Enable threshold monitoring (advanced feature)

Parameters
callbackCallback function for threshold events
user_dataUser data to pass to callback
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ EnsureDeinitialized()

bool BaseTemperature::EnsureDeinitialized ( )
inlinenoexcept

Ensures the sensor is deinitialized (lazy deinitialization).

Returns
true if deinitialized successfully, false otherwise

◆ EnsureInitialized()

bool BaseTemperature::EnsureInitialized ( )
inlinenoexcept

Ensures the sensor is initialized (lazy initialization).

Returns
true if initialized successfully, false otherwise

◆ EnterSleepMode()

virtual hf_temp_err_t BaseTemperature::EnterSleepMode ( )
inlinevirtualnoexcept

Enter low power mode (advanced feature)

Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ ExitSleepMode()

virtual hf_temp_err_t BaseTemperature::ExitSleepMode ( )
inlinevirtualnoexcept

Exit low power mode (advanced feature)

Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ GetCalibrationOffset()

virtual hf_temp_err_t BaseTemperature::GetCalibrationOffset ( float * offset_celsius) const
inlinevirtualnoexcept

Get calibration offset (advanced feature)

Parameters
offset_celsiusPointer to store calibration offset
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature, and StmTemperature.

◆ GetCapabilities()

virtual hf_u32_t BaseTemperature::GetCapabilities ( ) const
pure virtualnoexcept

Get sensor capabilities.

Returns
Capabilities flags (hf_temp_capabilities_t)

Implemented in EspTemperature, and StmTemperature.

◆ GetDiagnostics()

virtual hf_temp_err_t BaseTemperature::GetDiagnostics ( hf_temp_diagnostics_t & diagnostics)
inlinevirtualnoexcept

Get diagnostic information (advanced feature)

Parameters
diagnosticsReference to diagnostics structure to fill
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ GetRange()

virtual hf_temp_err_t BaseTemperature::GetRange ( float * min_celsius,
float * max_celsius ) const
inlinevirtualnoexcept

Get temperature measurement range (advanced feature)

Parameters
min_celsiusPointer to store minimum temperature
max_celsiusPointer to store maximum temperature
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature, and StmTemperature.

◆ GetResolution()

virtual hf_temp_err_t BaseTemperature::GetResolution ( float * resolution_celsius) const
inlinevirtualnoexcept

Get measurement resolution (advanced feature)

Parameters
resolution_celsiusPointer to store resolution
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ GetSensorInfo()

virtual hf_temp_err_t BaseTemperature::GetSensorInfo ( hf_temp_sensor_info_t * info) const
pure virtualnoexcept

Get sensor information.

Parameters
infoPointer to store sensor information
Returns
Error code (TEMP_SUCCESS on success)

Implemented in EspTemperature, and StmTemperature.

◆ GetState()

hf_temp_state_t BaseTemperature::GetState ( ) const
inlinenoexcept

Get current sensor state.

Returns
Current sensor state

◆ GetStatistics()

virtual hf_temp_err_t BaseTemperature::GetStatistics ( hf_temp_statistics_t & statistics)
inlinevirtualnoexcept

Get operation statistics (advanced feature)

Parameters
statisticsReference to statistics structure to fill
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ GetThresholds()

virtual hf_temp_err_t BaseTemperature::GetThresholds ( float * low_threshold_celsius,
float * high_threshold_celsius ) const
inlinevirtualnoexcept

Get temperature thresholds (advanced feature)

Parameters
low_threshold_celsiusPointer to store low threshold
high_threshold_celsiusPointer to store high threshold
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ HasCapability()

bool BaseTemperature::HasCapability ( hf_temp_capabilities_t capability) const
inlinenoexcept

Check if a specific capability is supported.

Parameters
capabilityCapability to check
Returns
true if supported, false otherwise

◆ Initialize()

virtual bool BaseTemperature::Initialize ( )
protectedpure virtualnoexcept

Platform-specific implementation for initialization.

Returns
true if initialization successful, false otherwise

Implemented in EspTemperature, and StmTemperature.

◆ IsInitialized()

bool BaseTemperature::IsInitialized ( ) const
inlinenoexcept

Check if the temperature sensor is initialized.

Returns
true if initialized, false otherwise

◆ IsMonitoringActive()

virtual bool BaseTemperature::IsMonitoringActive ( ) const
inlinevirtualnoexcept

Check if continuous monitoring is active (advanced feature)

Returns
true if monitoring is active, false otherwise

Reimplemented in EspTemperature.

◆ IsSleeping()

virtual bool BaseTemperature::IsSleeping ( ) const
inlinevirtualnoexcept

Check if sensor is in sleep mode (advanced feature)

Returns
true if in sleep mode, false otherwise

Reimplemented in EspTemperature.

◆ operator=()

BaseTemperature & BaseTemperature::operator= ( const BaseTemperature & )
delete

Assignment operator is deleted to avoid copying instances.

◆ ReadTemperature()

hf_temp_err_t BaseTemperature::ReadTemperature ( hf_temp_reading_t * reading)
inlinenoexcept

Read temperature with full information (blocking)

Parameters
readingPointer to store complete reading information
Returns
Error code (TEMP_SUCCESS on success)

◆ ReadTemperatureCelsius()

hf_temp_err_t BaseTemperature::ReadTemperatureCelsius ( float * temperature_celsius)
inlinenoexcept

Read temperature in Celsius (blocking)

Parameters
temperature_celsiusPointer to store temperature value
Returns
Error code (TEMP_SUCCESS on success)

◆ ReadTemperatureCelsiusImpl()

virtual hf_temp_err_t BaseTemperature::ReadTemperatureCelsiusImpl ( float * temperature_celsius)
protectedpure virtualnoexcept

Platform-specific implementation for reading temperature in Celsius.

Parameters
temperature_celsiusPointer to store temperature value
Returns
Error code (TEMP_SUCCESS on success)

Implemented in EspTemperature, and StmTemperature.

◆ ReadTemperatureFahrenheit()

hf_temp_err_t BaseTemperature::ReadTemperatureFahrenheit ( float * temperature_fahrenheit)
inlinenoexcept

Read temperature in Fahrenheit.

Parameters
temperature_fahrenheitPointer to store temperature value
Returns
Error code (TEMP_SUCCESS on success)

◆ ReadTemperatureKelvin()

hf_temp_err_t BaseTemperature::ReadTemperatureKelvin ( float * temperature_kelvin)
inlinenoexcept

Read temperature in Kelvin.

Parameters
temperature_kelvinPointer to store temperature value
Returns
Error code (TEMP_SUCCESS on success)

◆ ReadTemperatureUnit()

hf_temp_err_t BaseTemperature::ReadTemperatureUnit ( float * temperature,
hf_temp_unit_t unit )
inlinenoexcept

Read temperature in specified unit.

Parameters
temperaturePointer to store temperature value
unitDesired temperature unit
Returns
Error code (TEMP_SUCCESS on success)

◆ ResetCalibration()

virtual hf_temp_err_t BaseTemperature::ResetCalibration ( )
inlinevirtualnoexcept

Reset calibration to default (advanced feature)

Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ ResetDiagnostics()

virtual hf_temp_err_t BaseTemperature::ResetDiagnostics ( )
inlinevirtualnoexcept

Reset diagnostic information (advanced feature)

Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ ResetStatistics()

virtual hf_temp_err_t BaseTemperature::ResetStatistics ( )
inlinevirtualnoexcept

Reset operation statistics (advanced feature)

Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ SelfTest()

virtual hf_temp_err_t BaseTemperature::SelfTest ( )
inlinevirtualnoexcept

Perform sensor self-test (advanced feature)

Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ SetCalibrationOffset()

virtual hf_temp_err_t BaseTemperature::SetCalibrationOffset ( float offset_celsius)
inlinevirtualnoexcept

Set calibration offset (advanced feature)

Parameters
offset_celsiusCalibration offset in Celsius
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature, and StmTemperature.

◆ SetRange()

virtual hf_temp_err_t BaseTemperature::SetRange ( float min_celsius,
float max_celsius )
inlinevirtualnoexcept

Set temperature measurement range (advanced feature)

Parameters
min_celsiusMinimum temperature in Celsius
max_celsiusMaximum temperature in Celsius
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature, and StmTemperature.

◆ SetResolution()

virtual hf_temp_err_t BaseTemperature::SetResolution ( float resolution_celsius)
inlinevirtualnoexcept

Set measurement resolution (advanced feature)

Parameters
resolution_celsiusResolution in Celsius
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

◆ SetThresholds()

virtual hf_temp_err_t BaseTemperature::SetThresholds ( float low_threshold_celsius,
float high_threshold_celsius )
inlinevirtualnoexcept

Set temperature thresholds (advanced feature)

Parameters
low_threshold_celsiusLow temperature threshold
high_threshold_celsiusHigh temperature threshold
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ StartContinuousMonitoring()

virtual hf_temp_err_t BaseTemperature::StartContinuousMonitoring ( hf_u32_t sample_rate_hz,
hf_temp_reading_callback_t callback,
void * user_data )
inlinevirtualnoexcept

Start continuous temperature monitoring (advanced feature)

Parameters
sample_rate_hzSampling rate in Hz
callbackCallback function for each reading
user_dataUser data to pass to callback
Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ StopContinuousMonitoring()

virtual hf_temp_err_t BaseTemperature::StopContinuousMonitoring ( )
inlinevirtualnoexcept

Stop continuous temperature monitoring (advanced feature)

Returns
Error code (TEMP_SUCCESS on success, TEMP_ERR_UNSUPPORTED_OPERATION if not supported)

Reimplemented in EspTemperature.

◆ ValidateBasicOperation()

hf_temp_err_t BaseTemperature::ValidateBasicOperation ( ) const
inlineprotectednoexcept

Protected helper to validate basic operation preconditions.

Returns
Error code (TEMP_SUCCESS if valid to proceed)

Member Data Documentation

◆ current_state_

hf_temp_state_t BaseTemperature::current_state_
protected

Current sensor state.

◆ initialized_

bool BaseTemperature::initialized_
protected

Initialization status.


The documentation for this class was generated from the following file: