ndef

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NDEF markers
	NdefEnd = []byte{0xFE}

	// ErrNoNDEF is returned when no NDEF record is found.
	ErrNoNDEF = errors.New("no NDEF record found")
	// ErrInvalidNDEF is returned when the NDEF format is invalid.
	ErrInvalidNDEF = errors.New("invalid NDEF format")
)

Functions

func BuildMessage

func BuildMessage(text string) ([]byte, error)

BuildMessage is an alias for BuildTextMessage for backward compatibility

func BuildTextMessage

func BuildTextMessage(text string) ([]byte, error)

BuildTextMessage creates an NDEF message with a single text record

func ParseToText

func ParseToText(data []byte) (string, error)

ParseToText parses raw NDEF data and returns the first text or URI record as a string

func ValidateNDEFMessage

func ValidateNDEFMessage(data []byte) error

ValidateNDEFMessage validates basic NDEF message structure

Types

type NDEFMessage

type NDEFMessage struct {
	Records []NDEFRecord
}

NDEFMessage represents an NDEF message

type NDEFRecord

type NDEFRecord struct {
	Text    string
	URI     string
	Type    NDEFRecordType
	Payload []byte
}

NDEFRecord represents a single NDEF record

type NDEFRecordType

type NDEFRecordType string

NDEFRecordType represents the type of an NDEF record

const (
	// NDEFTypeText represents a text record type
	NDEFTypeText NDEFRecordType = "text"
	// NDEFTypeURI represents a URI record type
	NDEFTypeURI NDEFRecordType = "uri"
)

Jump to

Keyboard shortcuts

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