From 103ba4c696361d1f34a9b071c7175e5be63f205d Mon Sep 17 00:00:00 2001 From: JonasEr <8407728+JonasEr@users.noreply.github.com> Date: Wed, 15 Sep 2021 01:06:43 +0300 Subject: [PATCH] Bug fix of NFC message & records becoming inaccessible in on_tag lambdas (#2309) --- esphome/components/nfc/ndef_message.h | 4 ++-- esphome/components/nfc/nfc_tag.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/nfc/ndef_message.h b/esphome/components/nfc/ndef_message.h index d2ffa9582e..20140e8c1a 100644 --- a/esphome/components/nfc/ndef_message.h +++ b/esphome/components/nfc/ndef_message.h @@ -22,7 +22,7 @@ class NdefMessage { } } - const std::vector> &get_records() { return this->records_; }; + const std::vector> &get_records() { return this->records_; }; bool add_record(std::unique_ptr record); bool add_text_record(const std::string &text); @@ -32,7 +32,7 @@ class NdefMessage { std::vector encode(); protected: - std::vector> records_; + std::vector> records_; }; } // namespace nfc diff --git a/esphome/components/nfc/nfc_tag.h b/esphome/components/nfc/nfc_tag.h index ab6ca650e4..2dfc431428 100644 --- a/esphome/components/nfc/nfc_tag.h +++ b/esphome/components/nfc/nfc_tag.h @@ -43,13 +43,13 @@ class NfcTag { std::vector &get_uid() { return this->uid_; }; const std::string &get_tag_type() { return this->tag_type_; }; bool has_ndef_message() { return this->ndef_message_ != nullptr; }; - const std::unique_ptr &get_ndef_message() { return this->ndef_message_; }; + const std::shared_ptr &get_ndef_message() { return this->ndef_message_; }; void set_ndef_message(std::unique_ptr ndef_message) { this->ndef_message_ = std::move(ndef_message); }; protected: std::vector uid_; std::string tag_type_; - std::unique_ptr ndef_message_; + std::shared_ptr ndef_message_; }; } // namespace nfc