nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Data Structures | Public Types | Public Member Functions | Static Public Attributes
nrfcxx::sd::EnvSensorBeacon Class Reference

Beacon providing information derived from environmental sensors. More...

#include <nrfcxx/sd/beacon.hpp>

Inheritance diagram for nrfcxx::sd::EnvSensorBeacon:
nrfcxx::sd::Beacon

Data Structures

struct  instance_s
 Generic frame data holder. More...
 
struct  threshold_s
 Thresholds for detecting significant changes in readings. More...
 

Public Types

enum  frame_flag_e : uint8_t {
  FT_FLAG_TEMPERATURE = 0x01, FT_FLAG_HUMIDITY = 0x02, FT_FLAG_ABS_PRESSURE = 0x04, FT_FLAG_DIFF_PRESSURE = 0x08,
  FT_FLAG_IAQ_ECO2 = 0x10, FT_FLAG_IAQ_ETVOC = 0x20, FT_FLAG_LIGHT_INTENSITY = 0x40
}
 Bits used in frame_prefix_s::flags to identify the content of the frame. More...
 
using frame_s = frame_prefix_s
 This sensor uses a variable-content frame where element presence is inferred from frame_prefix_s::flags. More...
 
- Public Types inherited from nrfcxx::sd::Beacon
enum  state_e : uint8_t {
  INVALID = 0, FAILED, INACTIVE, CANCELLED,
  SCHEDULED_PREPARE, SCHEDULED, READY, ACTIVE
}
 Values representing the beacon state. More...
 
using crc_type = uint16_t
 Natively-supported checksum is CRC-16/DNP.
 

Public Member Functions

int significantChange (const instance_s &from, const threshold_s &thr) const
 Assess whether the current instance differs from a previous instance significantly. More...
 
const instance_sinstance () const
 Get a reference to the built-up content. More...
 
EnvSensorBeaconresetInstance ()
 
EnvSensorBeaconaddTemperature (int16_t value_cCel)
 
EnvSensorBeaconaddHumidity (uint16_t value_pptt)
 
EnvSensorBeaconaddAbsPressure (unsigned int value_cPa)
 
EnvSensorBeaconaddDiffPressure (int16_t value_cPa)
 
EnvSensorBeaconaddECO2 (uint16_t value_ppm)
 
EnvSensorBeaconaddETVOC (uint16_t value_ppb)
 
EnvSensorBeaconaddLightIntensity (uint8_t value_1)
 
EnvSensorBeaconaddThermistor (int16_t value_cCel)
 
int finalizeInstance ()
 
- Public Member Functions inherited from nrfcxx::sd::Beacon
virtual ~Beacon ()
 The beacon is stopped on destruction.
 
state_e state () const
 Return the current beacon state. More...
 
int validate () const
 Test whether the beacon is in a valid state. More...
 
unsigned int min_interval_utt () const
 Minimum interval between transmissions, in uptime ticks.
 
unsigned int interval_utt () const
 Current interval between transmissions, in uptime ticks.
 
unsigned int max_interval_utt () const
 Maximum interval between transmissions, in uptime ticks.
 
unsigned int prepare_backoff_utt () const
 Duration before beacon transmission that a pre-transmission notification will occur, in uptime ticks.
 
int set_interval (unsigned int utt)
 Configure a fixed interval. More...
 
int set_interval (unsigned int min_utt, unsigned int max_utt)
 Configure an exponential back-off interval. More...
 
int set_prepare_backoff (notifier_type notify, unsigned int backoff_utt)
 Configure notification that a beacon will transmit soon. More...
 
void set_tx_notify (notifier_type notify)
 Configure notification that a beacon is being sent. More...
 
uint8_t dt_flags () const
 Get the GAP ASD Flags data type value to use in the beacon.
 
void dt_flags (uint8_t v)
 Set the GAP ASD Flags data type value to use in the beacon.
 
int8_t dt_tx_power () const
 Get the GAP ASD Tx Power data type value to use in the beacon.
 
void dt_tx_power (int8_t v)
 Set the GAP ASD Tx Power data type value to use in the beacon.
 
int reset_interval ()
 Reset the interval so the beacon is retransmitted as quickly as possible. More...
 
int activate ()
 Enable the beacon. More...
 
int deactivate ()
 Disable the beacon.
 
unsigned int tx_count () const
 Return the number of transmissions since activation.
 
template<typename FT >
crc_type update_crc (FT *bp)
 Helper to store a checksum immediately following a frame instance. More...
 

Static Public Attributes

static constexpr uint8_t FRAME_TYPE = 2
 Value used for frame_s::frame_type.
 
- Static Public Attributes inherited from nrfcxx::sd::Beacon
static constexpr size_t MAX_MSD_LENGTH = 19 + sizeof(crc_type)
 The maximum length of a Manufacturer Specific Data PDU. More...
 
static constexpr uint16_t COMPANY_ID = -1
 The value to be used as the company ID for manufacturer specific data. More...
 
static constexpr uint8_t APP_FRAME_TYPE_BASE = 0x80
 Minimum value for frame_prefix_s::frame_type available for application beacons. More...
 
static constexpr uint8_t APP_FRAME_TYPE_LIMIT = 0xEF
 Maximum value for frame_prefix_s::frame_type available for application beacons. More...
 
