IOT-ESP32
sensor.h File Reference

Manage specific capabilities/data types of devices. More...

Typedefs

typedef uint8_t sensor_idx_t
 The device index of the installed sensor. More...
 

Enumerations

enum  contact_t
 contact states More...
 
enum  interface_t
 Sensor physical interfaces. More...
 
enum  motion_t
 motion states More...
 
enum  presence_t
 presence states More...
 
enum  sensor_type_t
 Types of sensors. More...
 
enum  update_scope_t
 Services to provide update scope. More...
 
enum  update_status_t
 State of a requested update/event. More...
 

Functions

const sensor_t * sensor_get_by_type (sensor_type_t)
 Return a sensor type refernce using the string name. More...
 
const sensor_t * sensor_get_by_type_name (attribute_t)
 Get reference to definition of SENSOR_TYPE. More...
 
void sensor_payload_entry_attr (sensor_data_entry_t, char *, sensor_val_type_t, void *)
 Update sensor entry of payload with the primary data. More...
 
void sensor_payload_entry_id (sensor_data_entry_t, uint8_t, sensor_type_t)
 Update sensor entry of payload with device index and type. More...
 
void sensor_payload_entry_tag (sensor_data_entry_t, sensor_tag_t)
 Update sensor entry of payload with 'tags'. More...
 
uint8_t sensor_process_payload (sensor_t *, sensor_multi_data_t *)
 Prepare sensor layer of payload stack. More...
 
void sensor_type_get_name (sensor_type_t, attribute_t)
 Return a usable type string provided a TYPE_ENUM. More...
 

Detailed Description

Manage specific capabilities/data types of devices.

Typedef Documentation

◆ sensor_idx_t

typedef uint16_t sensor_idx_t

The device index of the installed sensor.

Enumeration Type Documentation

◆ sensor_type_t

Types of sensors.

Identifiers for the sensor types or capabilites we support

◆ presence_t

enum presence_t

presence states

State values to represent 'presence'

◆ motion_t

enum motion_t

motion states

State values to represent 'motion'

◆ contact_t

enum contact_t

contact states

State values to represent 'contact'

◆ update_scope_t

Services to provide update scope.

Bitmask representing which service 'scopes' an update belongs to. This will dictate which handlers are called for delivery.

◆ interface_t

Sensor physical interfaces.

Defines what type of interface the sensor type uses on the device. Interfaces must be implementd on the device, and can be reused between sensors. When a device receives its configuration, these are the physical interfaces that will be configured to provide data for the sensor types.

◆ update_status_t

State of a requested update/event.

Track the state of the update for the various scopes provided on the request tracking the delivery lifecycle.

Function Documentation

◆ sensor_process_payload()

uint8_t sensor_process_payload ( sensor_t *  ,
sensor_multi_data_t *   
)

Prepare sensor layer of payload stack.

The payload layer is modified in place for the calling higher order entity

Parameters
sensoraptr to the appropriate sensor index of the originating device
dataone sensor slice from the device payload
Returns
uint8_t

◆ sensor_payload_entry_id()

void sensor_payload_entry_id ( sensor_data_entry_t  ,
uint8_t  ,
sensor_type_t   
)

Update sensor entry of payload with device index and type.

Parameters
entryptr to a sensor entry of a device payload
sensor_indexthe devices index number for this sensor
typethe sensors type

◆ sensor_payload_entry_tag()

void sensor_payload_entry_tag ( sensor_data_entry_t  ,
sensor_tag_t   
)

Update sensor entry of payload with 'tags'.

The 'tags' allow us to tack on additional key/value info to the same entry attribute (data point), providing for any number of dimesions in the time series data.

Parameters
entryptr to a sensor entry of a device payload
tagTag (k/v) to add. sensor_tag_t =~ attribute_t / attribute_t

◆ sensor_payload_entry_attr()

void sensor_payload_entry_attr ( sensor_data_entry_t  ,
char *  ,
sensor_val_type_t  ,
void *   
)

Update sensor entry of payload with the primary data.

Each sensor entry contains only one attribute / value pair which provides the measurement output. The sensor may provide several entries from a reading, each representing a unique measurement.

Parameters
entryptr to a sensor entry of a device payload
attrthe string which describe the unie of measurement receieved
val_typehow to interpret the value represented in binary
valthe value as a stdint type up to 32-bits

◆ sensor_type_get_name()

void sensor_type_get_name ( sensor_type_t  ,
attribute_t   
)

Return a usable type string provided a TYPE_ENUM.

Necessary evil for the ability to serialize between services without coupling.

Parameters
type
Returns
const sensor_t*

◆ sensor_get_by_type_name()

const sensor_t * sensor_get_by_type_name ( attribute_t  )

Get reference to definition of SENSOR_TYPE.

Parameters
type
Returns
const sensor_t*

◆ sensor_get_by_type()

const sensor_t * sensor_get_by_type ( sensor_type_t  )

Return a sensor type refernce using the string name.

Necessary evil for the ability to serialize between services without coupling.

Parameters
typestring representation of the type (sensor.type)
Returns
const sensor_t*