10#ifndef M5_UNIT_RFID_UHF_UHF_LAYER_HPP
11#define M5_UNIT_RFID_UHF_UHF_LAYER_HPP
26using Result = m5::stl::expected<void, Reason>;
59 bool detect(std::vector<Tag>& tags,
const uint32_t timeout_ms = 1000U);
75 bool detect(
Tag& tag,
const uint32_t timeout_ms = 500U);
96 bool select(
const Tag& tag,
const uint32_t access_password = 0,
const bool verify =
true);
98 bool select(
const Epc& epc,
const uint32_t access_password = 0,
const bool verify =
true);
115 bool select(
const Tid& tid,
const uint32_t access_password = 0,
const bool verify =
true);
121 return _has_selection;
165 bool dump(
const Bank bank,
const uint16_t word_address,
const uint16_t words);
180 Result readBank(std::vector<uint8_t>& out,
const Bank bank,
const uint16_t word_address,
const uint16_t word_count);
192 Result readBank(uint8_t* out, uint16_t& out_len,
const Bank bank,
const uint16_t word_address,
193 const uint16_t word_count);
211 Result writeBank(
const Bank bank,
const uint16_t word_address,
const uint8_t* data,
const uint16_t data_len);
223 Result lock(
const std::vector<LockSetting>& settings,
const bool allow_permanent =
false);
247 const uint8_t block_range = 1);
262 const uint16_t block_pointer = 0,
const uint8_t block_range = 1);
342 bool apply_selection(
const Bank bank,
const uint32_t pointer_bits,
const uint8_t* mask,
const size_t mask_len,
343 const uint32_t access_password,
const bool verify);
345 bool verify_selection();
347 void drop_selection_if_mask_rewritten(
const Bank bank);
349 bool reapply_selection();
351 uint16_t bank_words(
const Bank bank);
353 bool dump_words(
const char* what,
const Bank bank,
const uint16_t word_address,
const uint16_t words);
369 bool pause_polling();
371 void resume_polling();
375 uint32_t _access_password{};
377 Bank _mask_bank{Bank::Epc};
378 bool _has_selection{};
380 bool _resume_polling{};
EPC Gen2 semantics layer for UHF-RFID reader units.
Definition uhf_layer.hpp:39
bool nxpEASAlarm(std::vector< uint8_t > &alarm)
Ask the field whether any tag has its Product Status Flag asserted.
Definition uhf_layer.cpp:755
Result readBlockPermalock(std::vector< uint8_t > &mask, const Bank bank, const uint16_t block_pointer=0, const uint8_t block_range=1)
Read which blocks of a bank the selected tag has permanently locked.
Definition uhf_layer.cpp:567
Result toggleNxpConfigWord(uint16_t &config, const uint16_t toggle)
Invert bits of the Config-Word of an NXP UCODE G2X.
Definition uhf_layer.cpp:718
Result kill(const Tag &tag, const uint32_t kill_password)
Kill a tag permanently.
Definition uhf_layer.cpp:674
Result lock(const std::vector< LockSetting > &settings, const bool allow_permanent=false)
Change the lock state of memory banks and passwords.
Definition uhf_layer.cpp:522
Result nxpReadProtect(const bool protect)
Turn the read protection of an NXP UCODE G2X on or off.
Definition uhf_layer.cpp:765
Result writeNxpEAS(const bool enable)
Set or clear the Product Status Flag of an NXP UCODE G2X.
Definition uhf_layer.cpp:737
const Tag & selectedTag() const
The tag currently being addressed.
Definition uhf_layer.hpp:124
Result blockPermalock(const Bank bank, const uint8_t *mask, const size_t mask_len, const bool allow_permanent, const uint16_t block_pointer=0, const uint8_t block_range=1)
Permanently lock blocks of a bank on the selected tag.
Definition uhf_layer.cpp:581
Result readNxpConfigWord(uint16_t &config)
Read the Config-Word of an NXP UCODE G2X.
Definition uhf_layer.cpp:713
bool isSelected() const
Is a tag being addressed?
Definition uhf_layer.hpp:119
Result readQTParameters(QTParameters &qt)
Read the QT control word of the selected tag.
Definition uhf_layer.cpp:604
Result readBank(std::vector< uint8_t > &out, const Bank bank, const uint16_t word_address, const uint16_t word_count)
Read a memory bank.
Definition uhf_layer.cpp:415
bool select(const Tag &tag, const uint32_t access_password=0, const bool verify=true)
Point subsequent tag operations at one tag.
Definition uhf_layer.cpp:197
bool detect(std::vector< Tag > &tags, const uint32_t timeout_ms=1000U)
Detect tags.
Definition uhf_layer.cpp:43
bool deselect()
Stop addressing a single tag, and put polling back the way select() found it.
Definition uhf_layer.cpp:254
bool identify(Tag &tag)
Read the selected tag's TID and fill in what it says about the tag.
Definition uhf_layer.cpp:264
Result writeBank(const Bank bank, const uint16_t word_address, const uint8_t *data, const uint16_t data_len)
Write a memory bank.
Definition uhf_layer.cpp:455
Result writeQTParameters(const QTParameters &qt, const bool persistent=false)
Write the QT control word of the selected tag.
Definition uhf_layer.cpp:630
bool dump()
Dump every memory bank of the selected tag.
Definition uhf_layer.cpp:380
Non-instantiable base class for UHF-RFID reader units.
Definition unit_UHFRFID.hpp:64
Top level namespace of M5Stack.
UHF-RFID (EPC Gen2) related namespace.
EPC of a tag.
Definition uhf.hpp:173
QT control word of an Impinj Monza 4QT.
Definition uhf.hpp:1410
A tag, as the EPC Gen2 standard calls it.
Definition uhf.hpp:366
TID of a tag.
Definition uhf.hpp:213
Common vocabulary for UHF-RFID (EPCglobal UHF Class 1 Gen 2 / ISO 18000-6C)
Bank
EPC Gen2 memory bank.
Definition uhf.hpp:32
m5::stl::expected< void, Reason > Result
What became of an operation that was meant to change a tag.
Definition uhf_layer.hpp:26
Base class for UHF-RFID reader units.
m5::stl::expected< void, uint8_t > TagResult
What became of an operation on a tag.
Definition unit_UHFRFID.hpp:35