81 lines
2.9 KiB
C++
81 lines
2.9 KiB
C++
#include "esp32_presense.h"
|
|
|
|
namespace esphome
|
|
{
|
|
namespace esp32_presense
|
|
{
|
|
unsigned int totalSeen = 0;
|
|
unsigned int totalFpSeen = 0;
|
|
unsigned int totalFpQueried = 0;
|
|
unsigned int totalFpReported = 0;
|
|
|
|
|
|
|
|
void ESP32Presense::reportLoop()
|
|
{
|
|
auto copy = BleFingerprintCollection::GetCopy();
|
|
unsigned int count = 0;
|
|
for (auto &i : copy)
|
|
if (i->shouldCount())
|
|
count++;
|
|
sendTelemetry(totalSeen, totalFpSeen, totalFpQueried, totalFpReported, count);
|
|
|
|
auto reported = 0;
|
|
for (auto &f : copy) {
|
|
auto seen = f->getSeenCount();
|
|
if (seen) {
|
|
totalSeen += seen;
|
|
totalFpSeen++;
|
|
}
|
|
|
|
/*
|
|
if (f->hasReport()) {
|
|
if (reportBuffer(f))
|
|
f->clearReport();
|
|
}
|
|
|
|
if (reportDevice(f)) {
|
|
totalFpReported++;
|
|
reported++;
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
|
|
bool ESP32Presense::sendTelemetry(
|
|
unsigned int totalSeen,
|
|
unsigned int totalFpSeen,
|
|
unsigned int totalFpQueried,
|
|
unsigned int totalFpReported,
|
|
unsigned int count
|
|
) {
|
|
this->publish(this->room_ + "/status", "online");
|
|
this->publish(this->room_ + "/max_distance", BleFingerprintCollection::maxDistance);
|
|
this->publish(this->room_ + "/absorption", BleFingerprintCollection::absorption);
|
|
this->publish(this->room_ + "/tx_ref_rssi", BleFingerprintCollection::txRefRssi);
|
|
this->publish(this->room_ + "/rx_adj_rssi", BleFingerprintCollection::rxAdjRssi);
|
|
this->publish(this->room_ + "/query", BleFingerprintCollection::query);
|
|
this->publish(this->room_ + "/include", BleFingerprintCollection::include);
|
|
this->publish(this->room_ + "/exclude", BleFingerprintCollection::exclude);
|
|
this->publish(this->room_ + "/known_macs", BleFingerprintCollection::knownMacs);
|
|
this->publish(this->room_ + "/known_irks", BleFingerprintCollection::knownIrks);
|
|
this->publish(this->room_ + "/count_ids", BleFingerprintCollection::countIds);
|
|
|
|
return true;
|
|
}
|
|
/*
|
|
void ESP32NimbleMQTTRoom::on_result(nimble_distance_custom::NimbleDistanceCustomResult& result)
|
|
{
|
|
auto address = result.address.toString();
|
|
|
|
this->publish_json(
|
|
this->base_topic_ + "/devices/" + address + "/" + this->room_,
|
|
[=](ArduinoJson::JsonObject root) -> void {
|
|
root["id"] = address;
|
|
root["distance"] = result.distance;
|
|
}
|
|
);
|
|
};
|
|
*/
|
|
} // namespace esp32_nimble_tracker
|
|
} // namespace esphome
|