From bca7140c2c2996057103ec9efc8f4fd1cabbd415 Mon Sep 17 00:00:00 2001 From: Pascal Brunot Date: Sun, 11 Aug 2024 22:34:14 +0200 Subject: [PATCH] Rfid: allow optional timepoint to disable rfid events beforehand. + test update. --- include/BaseRfidWrapper.hpp | 2 +- include/RFIDWrapper.hpp | 2 +- src/RFIDWrapper.tpp | 2 +- test/test_logic/test_common.cpp | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/BaseRfidWrapper.hpp b/include/BaseRfidWrapper.hpp index c07b04f3..98788b86 100644 --- a/include/BaseRfidWrapper.hpp +++ b/include/BaseRfidWrapper.hpp @@ -23,7 +23,7 @@ namespace fabomatic virtual auto selfTest() const -> bool = 0; virtual auto reset() const -> void = 0; - virtual auto setDisabledUntil(fabomatic::Tasks::time_point t) -> void = 0; + virtual auto setDisabledUntil(std::optional t) -> void = 0; }; } // namespace fabomatic #endif // BASERFIDWRAPPER_HPP_ \ No newline at end of file diff --git a/include/RFIDWrapper.hpp b/include/RFIDWrapper.hpp index 95cb0261..980dd718 100644 --- a/include/RFIDWrapper.hpp +++ b/include/RFIDWrapper.hpp @@ -47,7 +47,7 @@ namespace fabomatic [[nodiscard]] auto getUid() const -> card::uid_t override; - [[nodiscard]] auto setDisabledUntil(fabomatic::Tasks::time_point delay) -> void override; + [[nodiscard]] auto setDisabledUntil(std::optional delay) -> void override; /// @brief Returns the driver object for testing/simulation Driver &getDriver(); diff --git a/src/RFIDWrapper.tpp b/src/RFIDWrapper.tpp index 29148f8c..0966f210 100644 --- a/src/RFIDWrapper.tpp +++ b/src/RFIDWrapper.tpp @@ -34,7 +34,7 @@ namespace fabomatic } template - [[nodiscard]] auto RFIDWrapper::setDisabledUntil(fabomatic::Tasks::time_point delay) -> void + [[nodiscard]] auto RFIDWrapper::setDisabledUntil(std::optional delay) -> void { this->disabledUntil = delay; } diff --git a/test/test_logic/test_common.cpp b/test/test_logic/test_common.cpp index f613ed76..0ecb4fb2 100644 --- a/test/test_logic/test_common.cpp +++ b/test/test_logic/test_common.cpp @@ -21,7 +21,11 @@ namespace fabomatic::tests std::optional duration_tap) { constexpr auto DEFAULT_CYCLES = 3; + + // Ignore DELAY_BETWEEN_SWEEPS delay between cards events + rfid.setDisabledUntil(std::nullopt); MockMrfc522 &driver = rfid.getDriver(); + driver.resetUid(); for (auto i = 0; i < DEFAULT_CYCLES; i++) { @@ -38,7 +42,6 @@ namespace fabomatic::tests logic.checkRfid(); delay(50); } while (duration_tap.has_value() && fabomatic::Tasks::arduinoNow() - start < duration_tap); - } else if (duration_tap) {