testing

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdGetFirmwareVersion  = 0x02
	CmdInListPassiveTarget = 0x4A
	CmdInDataExchange      = 0x40
	CmdInRelease           = 0x52
	CmdSAMConfiguration    = 0x14
	CmdInSelect            = 0x54
)

Command bytes for reference

Variables

View Source
var (
	// TestNTAG213UID is a sample NTAG213 UID
	TestNTAG213UID = []byte{0x04, 0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56}

	// TestMIFARE1KUID is a sample MIFARE Classic 1K UID
	TestMIFARE1KUID = []byte{0x12, 0x34, 0x56, 0x78}

	// TestMIFARE4KUID is a sample MIFARE Classic 4K UID
	TestMIFARE4KUID = []byte{0xAB, 0xCD, 0xEF, 0x01}
)

Common UIDs for testing

Functions

func BuildDataExchangeResponse

func BuildDataExchangeResponse(data []byte) []byte

BuildDataExchangeResponse creates an InDataExchange response

func BuildErrorResponse

func BuildErrorResponse(cmd, errorCode byte) []byte

BuildErrorResponse creates an error response for any command

func BuildFirmwareVersionResponse

func BuildFirmwareVersionResponse() []byte

BuildFirmwareVersionResponse creates a GetFirmwareVersion response

func BuildNoTagResponse

func BuildNoTagResponse() []byte

BuildNoTagResponse creates an empty InListPassiveTarget response

func BuildSAMConfigurationResponse

func BuildSAMConfigurationResponse() []byte

BuildSAMConfigurationResponse creates a SAMConfiguration response BuildSAMConfigurationResponse creates a SAMConfiguration response BuildSAMConfigurationResponse creates a SAMConfiguration response

func BuildTagDetectionResponse

func BuildTagDetectionResponse(tagType string, uid []byte) []byte

BuildTagDetectionResponse creates an InListPassiveTarget response

Types

type VirtualTag

type VirtualTag struct {
	Type   string
	UID    []byte
	Memory [][]byte

	Present bool
	// contains filtered or unexported fields
}

VirtualTag represents a simulated NFC tag for testing

func NewVirtualMIFARE1K

func NewVirtualMIFARE1K(uid []byte) *VirtualTag

NewVirtualMIFARE1K creates a virtual MIFARE Classic 1K tag

func NewVirtualMIFARE4K

func NewVirtualMIFARE4K(uid []byte) *VirtualTag

NewVirtualMIFARE4K creates a virtual MIFARE Classic 4K tag

func NewVirtualNTAG213

func NewVirtualNTAG213(uid []byte) *VirtualTag

NewVirtualNTAG213 creates a virtual NTAG213 tag with default content

func (*VirtualTag) GetNDEFText

func (v *VirtualTag) GetNDEFText() string

GetNDEFText extracts text from the NDEF message (simplified)

func (*VirtualTag) GetUIDString

func (v *VirtualTag) GetUIDString() string

GetUIDString returns the UID as a hex string

func (*VirtualTag) Insert

func (v *VirtualTag) Insert()

Insert sets the tag as present

func (*VirtualTag) ReadBlock

func (v *VirtualTag) ReadBlock(block int) ([]byte, error)

ReadBlock reads a specific memory block

func (*VirtualTag) Remove

func (v *VirtualTag) Remove()

Remove sets the tag as not present

func (*VirtualTag) SetNDEFText

func (v *VirtualTag) SetNDEFText(text string) error

SetNDEFText sets a simple text NDEF message

func (*VirtualTag) WriteBlock

func (v *VirtualTag) WriteBlock(block int, data []byte) error

WriteBlock writes data to a specific memory block

Jump to

Keyboard shortcuts

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