From 1de13d528f0a8a90c3b9b3f13fd6e7e58d941dd4 Mon Sep 17 00:00:00 2001 From: Bracken Dawson Date: Fri, 29 Oct 2021 20:53:44 +0100 Subject: [PATCH] Opt in to incorrect UIDs rather than correct ones --- mfrc522/mfrc522.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mfrc522/mfrc522.go b/mfrc522/mfrc522.go index 523fba9..f4722b0 100644 --- a/mfrc522/mfrc522.go +++ b/mfrc522/mfrc522.go @@ -46,11 +46,11 @@ type config struct { type configF func(*config) *config -// WithFixedUID sets the card reader to return correct 4-byte UIDs. Without -// this setting 4-byte UIDs will be 5-bytes long with bytes 0 to 3 being the -// correct UID and byte 4 being an XOR of bytes 0 to 3. 7-byte UIDs are correct -// regardless of this configuration. -func WithFixedUID() configF { +// WithBogusUID sets the card reader to return incorrect 4-byte UIDs. In +// version 3.6.12 and earlier this package ruturned 5-bytes for tags with a +// 4-byte UID with bytes 0 to 3 being the correct UID and byte 4 being an XOR +// of bytes 0 to 3. 7-byte UIDs are correct regardless of this configuration. +func WithBogusUID() configF { return func(c *config) *config { c.bogusUID = false return c @@ -79,9 +79,6 @@ func WithSync() configF { func noop() {} // NewSPI creates and initializes the RFID card reader attached to SPI. -// It is recommended to use the WithFixedUID configuration to return correct -// card UIDs. Incorrect UIDs are returned for compatibility but will be removed -// from a future version of this package. // // spiPort the SPI device to use. // resetPin reset GPIO pin. @@ -143,8 +140,6 @@ func (r *Dev) SetAntennaGain(gain int) error { } // ReadUID reads the 4-byte or 7-byte card UID with IRQ event timeout. -// 4-byte UIDs will include their checksum byte unless Dev was created using -// WithFixedUID. // // timeout the operation timeout func (r *Dev) ReadUID(timeout time.Duration) (uid []byte, err error) {