20 lines
644 B
C++
20 lines
644 B
C++
|
#include "esp32_nimble_mqtt_room.h"
|
||
|
|
||
|
namespace esphome
|
||
|
{
|
||
|
namespace esp32_nimble_mqtt_room
|
||
|
{
|
||
|
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
|