Skip to content

Commit

Permalink
Rfid: allow optional timepoint to disable rfid events beforehand.
Browse files Browse the repository at this point in the history
+ test update.
  • Loading branch information
PBrunot committed Aug 11, 2024
1 parent e16e3c0 commit bca7140
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/BaseRfidWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tasks::time_point> t) -> void = 0;
};
} // namespace fabomatic
#endif // BASERFIDWRAPPER_HPP_
2 changes: 1 addition & 1 deletion include/RFIDWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tasks::time_point> delay) -> void override;

/// @brief Returns the driver object for testing/simulation
Driver &getDriver();
Expand Down
2 changes: 1 addition & 1 deletion src/RFIDWrapper.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace fabomatic
}

template <typename Driver>
[[nodiscard]] auto RFIDWrapper<Driver>::setDisabledUntil(fabomatic::Tasks::time_point delay) -> void
[[nodiscard]] auto RFIDWrapper<Driver>::setDisabledUntil(std::optional<Tasks::time_point> delay) -> void
{
this->disabledUntil = delay;
}
Expand Down
5 changes: 4 additions & 1 deletion test/test_logic/test_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ namespace fabomatic::tests
std::optional<std::chrono::milliseconds> 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++)
{
Expand All @@ -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)
{
Expand Down

0 comments on commit bca7140

Please sign in to comment.