mirror of
https://github.com/esphome/esphome.git
synced 2024-06-26 10:35:18 +02:00
* Add macros header with more usable Arduino version defines * Change Arduino version checking to use our version defines * Add missing ESP8266 check * Rename Arduino version macro to ARDUINO_VERSION_CODE * Upgrade clang-tidy to use Arduino 3 * Fix clang-tidy warnings * Upgrade NeoPixelBus to upstream 2.6.7 * Use Arduino-version-appropriate API to set redirect flags * Remove now unnecessary CLANG_TIDY ifdefs * Add preprocessor hackery to avoid including pgmspace.h * Bump base image to 4.1.1 and update lint * Fix nfctag * Fix make_unique ambiguous * Fix ignore name * Fix ambiguous v2 * Remove unused begin * Cast time_t to prevent issues on platforms where time_t is 32bit Co-authored-by: Otto winter <otto@otto-winter.com>
57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include "esphome/core/log.h"
|
|
#include "esphome/core/helpers.h"
|
|
#include "ndef_message.h"
|
|
|
|
namespace esphome {
|
|
namespace nfc {
|
|
|
|
class NfcTag {
|
|
public:
|
|
NfcTag() {
|
|
this->uid_ = {};
|
|
this->tag_type_ = "Unknown";
|
|
};
|
|
NfcTag(std::vector<uint8_t> &uid) {
|
|
this->uid_ = uid;
|
|
this->tag_type_ = "Unknown";
|
|
};
|
|
NfcTag(std::vector<uint8_t> &uid, const std::string &tag_type) {
|
|
this->uid_ = uid;
|
|
this->tag_type_ = tag_type;
|
|
};
|
|
NfcTag(std::vector<uint8_t> &uid, const std::string &tag_type, std::unique_ptr<nfc::NdefMessage> ndef_message) {
|
|
this->uid_ = uid;
|
|
this->tag_type_ = tag_type;
|
|
this->ndef_message_ = std::move(ndef_message);
|
|
};
|
|
NfcTag(std::vector<uint8_t> &uid, const std::string &tag_type, std::vector<uint8_t> &ndef_data) {
|
|
this->uid_ = uid;
|
|
this->tag_type_ = tag_type;
|
|
this->ndef_message_ = std::unique_ptr<NdefMessage>(new NdefMessage(ndef_data));
|
|
};
|
|
NfcTag(const NfcTag &rhs) {
|
|
uid_ = rhs.uid_;
|
|
tag_type_ = rhs.tag_type_;
|
|
if (rhs.ndef_message_ != nullptr)
|
|
ndef_message_ = std::unique_ptr<NdefMessage>(new NdefMessage(*rhs.ndef_message_));
|
|
}
|
|
|
|
std::vector<uint8_t> &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<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); };
|
|
|
|
protected:
|
|
std::vector<uint8_t> uid_;
|
|
std::string tag_type_;
|
|
std::unique_ptr<NdefMessage> ndef_message_;
|
|
};
|
|
|
|
} // namespace nfc
|
|
} // namespace esphome
|