pn532

package
v0.0.0-...-25fe843 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

README

PN532 Driver

This is still a work in progress driver. At the moment it only supports I2C. For an example check the nfc example.

Datasheet and user manual

For implementing the communication the PN532 User Manual is of much more use than the Datasheet.

Reference Driver Code

Reference Hardware

I have tested this driver on a cheap NCF Module V3 board:

Elechouse NFC Module V3

This board does not provide the RSTPD_N, this is why I did not have used the reset logic.

For more details please check the manual PN532 NFC RFID Module User Guide

License

Since this is basically a rewrite of the Adafruit Code in Go the license is BSD license as of the original code.

Documentation

Index

Constants

View Source
const (
	MIFARE_CMD_AUTH_A           = 0x60 ///< Auth A
	MIFARE_CMD_AUTH_B           = 0x61 ///< Auth B
	MIFARE_CMD_READ             = 0x30 ///< Read
	MIFARE_CMD_WRITE            = 0xA0 ///< Write
	MIFARE_CMD_TRANSFER         = 0xB0 ///< Transfer
	MIFARE_CMD_DECREMENT        = 0xC0 ///< Decrement
	MIFARE_CMD_INCREMENT        = 0xC1 ///< Increment
	MIFARE_CMD_STORE            = 0xC2 ///< Store
	MIFARE_ULTRALIGHT_CMD_WRITE = 0xA2 ///< Write (MiFare Ultralight)
)

Mifare Commands

View Source
const MifareClassicBlockSize = 16

Variables

This section is empty.

Functions

This section is empty.

Types

type MifareClassic

type MifareClassic struct {
	// contains filtered or unexported fields
}

func NewMifareClasic

func NewMifareClasic(device *Device) MifareClassic

func (*MifareClassic) AuthenticateBlock

func (m *MifareClassic) AuthenticateBlock(uid []byte,
	blockNumber uint32,
	keyNumber MifareClassicKeyType,
) error

func (*MifareClassic) IsFirstBlock

func (m *MifareClassic) IsFirstBlock(block uint32) bool

func (*MifareClassic) IsTrailerBlock

func (m *MifareClassic) IsTrailerBlock(block uint32) bool

func (*MifareClassic) ReadDataBlock

func (m *MifareClassic) ReadDataBlock(blockNumber uint8) ([]byte, error)

func (*MifareClassic) SetKeyA

func (m *MifareClassic) SetKeyA(key MifareClassicKey)

func (*MifareClassic) SetKeyB

func (m *MifareClassic) SetKeyB(key MifareClassicKey)

func (*MifareClassic) WriteDataBlock

func (m *MifareClassic) WriteDataBlock(blockNumber uint8, data []byte) error

type MifareClassicKey

type MifareClassicKey []byte

type MifareClassicKeyType

type MifareClassicKeyType uint8
const (
	MifareClassicKeyA MifareClassicKeyType = 0
	MifareClassicKeyB MifareClassicKeyType = 1
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL