[pn532] Replace millis zero sentinel with optional (#14295)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Jonathan Swoboda
2026-02-25 15:15:49 -05:00
committed by GitHub
parent a60e5c5c4f
commit 2e167835ea
2 changed files with 5 additions and 5 deletions

View File

@@ -308,13 +308,13 @@ void PN532::send_nack_() {
enum PN532ReadReady PN532::read_ready_(bool block) {
if (this->rd_ready_ == READY) {
if (block) {
this->rd_start_time_ = 0;
this->rd_start_time_.reset();
this->rd_ready_ = WOULDBLOCK;
}
return READY;
}
if (!this->rd_start_time_) {
if (!this->rd_start_time_.has_value()) {
this->rd_start_time_ = millis();
}
@@ -324,7 +324,7 @@ enum PN532ReadReady PN532::read_ready_(bool block) {
break;
}
if (millis() - this->rd_start_time_ > 100) {
if (millis() - *this->rd_start_time_ > 100) {
ESP_LOGV(TAG, "Timed out waiting for readiness from PN532!");
this->rd_ready_ = TIMEOUT;
break;
@@ -340,7 +340,7 @@ enum PN532ReadReady PN532::read_ready_(bool block) {
auto rdy = this->rd_ready_;
if (block || rdy == TIMEOUT) {
this->rd_start_time_ = 0;
this->rd_start_time_.reset();
this->rd_ready_ = WOULDBLOCK;
}
return rdy;

View File

@@ -99,7 +99,7 @@ class PN532 : public PollingComponent {
std::vector<nfc::NfcOnTagTrigger *> triggers_ontagremoved_;
nfc::NfcTagUid current_uid_;
nfc::NdefMessage *next_task_message_to_write_;
uint32_t rd_start_time_{0};
optional<uint32_t> rd_start_time_{};
enum PN532ReadReady rd_ready_ { WOULDBLOCK };
enum NfcTask {
READ = 0,