static constexpr uint8_t FRAME_TYPE_TEST = 0xFF
 Frame type reserved for test applications.
 

Additional Inherited Members

- Static Public Member Functions inherited from nrfcxx::sd::Beacon
static const telemetry_state_typetelemetry_state ()
 Access the current telemetry state.
 
static const Beaconactive ()
 
static void set_notify (notifier_type notify)
 Register the notifier that signals application to process a beacon event.
 
static int process_event ()
 Method to be invoked by main loop when a beacon-related event occurs.
 
static int process_completion ()
 Method to be invoked by main loop when the beacon has been transmitted.
 
static void telemetry_state_setup (const systemState::state_type &ss, bool is_reset, bool retained)
 Function to maintain beacon telemetry state across resets. More...
 
- Protected Member Functions inherited from nrfcxx::sd::Beacon
 Beacon ()
 Construct a new beacon.
 
virtual int pre_activate_ ()
 Called by activate() to make sure everything needed for activation is present.
 
crc_type update_crc_ (uint8_t *sp, size_t span)
 Function to calculate a checksum and store it after the data. More...
 

Detailed Description

Beacon providing information derived from environmental sensors.

This beacon is configured with:

The beacon interval should be reset whenever a sensor value differs from the value sent in the last reset by more than some metric-specific limit.

Member Typedef Documentation

◆ frame_s

This sensor uses a variable-content frame where element presence is inferred from frame_prefix_s::flags.

See frame_flag_e for the implicit layout.

Member Enumeration Documentation

◆ frame_flag_e

Bits used in frame_prefix_s::flags to identify the content of the frame.

Bits are to be read from LSB up. If the bit is clear, the corresponding element is not present in the frame. If the bit is set the corresponding element is present in the frame, following all content identified by lower bits.

Following the last optional member there will be:

  • zero or more int16_t values providing thermistor measurements in cCel, with flag values as with FT_FLAG_TEMPERATURE;
  • a CRC-16/DNP checksum.

If there are bits set in frame_prefix_s::flags after the highest bit defined in the decoding application then all content between the last identified member and the checksum should be discarded, as the payload will be carrying data that is probably not thermistor readings.

Note
It should not be assumed that every beacon will contain the same information: if a measurement is not available, it will not be present. However, if thermistors are present the ordinal position for a specific thermistor will be the same across all beacons (i.e. only trailing invalid thermistor measurements will be discarded).
Enumerator
FT_FLAG_TEMPERATURE 

Flag indicating that the frame contains a temperature measurement.

Details:

  • Representation: int16_t LE
  • Units: cCel
  • Valid range: -299.99 Cel to 299.99 Cel

Values with a magnitude at or above 30000 cCel indicate an error reading.

The carried temperature is assumed to be measured at the beacon device.

FT_FLAG_HUMIDITY 

Flag indicating that the frame contains a relative humidity measurement.

Details:

  • Representation: uint16_t LE
  • Units: pptt (parts per ten thousand, or 100 * percent)
  • Valid range: 0.00% to 100.00%

The carried humidity is assumed to be measured at the same location as temperature.

FT_FLAG_ABS_PRESSURE 

Flag indicating that the frame contains an absolute atmospheric pressure measurement.

Details:

  • Representation: uint24_t LE
  • Units: cPa
  • Valid range: 0.0000 hPa to 1258.2911 hPa

Sea-level atmospheric pressure ranges from 870 hPa to 1085 hPa. Altitude variation is roughly 120 hPa per km. US continental altitude ranges from -85 m to 4506 m. Inferred range requirements: 330 hPa to 1095 hPa

FT_FLAG_DIFF_PRESSURE 

Flag indicating that the frame contains a differential pressure measurement.

Details:

  • Representation: int16_t LE
  • Units: cPa
  • Valid range: -299.99 Pa to 299.99 Pa
FT_FLAG_IAQ_ECO2 

Flag indicating that the frame contains an equivalent CO2 air quality measurement.

Details:

  • Representation: uint16_t LE
  • Units: ppm
  • Valid range: 400 .. 32768
FT_FLAG_IAQ_ETVOC 

Flag indicating that the frame contains an equivalent Total Volatile Organic Compound air quality measurement.

Details:

  • Representation: uint16_t LE
  • Units: ppb
  • Valid range: 0 .. 32768
FT_FLAG_LIGHT_INTENSITY 

Flag indicating that the frame contains a relative light intensity measurement that's proportional to the log of lux, but with an unspecified slope and offset.

Details:

  • Representation: uint8_t
  • Units: unspecified
  • Valid range: 0 (complete dark) .. 255 (intense light)

Member Function Documentation

◆ instance()

const instance_s& nrfcxx::sd::EnvSensorBeacon::instance ( ) const
inline

Get a reference to the built-up content.

Content is constructed using resetInstance() followed by various methods like addTemperature(), and finished with finalizeInstance().

◆ significantChange()

int nrfcxx::sd::EnvSensorBeacon::significantChange ( const instance_s from,
const threshold_s thr 
) const

Assess whether the current instance differs from a previous instance significantly.

A change is diagnosed if:

Parameters
froma previous instance against which differences are calculated.
thrthe thresholds for detecting differences.
Returns
zero` iff all measurements are equally present/valid in each instance and the differences are less than the measurement threshold. If a significant change is detected it is indicated by a negative return value.

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