|
|
|
|
@ -134,11 +134,19 @@ type Dev struct {
|
|
|
|
|
spiDev spi.Conn
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// String implements conn.Resource.
|
|
|
|
|
func (r *Dev) String() string {
|
|
|
|
|
return fmt.Sprintf("Mifare MFRC522 [bus: %v, reset pin: %s, irq pin: %s]",
|
|
|
|
|
r.spiDev, r.resetPin.Name(), r.irqPin.Name())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Halt implements conn.Resource.
|
|
|
|
|
//
|
|
|
|
|
// It soft-stops the chip - PowerDown bit set, command IDLE
|
|
|
|
|
func (r *Dev) Halt() error {
|
|
|
|
|
return r.devWrite(commands.CommandReg, 16)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetOperationtimeout updates the device timeout for card operations.
|
|
|
|
|
//
|
|
|
|
|
// Effectively that sets the maximum time the RFID device will wait for IRQ
|
|
|
|
|
@ -165,11 +173,6 @@ func (r *Dev) Reset() error {
|
|
|
|
|
return r.devWrite(commands.CommandReg, commands.PCD_RESETPHASE)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Halt soft-stops the chip - PowerDown bit set, command IDLE
|
|
|
|
|
func (r *Dev) Halt() error {
|
|
|
|
|
return r.devWrite(commands.CommandReg, 16)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetAntenna configures the antenna state, on/off.
|
|
|
|
|
func (r *Dev) SetAntenna(state bool) error {
|
|
|
|
|
if state {
|
|
|
|
|
@ -754,10 +757,9 @@ var sequenceCommands = struct {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _ conn.Resource = &Dev{}
|
|
|
|
|
var _ fmt.Stringer = &Dev{}
|
|
|
|
|
var _ fmt.Stringer = &BlocksAccess{}
|
|
|
|
|
|
|
|
|
|
func wrapf(format string, a ...interface{}) error {
|
|
|
|
|
return fmt.Errorf("mfrc522: "+format, a...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _ conn.Resource = &Dev{}
|
|
|
|
|
var _ fmt.Stringer = &BlocksAccess{}
|
|
|
|
|
|