Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
SensorData Struct Reference

Generic sensor data structure. More...

#include <ISensor.h>

Public Member Functions

 SensorData ()
 Construct a new SensorData with default values.
bool toJSON (char *buffer, size_t bufferSize) const
 Convert sensor data to JSON string for publishing.

Public Attributes

uint16_t aux1
 Auxiliary numeric field 1.
uint16_t aux2
 Auxiliary numeric field 2.
bool flag1
 Generic boolean flag (e.g., motionDetected, occupied, inRange).
bool flag2
 Spare boolean flag for future use.
bool hasNewData
 Flag indicating if this record contains new data.
uint16_t primary
 Main numeric value (count, distance, faceNumber, ...).
uint16_t secondary
 Secondary numeric value (score, quality, ...).
char sensorType [16]
 Type of sensor ("PIR", "Ultrasonic", etc.).
time_t timestamp
 When the data was captured (Unix time).

Detailed Description

Generic sensor data structure.

This structure is intentionally generic so different sensor types (PIR, ultrasonic, gesture, etc.) can share the same layout. The meaning of each numeric/boolean field is defined by the sensorType string.

Examples:

  • PIR: hasNewData=true when motion edge detected; primary/secondary unused.
  • GestureFace: primary=faceNumber, secondary=faceScore, aux1=gestureType, aux2=gestureScore.
  • Ultrasonic: primary=distance (cm), secondary=signal quality, etc.

Uses only POD types and fixed-size char[] to avoid heap use.

Definition at line 23 of file ISensor.h.

Constructor & Destructor Documentation

◆ SensorData()

SensorData::SensorData ( )
inline

Construct a new SensorData with default values.

Definition at line 54 of file ISensor.h.

References aux1, aux2, flag1, flag2, hasNewData, primary, secondary, sensorType, and timestamp.

Member Function Documentation

◆ toJSON()

bool SensorData::toJSON ( char * buffer,
size_t bufferSize ) const
inline

Convert sensor data to JSON string for publishing.

Parameters
bufferCharacter buffer to write JSON into
bufferSizeSize of the buffer
Returns
true if JSON was created successfully

Definition at line 156 of file ISensor.h.

References aux1, aux2, flag1, flag2, primary, secondary, sensorType, and timestamp.

Member Data Documentation

◆ aux1

uint16_t SensorData::aux1

Auxiliary numeric field 1.

Definition at line 40 of file ISensor.h.

Referenced by SensorData(), and toJSON().

◆ aux2

uint16_t SensorData::aux2

Auxiliary numeric field 2.

Definition at line 43 of file ISensor.h.

Referenced by SensorData(), and toJSON().

◆ flag1

bool SensorData::flag1

Generic boolean flag (e.g., motionDetected, occupied, inRange).

Definition at line 46 of file ISensor.h.

Referenced by SensorData(), and toJSON().

◆ flag2

bool SensorData::flag2

Spare boolean flag for future use.

Definition at line 49 of file ISensor.h.

Referenced by SensorData(), and toJSON().

◆ hasNewData

bool SensorData::hasNewData

Flag indicating if this record contains new data.

Definition at line 31 of file ISensor.h.

Referenced by SensorData().

◆ primary

uint16_t SensorData::primary

Main numeric value (count, distance, faceNumber, ...).

Definition at line 34 of file ISensor.h.

Referenced by SensorData(), and toJSON().

◆ secondary

uint16_t SensorData::secondary

Secondary numeric value (score, quality, ...).

Definition at line 37 of file ISensor.h.

Referenced by SensorData(), and toJSON().

◆ sensorType

char SensorData::sensorType[16]

Type of sensor ("PIR", "Ultrasonic", etc.).

Definition at line 28 of file ISensor.h.

Referenced by SensorData(), and toJSON().

◆ timestamp

time_t SensorData::timestamp

When the data was captured (Unix time).

Definition at line 25 of file ISensor.h.

Referenced by SensorData(), and toJSON().


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