Documentation
¶
Index ¶
- Variables
- type CardDetectionState
- type CardState
- func (cs *CardState) CanStartRemovalTimer() bool
- func (cs *CardState) TransitionToDetected(timeout time.Duration, callback func())
- func (cs *CardState) TransitionToIdle()
- func (cs *CardState) TransitionToPostReadGrace(timeout time.Duration, callback func())
- func (cs *CardState) TransitionToReading()
- type Config
- type Monitor
Constants ¶
This section is empty.
Variables ¶
var ErrNoTagInPoll = errors.New("no tag detected in polling cycle")
ErrNoTagInPoll indicates no tag was detected during polling (not an error condition)
Functions ¶
This section is empty.
Types ¶
type CardDetectionState ¶
type CardDetectionState int
CardDetectionState represents the finite state machine for card detection
const ( StateIdle CardDetectionState = iota StateTagDetected StateReading StatePostReadGrace )
type CardState ¶
type CardState struct {
LastSeenTime time.Time
ReadStartTime time.Time
RemovalTimer *time.Timer
LastUID string
LastType string
TestedUID string
DetectionState CardDetectionState
Present bool
}
CardState tracks the state of a card on a reader
func (*CardState) CanStartRemovalTimer ¶
CanStartRemovalTimer returns true if the state allows removal timer to run
func (*CardState) TransitionToDetected ¶
TransitionToDetected moves to tag detected state with normal removal timeout
func (*CardState) TransitionToIdle ¶
func (cs *CardState) TransitionToIdle()
TransitionToIdle resets to idle state
func (*CardState) TransitionToPostReadGrace ¶
TransitionToPostReadGrace moves to post-read grace period with short timeout
func (*CardState) TransitionToReading ¶
func (cs *CardState) TransitionToReading()
TransitionToReading moves to reading state and suspends removal timer
type Config ¶
Config holds polling configuration options
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default polling configuration
type Monitor ¶
type Monitor struct {
OnCardDetected func(tag *pn532.DetectedTag) error
OnCardRemoved func()
OnCardChanged func(tag *pn532.DetectedTag) error
// contains filtered or unexported fields
}
Monitor handles continuous card monitoring with state machine
func NewMonitor ¶
NewMonitor creates a new card monitor