BresserWeatherSensorLW
Bresser 868 MHz Weather Sensor Radio Receiver based on ESP32/RP2040 and SX1262/SX1276/LR1121 - sends data to a LoRaWAN Network
Loading...
Searching...
No Matches
BleSensors Class Reference

BLE Sensor (e.g. thermometer/hygrometer) client. More...

#include <BleSensors.h>

Public Member Functions

 BleSensors (std::vector< std::string > known_sensors, bool(*stopScanCb)()=nullptr)
 Constructor.
 BleSensors (bool(*stopScanCb)()=nullptr)
 Constructor.
void setAddresses (std::vector< std::string > known_sensors)
 Set BLE MAC addresses of known sensors.
void begin (void)
 Initialization.
void clearScanResults (void)
 Delete results from BLEScan buffer to release memory.
unsigned getData (uint32_t duration, bool activeScan=true)
 Get data from sensors by running a BLE scan.
void resetData (void)
 Set sensor data invalid.

Public Attributes

std::vector< ble_sensors_t > data
 Sensor data.

Detailed Description

BLE Sensor (e.g. thermometer/hygrometer) client.

Constructor & Destructor Documentation

◆ BleSensors()

BleSensors::BleSensors ( std::vector< std::string > known_sensors,
bool(* stopScanCb )() = nullptr )
inline

Constructor.

Parameters
known_sensorsVector of BLE MAC addresses of known sensors, e.g. {"11:22:33:44:55:66", "AA:BB:CC:DD:EE:FF"}

Member Function Documentation

◆ getData()

unsigned BleSensors::getData ( uint32_t scanTime,
bool activeScan = true )

Get data from sensors by running a BLE scan.

Get BLE sensor data.

Parameters
durationScan duration in seconds
activeScan0: passive scan / 1: active scan
Returns
Number of known sensors found (max. size of known_sensors vector)

Note: Decoding using TheengsDecoder is performed here after scanning, instead of during the NimBLE callback, to avoid heavy processing in the callback context, which can lead to the watchdog being triggered.

◆ setAddresses()

void BleSensors::setAddresses ( std::vector< std::string > known_sensors)
inline

Set BLE MAC addresses of known sensors.

Parameters
known_sensorsvector of BLE MAC addresses (see constructor)

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