Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type FrameType
- type InfoFrame
- type Logger
- type Pn532
- func (p *Pn532) Close() error
- func (p *Pn532) FirmwareVersion() ([]byte, error)
- func (p *Pn532) InAutoPoll(PollNr, Period byte, Type ...byte) ([]byte, error)
- func (p *Pn532) MifareClassicAuthenticateBlock(uid []byte, blockNum byte, keyType byte, key []byte) (bool, error)
- func (p *Pn532) MifareClassicReadBlock(blockNum byte) ([]byte, error)
- func (p *Pn532) MifareClassicWriteBlock(blockNum byte, data []byte) (bool, error)
- func (p *Pn532) ReadPassiveTarget(cardBaud byte) ([]byte, error)
- func (p *Pn532) SAMConfiguration(mode byte, timeout byte) (bool, error)
- func (p *Pn532) SendCommand(data []byte) (bool, error)
- func (p *Pn532) SetParameters(...) (bool, error)
- func (p *Pn532) WaitInfoFrame() (*InfoFrame, error)
- func (p *Pn532) Write(data []byte) (int, error)
- func (p *Pn532) WriteFrame(data []byte) error
- type RespFrame
- type SilentLogger
Constants ¶
const (
ISO14443A = 0x00 // 卡片类型
)
Variables ¶
var DefaultLogger = &defaultLogger{}
Functions ¶
This section is empty.
Types ¶
type InfoFrame ¶
type InfoFrame struct {
PreAmble byte
StartCode [2]byte
Len byte
Lcs byte
Tfi byte
Data []byte
Dcs byte
PostAmble byte
}
func NewNormalFrame ¶
type Pn532 ¶
type Pn532 struct {
Resp chan *RespFrame
// contains filtered or unexported fields
}
func InitWithConf ¶
func (*Pn532) FirmwareVersion ¶
FirmwareVersion 获取固件版本
func (*Pn532) InAutoPoll ¶
InAutoPoll 读卡 并返回读到的uid PollNr specifies the number of polling (one polling is a polling for each Type j). period (0x01-0x0F) indicates the polling period in units of 150 ms. Type 1 indicates the mandatory target type to be polled at the 1st time.
func (*Pn532) MifareClassicAuthenticateBlock ¶
func (p *Pn532) MifareClassicAuthenticateBlock(uid []byte, blockNum byte, keyType byte, key []byte) (bool, error)
MifareClassicAuthenticateBlock 验证区块密码 keyType 为设置验证A密码或B密码 blockNum为块号
func (*Pn532) MifareClassicReadBlock ¶
func (*Pn532) MifareClassicWriteBlock ¶
func (*Pn532) ReadPassiveTarget ¶
ReadPassiveTarget 读卡 并返回读到的uid
func (*Pn532) SAMConfiguration ¶
SAMConfiguration 通常传入command.NormalMode,0x17
func (*Pn532) SendCommand ¶
SendCommand 发送命令至pn532 如响应正确 返回true 否则返回false
func (*Pn532) SetParameters ¶
func (p *Pn532) SetParameters(NADUsed, DIDUsed, AutoATR_RES, AutoRATS, ISO14443_4_PICC, RemovePrePostAmble bool) (bool, error)
SetParameters 此命令用于设置 PN532 的内部参数,然后配置其针对不同情况的行为。 NADUsed: Use of the NAD information in case of initiator configuration (DEP and ISO/IEC14443-4 PCD). DIDUsed: Use of the DID information in case of initiator configuration (or CID in case of ISO/IEC14443-4 PCD configuration). AutoATR_RES: Automatic generation of the ATR_RES in case of target configuration. AutoRATS: Automatic generation of the RATS in case of ISO/IEC14443-4 PCD mode. ISO14443-4_PICC: The emulation of a ISO/IEC14443-4 PICC is enabled. RemovePrePostAmble: The PN532 does not send Preamble and Postamble.
func (*Pn532) WaitInfoFrame ¶
WaitInfoFrame 等待响应帧
func (*Pn532) WriteFrame ¶
type SilentLogger ¶
type SilentLogger struct{}
func (*SilentLogger) Debugf ¶
func (l *SilentLogger) Debugf(_ string, _ ...interface{})
func (*SilentLogger) Errorf ¶
func (l *SilentLogger) Errorf(_ string, _ ...interface{})
func (*SilentLogger) Infof ¶
func (l *SilentLogger) Infof(_ string, _ ...interface{})