RFID: Change the checkTag fail return
Previously, checkTag() returned 0 when it failed or when there was no changes. This is fine if we are only expecting already programmed tags, but as tags arrive new with blocks zeroed out, which conflicts with the 0 return value. Introduce a new constant to RFID for the return error, -1, and use it instead of 0 everywhere. Update comments and README to highlight this new reserved ID.
This commit is contained in:
parent
2fd1939746
commit
3ee09f284a
4 changed files with 11 additions and 7 deletions
|
@ -32,6 +32,8 @@ struct uidNode {
|
|||
class RFID {
|
||||
public:
|
||||
static constexpr int maxTags = 2;
|
||||
/* Error value returned when checking for new or gone tags. */
|
||||
static constexpr int8_t checkFail = -1;
|
||||
|
||||
/***
|
||||
* Use the main SPI port and NFC chip select by default, but allow choosing
|
||||
|
@ -48,7 +50,8 @@ public:
|
|||
* at a time, another call would be needed to get eventual concurrent events.
|
||||
* This updates the respective lists and returns the ID with the direction
|
||||
* of the change.
|
||||
* @return 0 if no change, ID if new tag detected, ID & sign bit if the tag left.
|
||||
* @return ID if new tag detected, ID & sign bit if the tag left
|
||||
* @return RFID::checkFail if no change or error.
|
||||
*/
|
||||
int8_t checkTags();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue