15#include <../../include/BLESensor.hpp>
16#include <NimBLEAdvertisedDevice.h>
17#include <MQTTMailer.hpp>
20#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00)>>8) + (((x)&0xFF)<<8))
22#define ENDIAN_CHANGE_U32(x) ((((x)&0xFF000000)>>24) + (((x)&0x00FF0000)>>8)) + ((((x)&0xFF00)<<8) + (((x)&0xFF)<<24))
68 static KKMK6P& getInstance(){
81 std::string
toJSON(
double temp,
double humidity);
88 NimBLEUUID(
"0000fff1-0000-1000-8000-00805f9b34fb"),
89 NimBLEUUID(
"0000feaa-0000-1000-8000-00805f9b34fb")};
96 uint8_t address[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
101 std::stringstream
ss;
114 uint8_t address[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
115 char name[2] = {0x00, 0x00};
122 snprintf(
res,
size,
"%02x:%02x:%02x:%02x:%02x:%02x", address[5], address[4], address[3], address[2], address[1], address[0]);
125 std::stringstream
ss;
126 ss <<
"MAC: " <<
ret <<
", "
127 <<
"Name: "<< name[0] << name[1];
147 std::stringstream
ss;
148 ss <<
"V" << (
int)version <<
".0, "
150 << temp.toString() <<
" C, "
151 << humidity.toString() <<
"%, "
const bool USB_DEBUG
USB serial debugging enabled.
Definition main.cpp:62
std::string toString()
Convert struct members upper and lower to a string double value.
Definition KKM_K6P.hpp:8
#define ENDIAN_CHANGE_U16(x)
< Converts endianess for 16 bit integers
Definition KKM_K6P.hpp:20
Defines a bluetooth low energy (BLE) interface for integrating new sensors into the DG firmware.
Definition BLESensor.hpp:20
Singleton used to identify and parse BLE transmissions from KKMK6P BLE Temperature and Humidity senso...
Definition KKM_K6P.hpp:65
int getVoltage()
Gets the voltage.
Definition KKM_K6P.cpp:116
std::string toJSON(double temp, double humidity)
convert data values to JSON string object
Definition KKM_K6P.cpp:141
bool advertisedDeviceIsK6P(NimBLEAdvertisedDevice *)
Check if the advertised device is a KKMK6P sensor.
Definition KKM_K6P.cpp:11
float getHumidity()
Convert uint16_t from HT_Frame to a float relative humidity value.
Definition KKM_K6P.cpp:99
MQTTMail * parseAdvertisedData(NimBLEAdvertisedDevice *dev)
Retrieve data advertised by the device and save it if of interest.
Definition KKM_K6P.cpp:35
float getTemp()
Convert the uint16_t in HT_Frame to a float temperature value in Celsius.
Definition KKM_K6P.cpp:81
std::string getSensorType()
get the sensor type as a string
Definition KKM_K6P.cpp:137
An object that stores data from which a topic and message can be extracted for publishing to an MQTT ...
Definition MQTTMailer.hpp:37
int reset_count
number of resets retrieved for NVS
Definition scheduler.hpp:31
Defines structure for floating point numbers in dual 8 bit upper/lower format.
Definition KKM_K6P.hpp:44
int8_t upper
the value to the left of the decimal point
Definition KKM_K6P.hpp:45
std::string toString()
Convert struct members upper and lower to a string double value.
Definition KKM_K6P.hpp:53
uint8_t lower
the value to the right of the decimal point
Definition KKM_K6P.hpp:46