Bug fix of NFC message & records becoming inaccessible in on_tag lambdas (#2309)

This commit is contained in:
JonasEr 2021-09-15 01:06:43 +03:00 committed by GitHub
parent 5a90b83f63
commit 103ba4c696
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -22,7 +22,7 @@ class NdefMessage {
} }
} }
const std::vector<std::unique_ptr<NdefRecord>> &get_records() { return this->records_; }; const std::vector<std::shared_ptr<NdefRecord>> &get_records() { return this->records_; };
bool add_record(std::unique_ptr<NdefRecord> record); bool add_record(std::unique_ptr<NdefRecord> record);
bool add_text_record(const std::string &text); bool add_text_record(const std::string &text);
@ -32,7 +32,7 @@ class NdefMessage {
std::vector<uint8_t> encode(); std::vector<uint8_t> encode();
protected: protected:
std::vector<std::unique_ptr<NdefRecord>> records_; std::vector<std::shared_ptr<NdefRecord>> records_;
}; };
} // namespace nfc } // namespace nfc

View file

@ -43,13 +43,13 @@ class NfcTag {
std::vector<uint8_t> &get_uid() { return this->uid_; }; std::vector<uint8_t> &get_uid() { return this->uid_; };
const std::string &get_tag_type() { return this->tag_type_; }; const std::string &get_tag_type() { return this->tag_type_; };
bool has_ndef_message() { return this->ndef_message_ != nullptr; }; bool has_ndef_message() { return this->ndef_message_ != nullptr; };
const std::unique_ptr<NdefMessage> &get_ndef_message() { return this->ndef_message_; }; const std::shared_ptr<NdefMessage> &get_ndef_message() { return this->ndef_message_; };
void set_ndef_message(std::unique_ptr<NdefMessage> ndef_message) { this->ndef_message_ = std::move(ndef_message); }; void set_ndef_message(std::unique_ptr<NdefMessage> ndef_message) { this->ndef_message_ = std::move(ndef_message); };
protected: protected:
std::vector<uint8_t> uid_; std::vector<uint8_t> uid_;
std::string tag_type_; std::string tag_type_;
std::unique_ptr<NdefMessage> ndef_message_; std::shared_ptr<NdefMessage> ndef_message_;
}; };
} // namespace nfc } // namespace nfc