mirror of
https://github.com/esphome/esphome.git
synced 2026-06-02 11:08:06 +08:00
[pn532] Replace millis zero sentinel with optional (#14295)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -308,13 +308,13 @@ void PN532::send_nack_() {
|
|||||||
enum PN532ReadReady PN532::read_ready_(bool block) {
|
enum PN532ReadReady PN532::read_ready_(bool block) {
|
||||||
if (this->rd_ready_ == READY) {
|
if (this->rd_ready_ == READY) {
|
||||||
if (block) {
|
if (block) {
|
||||||
this->rd_start_time_ = 0;
|
this->rd_start_time_.reset();
|
||||||
this->rd_ready_ = WOULDBLOCK;
|
this->rd_ready_ = WOULDBLOCK;
|
||||||
}
|
}
|
||||||
return READY;
|
return READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->rd_start_time_) {
|
if (!this->rd_start_time_.has_value()) {
|
||||||
this->rd_start_time_ = millis();
|
this->rd_start_time_ = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ enum PN532ReadReady PN532::read_ready_(bool block) {
|
|||||||
break;
|
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!");
|
ESP_LOGV(TAG, "Timed out waiting for readiness from PN532!");
|
||||||
this->rd_ready_ = TIMEOUT;
|
this->rd_ready_ = TIMEOUT;
|
||||||
break;
|
break;
|
||||||
@@ -340,7 +340,7 @@ enum PN532ReadReady PN532::read_ready_(bool block) {
|
|||||||
|
|
||||||
auto rdy = this->rd_ready_;
|
auto rdy = this->rd_ready_;
|
||||||
if (block || rdy == TIMEOUT) {
|
if (block || rdy == TIMEOUT) {
|
||||||
this->rd_start_time_ = 0;
|
this->rd_start_time_.reset();
|
||||||
this->rd_ready_ = WOULDBLOCK;
|
this->rd_ready_ = WOULDBLOCK;
|
||||||
}
|
}
|
||||||
return rdy;
|
return rdy;
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class PN532 : public PollingComponent {
|
|||||||
std::vector<nfc::NfcOnTagTrigger *> triggers_ontagremoved_;
|
std::vector<nfc::NfcOnTagTrigger *> triggers_ontagremoved_;
|
||||||
nfc::NfcTagUid current_uid_;
|
nfc::NfcTagUid current_uid_;
|
||||||
nfc::NdefMessage *next_task_message_to_write_;
|
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 PN532ReadReady rd_ready_ { WOULDBLOCK };
|
||||||
enum NfcTask {
|
enum NfcTask {
|
||||||
READ = 0,
|
READ = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user