Embedded Artistry C Interfaces
A reference collection of abstract interfaces in C.
Public Attributes | List of all members
HumiditySensor_withCb Struct Reference

Virtual Relative Humidity Sensor Interface with Callback Support. More...

#include <humidity_sensor.h>

Public Attributes

bool(* readHumidity )(uint8_t *const humidity)
 Get the current relative humidity. More...
 
void(* registerNewSampleCb )(const NewHumiditySampleCb callback)
 Register a NewHumiditySampleCb function. More...
 
void(* unregisterNewSampleCb )(const NewHumiditySampleCb callback)
 Remove a registered NewHumiditySampleCb function. More...
 
void(* registerErrorCb )(const HumidityErrorCb callback)
 Register a HumidityErrorCb function. More...
 
void(* unregisterErrorCb )(const HumidityErrorCb callback)
 Remove a registered HumidityErrorCb function. More...
 

Detailed Description

Virtual Relative Humidity Sensor Interface with Callback Support.

A standard interface for a device which can measure relative humidity. Interested parties can receive callbacks when new samples are available.

This device returns relative humdity, rounded to the nearest whole percentage.

Fundamental Assumptions

Undesired event assumptions

Implementation Notes

Definition at line 141 of file humidity_sensor.h.

Member Data Documentation

◆ readHumidity

bool(* HumiditySensor_withCb::readHumidity) (uint8_t *const humidity)

Get the current relative humidity.

Precondition
The sensor has been properly initialized by the system.
Postcondition
If the measurement is valid and the humidity parameter is not NULL, the data pointed to will be updated with the latest reading
If the measurement is invalid, the data pointed to by the humidity parameter will remain unchanged.
If the measurement is valid, registered New Sample callbacks will be invoked or dispatched with the new measurement.
If the measurement is not valid, registered Error callbacks will be invoked or dispatched.
Parameters
[in,out]humidityCurrent relative humidity in %. If humidity is NULL, the function will only supply the humidity sample to registered callback functions.

Humidity is specified as an integral perecentage.

Returns
True if the sample is valid, false if invalid (e.g., an error occured)

Definition at line 163 of file humidity_sensor.h.

◆ registerErrorCb

void(* HumiditySensor_withCb::registerErrorCb) (const HumidityErrorCb callback)

Register a HumidityErrorCb function.

This function will add the callback input to a list of functions to execute when a humidity sensor error occurs.

Precondition
callback is not NULL
Postcondition
callback is added to the list of error callbacks.
Parameters
[in]callbackThe callback function pointer to register on the "error" callback list.

Definition at line 202 of file humidity_sensor.h.

◆ registerNewSampleCb

void(* HumiditySensor_withCb::registerNewSampleCb) (const NewHumiditySampleCb callback)

Register a NewHumiditySampleCb function.

This function will add the callback input to a list of functions to execute when a new and valid sample is available.

Precondition
callback is not NULL
Postcondition
callback is added to the list of "new sample" callbacks.
Parameters
[in]callbackThe callback function pointer to register on the "new sample" callback list.

Definition at line 176 of file humidity_sensor.h.

◆ unregisterErrorCb

void(* HumiditySensor_withCb::unregisterErrorCb) (const HumidityErrorCb callback)

Remove a registered HumidityErrorCb function.

This function will remove a callback function from the registered list of "error" callbacks. If the function has not been previously registered, the parameter will be ignored and the list will be unchanged.

Postcondition
callback function pointer is not present on the list of "error" callbacks.
Parameters
[in]callbackThe callback function pointer to remove from the "error" callback list.

Definition at line 215 of file humidity_sensor.h.

◆ unregisterNewSampleCb

void(* HumiditySensor_withCb::unregisterNewSampleCb) (const NewHumiditySampleCb callback)

Remove a registered NewHumiditySampleCb function.

This function will remove a callback function from the registered list of "new sample" callbacks. If the function has not been previously registered, the parameter will be ignored and the list will be unchanged.

Postcondition
callback function pointer is not present on the list of "new sample" callbacks.
Parameters
[in]callbackThe callback function pointer to remove from the "new sample" callback list.

Definition at line 189 of file humidity_sensor.h.


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