types

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 11 Imported by: 38

Documentation

Index

Constants

View Source
const BIND_PORT = 0
View Source
const BROADCAST_PORT = 60000
View Source
const CONTROLLER_PORT = 60000

Variables

This section is empty.

Functions

This section is empty.

Types

type BindAddr added in v0.7.2

type BindAddr struct {
	netip.AddrPort
}

func BindAddrFrom added in v0.8.9

func BindAddrFrom(addr netip.Addr, port uint16) BindAddr

* BindAddrFrom contructs a BindAddr from an address and port.

func MustParseBindAddr added in v0.8.9

func MustParseBindAddr(s string) BindAddr

* MustParseBindAddr invokes ParseBindAddr and panics on error. * * It is intended for use in tests with hard-coded strings.

func ParseBindAddr added in v0.8.9

func ParseBindAddr(s string) (BindAddr, error)

* ParseBindAddr parses a string as a bind address. * * It doesn't do any name resolution i.e.: both the address and the port must be numeric. Defaults * to port 0 if the port is not specified.

func (*BindAddr) Clone added in v0.7.2

func (a *BindAddr) Clone() *BindAddr

func (*BindAddr) Equal added in v0.7.2

func (a *BindAddr) Equal(addr *ControllerAddr) bool

func (BindAddr) MarshalJSON added in v0.7.2

func (a BindAddr) MarshalJSON() ([]byte, error)

func (*BindAddr) Set added in v0.7.2

func (a *BindAddr) Set(v string) error

func (BindAddr) String added in v0.7.2

func (a BindAddr) String() string

* Formats the bind address and port as an address:port string. * * Return only the bind address if bind port is the default port (60000).

func (*BindAddr) UnmarshalJSON added in v0.7.2

func (a *BindAddr) UnmarshalJSON(bytes []byte) error

type BroadcastAddr added in v0.7.2

type BroadcastAddr struct {
	netip.AddrPort
}

func BroadcastAddrFrom added in v0.8.9

func BroadcastAddrFrom(addr netip.Addr, port uint16) BroadcastAddr

* BroadcastAddrFrom contructs a BroadcastAddr from an address and port.

func MustParseBroadcastAddr added in v0.8.9

func MustParseBroadcastAddr(s string) BroadcastAddr

* MustParseBroadcastAddr invokes ParseBroadcastAddr and panics on error. * * It is intended for use in tests with hard-coded strings.

func ParseBroadcastAddr added in v0.8.9

func ParseBroadcastAddr(s string) (BroadcastAddr, error)

* ParseBroadcastAddr parses a string as a UDP broadcast address. * * It doesn't do any name resolution i.e.: both the address and the port must be numeric. Defaults * to port 60000 if the port is not specified.

func (*BroadcastAddr) Clone added in v0.7.2

func (a *BroadcastAddr) Clone() *BroadcastAddr

func (*BroadcastAddr) Equal added in v0.7.2

func (a *BroadcastAddr) Equal(addr *BroadcastAddr) bool

func (BroadcastAddr) MarshalJSON added in v0.7.2

func (a BroadcastAddr) MarshalJSON() ([]byte, error)

func (*BroadcastAddr) Set added in v0.7.2

func (a *BroadcastAddr) Set(v string) error

func (BroadcastAddr) String added in v0.7.2

func (a BroadcastAddr) String() string

* Formats the broadcast address and port as an address:port string. * * Return only the bind address if bind port is the default port (60000).

func (*BroadcastAddr) UnmarshalJSON added in v0.7.2

func (a *BroadcastAddr) UnmarshalJSON(bytes []byte) error

type Card

type Card struct {
	CardNumber uint32          `json:"card-number"`
	From       Date            `json:"start-date"`
	To         Date            `json:"end-date"`
	Doors      map[uint8]uint8 `json:"doors"`
	PIN        PIN             `json:"PIN,omitempty"`
}

func (*Card) Clone

func (c *Card) Clone() Card

func (Card) MarshalJSON added in v0.8.4

func (c Card) MarshalJSON() ([]byte, error)

func (Card) String

func (c Card) String() string

func (*Card) UnmarshalJSON

func (c *Card) UnmarshalJSON(bytes []byte) error

type CardFormat added in v0.8.6

type CardFormat uint8
const (
	WiegandAny CardFormat = iota
	Wiegand26
)

func CardFormatFromString added in v0.8.6

func CardFormatFromString(v string) (CardFormat, error)

func (CardFormat) MarshalConf added in v0.8.6

func (f CardFormat) MarshalConf(tag string) ([]byte, error)

func (CardFormat) String added in v0.8.6

func (f CardFormat) String() string

func (*CardFormat) UnmarshalConf added in v0.8.6

func (f *CardFormat) UnmarshalConf(tag string, values map[string]string) (any, error)

type ControlState added in v0.7.2

type ControlState int
const (
	NormallyOpen ControlState = iota + 1
	NormallyClosed
	Controlled
)
const (
	ModeUnknown ControlState = iota
	ModeNormallyOpen
	ModeNormallyClosed
	ModeControlled
)

func (ControlState) MarshalJSON added in v0.7.2

func (v ControlState) MarshalJSON() ([]byte, error)

func (ControlState) String added in v0.7.2

func (v ControlState) String() string

func (*ControlState) UnmarshalJSON added in v0.7.2

func (v *ControlState) UnmarshalJSON(b []byte) error

type ControllerAddr added in v0.8.9

type ControllerAddr struct {
	netip.AddrPort
}

func ControllerAddrFrom added in v0.8.9

func ControllerAddrFrom(addr netip.Addr, port uint16) ControllerAddr

* ControllerAddrFrom contructs a ControllerAddr from an address and port.

func MustParseControllerAddr added in v0.8.9

func MustParseControllerAddr(s string) ControllerAddr

* MustParseControllerAddr invokes ParseControllerAddr and panics on error. * * It is intended for use in tests with hard-coded strings.

func ParseControllerAddr added in v0.8.9

func ParseControllerAddr(s string) (ControllerAddr, error)

* ParseControllerAddr parses a string as a controller address. * * It doesn't do any name resolution i.e.: both the address and the port must be numeric. Defaults * to port 60000 if the port is not specified.

func (*ControllerAddr) Clone added in v0.8.9

func (a *ControllerAddr) Clone() *ControllerAddr

func (ControllerAddr) Equal added in v0.8.9

func (a ControllerAddr) Equal(addr ControllerAddr) bool

func (ControllerAddr) IsValid added in v0.8.9

func (a ControllerAddr) IsValid() bool

func (ControllerAddr) MarshalJSON added in v0.8.9

func (a ControllerAddr) MarshalJSON() ([]byte, error)

func (*ControllerAddr) Set added in v0.8.9

func (a *ControllerAddr) Set(v string) error

func (ControllerAddr) String added in v0.8.9

func (a ControllerAddr) String() string

* Formats the controller address and port as an address:port string. * * Return only the controller address if bind port is the default port (60000).

func (*ControllerAddr) UnmarshalJSON added in v0.8.9

func (a *ControllerAddr) UnmarshalJSON(bytes []byte) error

type Date

type Date time.Time

func MustParseDate added in v0.8.9

func MustParseDate(s string) Date

MustParseDate invokes ParseDate and panics on error.

It is intended for use in tests with hard-coded strings.

func ParseDate added in v0.8.9

func ParseDate(s string) (Date, error)

Parses a date string, returning a zero value Date{} and an error if the string is blank or not a valid date.

func ToDate added in v0.7.0

func ToDate(year int, month time.Month, day int) Date

Utility function to explicitly construct a Date from year, month and day.

func (Date) After

func (d Date) After(date Date) bool

func (Date) Before

func (d Date) Before(date Date) bool

func (Date) Equals added in v0.8.4

func (d Date) Equals(date Date) bool

Returns true if the year,month and day are the same.

func (Date) IsZero added in v0.8.5

func (d Date) IsZero() bool

Returns true if the date is the zero value.

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (Date) MarshalUT0311L0x

func (d Date) MarshalUT0311L0x() ([]byte, error)

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(bytes []byte) error

func (*Date) UnmarshalUT0311L0x

func (d *Date) UnmarshalUT0311L0x(bytes []byte) (any, error)

* Unmarshalls invalid date values as a 'zero' date without an error on the grounds * that it should be possible to retrieve information from a corrupted access controller. * Applications are expected to check for valid dates.

func (Date) Weekday added in v0.7.0

func (d Date) Weekday() time.Weekday

type DateTime

type DateTime time.Time

func DateTimeNow added in v0.7.3

func DateTimeNow() DateTime

func (DateTime) Add added in v0.7.3

func (d DateTime) Add(dt time.Duration) DateTime

func (DateTime) Before added in v0.7.3

func (d DateTime) Before(t time.Time) bool

Because time.Truncate does not in any way behave like your would expect it to :-(

func (DateTime) IsZero added in v0.7.3

func (d DateTime) IsZero() bool

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

func (DateTime) MarshalText added in v0.7.1

func (d DateTime) MarshalText() ([]byte, error)

func (DateTime) MarshalUT0311L0x

func (d DateTime) MarshalUT0311L0x() ([]byte, error)

func (DateTime) String

func (d DateTime) String() string

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(bytes []byte) error

func (*DateTime) UnmarshalUT0311L0x

func (d *DateTime) UnmarshalUT0311L0x(b []byte) (any, error)

* Unmarshalls invalid date/time values as a 'zero' date without an error on the grounds * that it should be possible to retrieve information from a corrupted access controller. * Applications are expected to check for valid date-times.

type Device

type Device struct {
	Name         string
	SerialNumber SerialNumber
	IpAddress    net.IP
	SubnetMask   net.IP
	Gateway      net.IP
	MacAddress   MacAddress
	Version      Version
	Date         Date
	Address      netip.AddrPort
	TimeZone     *time.Location
}

func (*Device) String

func (device *Device) String() string

type DoorControlState

type DoorControlState struct {
	SerialNumber SerialNumber
	Door         uint8
	ControlState ControlState
	Delay        uint8
}

func (*DoorControlState) String

func (d *DoorControlState) String() string

type Event

type Event struct {
	SerialNumber SerialNumber
	Index        uint32
	Type         byte
	Granted      bool
	Door         byte
	Direction    uint8
	CardNumber   uint32
	Timestamp    DateTime
	Reason       uint8
}

func (Event) IsZero added in v0.8.7

func (e Event) IsZero() bool

func (Event) String

func (e Event) String() string

type EventIndex

type EventIndex struct {
	SerialNumber SerialNumber
	Index        uint32
}

func (*EventIndex) String

func (e *EventIndex) String() string

type EventIndexResult

type EventIndexResult struct {
	SerialNumber SerialNumber
	Index        uint32
	Changed      bool
}

func (*EventIndexResult) String

func (e *EventIndexResult) String() string

type HHmm added in v0.7.0

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

func HHmmFromString added in v0.7.0

func HHmmFromString(s string) (*HHmm, error)

func HHmmFromTime added in v0.7.0

func HHmmFromTime(t time.Time) HHmm

func NewHHmm added in v0.7.0

func NewHHmm(hours, minutes int) HHmm

func (HHmm) After added in v0.7.0

func (h HHmm) After(t HHmm) bool

func (HHmm) Before added in v0.7.0

func (h HHmm) Before(t HHmm) bool

func (HHmm) Equals added in v0.7.1

func (h HHmm) Equals(t HHmm) bool

func (HHmm) MarshalJSON added in v0.7.0

func (h HHmm) MarshalJSON() ([]byte, error)

func (HHmm) MarshalUT0311L0x added in v0.7.0

func (h HHmm) MarshalUT0311L0x() ([]byte, error)

func (HHmm) String added in v0.7.0

func (h HHmm) String() string

func (*HHmm) UnmarshalJSON added in v0.7.0

func (h *HHmm) UnmarshalJSON(bytes []byte) error

func (*HHmm) UnmarshalUT0311L0x added in v0.7.0

func (h *HHmm) UnmarshalUT0311L0x(bytes []byte) (interface{}, error)

type Interlock added in v0.8.5

type Interlock uint8
const (
	NoInterlock    Interlock = 0x00 // disabled
	Interlock12    Interlock = 0x01 // doors (1,2)
	Interlock34    Interlock = 0x02 // doors (3,4)
	Interlock12_34 Interlock = 0x03 // doors (1,2) and (3,4)
	Interlock123   Interlock = 0x04 // doors (1,2,3)
	Interlock1234  Interlock = 0x08 // doors (1,2,3,4)
)

func (Interlock) String added in v0.8.5

func (i Interlock) String() string

type ListenAddr added in v0.7.2

type ListenAddr struct {
	netip.AddrPort
}

func ListenAddrFrom added in v0.8.9

func ListenAddrFrom(addr netip.Addr, port uint16) ListenAddr

* ListenAddrFrom contructs a ListenAddr from an address and port.

func MustParseListenAddr added in v0.8.9

func MustParseListenAddr(s string) ListenAddr

* MustParseListenAddr invokes ParseListenAddr and panics on error. * * It is intended for use in tests with hard-coded strings.

func ParseListenAddr added in v0.8.9

func ParseListenAddr(s string) (ListenAddr, error)

* ParseListenAddr parses a string as a UDP listen address. * * It doesn't do any name resolution and the port is required - both the address and the port must be numeric

func (*ListenAddr) Clone added in v0.7.2

func (a *ListenAddr) Clone() *ListenAddr

func (*ListenAddr) Equal added in v0.7.2

func (a *ListenAddr) Equal(addr *ListenAddr) bool

func (ListenAddr) IsValid added in v0.8.9

func (a ListenAddr) IsValid() bool

func (ListenAddr) MarshalJSON added in v0.7.2

func (a ListenAddr) MarshalJSON() ([]byte, error)

func (*ListenAddr) Set added in v0.7.2

func (a *ListenAddr) Set(v string) error

func (ListenAddr) String added in v0.7.2

func (a ListenAddr) String() string

* Formats the listen address and port as an address:port string. *

func (*ListenAddr) UnmarshalJSON added in v0.7.2

func (a *ListenAddr) UnmarshalJSON(bytes []byte) error

type MacAddress

type MacAddress net.HardwareAddr

func (MacAddress) MarshalJSON

func (m MacAddress) MarshalJSON() ([]byte, error)

func (MacAddress) MarshalUT0311L0x

func (m MacAddress) MarshalUT0311L0x() ([]byte, error)

func (MacAddress) String

func (m MacAddress) String() string

func (*MacAddress) UnmarshalJSON

func (m *MacAddress) UnmarshalJSON(bytes []byte) error

func (*MacAddress) UnmarshalUT0311L0x

func (m *MacAddress) UnmarshalUT0311L0x(bytes []byte) (interface{}, error)

type MsgType

type MsgType uint8

type PIN added in v0.8.4

type PIN uint32

func (PIN) MarshalJSON added in v0.8.4

func (p PIN) MarshalJSON() ([]byte, error)

func (PIN) MarshalUT0311L0x added in v0.8.4

func (p PIN) MarshalUT0311L0x() ([]byte, error)

func (*PIN) UnmarshalJSON added in v0.8.4

func (p *PIN) UnmarshalJSON(bytes []byte) error

func (*PIN) UnmarshalUT0311L0x added in v0.8.4

func (p *PIN) UnmarshalUT0311L0x(bytes []byte) (any, error)

type Result

type Result struct {
	SerialNumber SerialNumber
	Succeeded    bool
}

func (*Result) String

func (r *Result) String() string

type SOM added in v0.6.8

type SOM uint8

type Segment added in v0.7.0

type Segment struct {
	Start HHmm `json:"start,omitempty"`
	End   HHmm `json:"end,omitempty"`
}

func (Segment) String added in v0.7.0

func (s Segment) String() string

type Segments added in v0.7.0

type Segments map[uint8]Segment

func (Segments) MarshalJSON added in v0.7.0

func (ss Segments) MarshalJSON() ([]byte, error)

func (Segments) String added in v0.7.0

func (ss Segments) String() string

func (*Segments) UnmarshalJSON added in v0.7.0

func (ss *Segments) UnmarshalJSON(bytes []byte) error

type SerialNumber

type SerialNumber uint32

func (SerialNumber) MarshalUT0311L0x

func (s SerialNumber) MarshalUT0311L0x() ([]byte, error)

func (SerialNumber) String

func (s SerialNumber) String() string

func (*SerialNumber) UnmarshalUT0311L0x

func (s *SerialNumber) UnmarshalUT0311L0x(bytes []byte) (interface{}, error)

type Status

type Status struct {
	SerialNumber   SerialNumber
	DoorState      map[uint8]bool
	DoorButton     map[uint8]bool
	SystemError    uint8
	SystemDateTime DateTime
	SequenceId     uint32
	SpecialInfo    uint8
	RelayState     uint8
	InputState     uint8
	Event          StatusEvent // using zero value for 'no event'
}

func (Status) String

func (s Status) String() string

type StatusEvent added in v0.6.12

type StatusEvent struct {
	Index      uint32
	Type       byte
	Granted    bool
	Door       byte
	Direction  uint8
	CardNumber uint32
	Timestamp  DateTime
	Reason     uint8
}

func (StatusEvent) IsZero added in v0.8.7

func (e StatusEvent) IsZero() bool

type SystemDate

type SystemDate time.Time

func (SystemDate) Format added in v0.8.4

func (d SystemDate) Format(format string) string

func (SystemDate) IsZero added in v0.8.4

func (d SystemDate) IsZero() bool

func (SystemDate) MarshalUT0311L0x

func (d SystemDate) MarshalUT0311L0x() ([]byte, error)

func (SystemDate) String

func (d SystemDate) String() string

func (*SystemDate) UnmarshalUT0311L0x

func (d *SystemDate) UnmarshalUT0311L0x(b []byte) (interface{}, error)

type SystemTime

type SystemTime time.Time

func TimeFromString added in v0.7.0

func TimeFromString(s string) (*SystemTime, error)

func (SystemTime) Format added in v0.8.4

func (t SystemTime) Format(format string) string

func (SystemTime) MarshalUT0311L0x

func (d SystemTime) MarshalUT0311L0x() ([]byte, error)

func (SystemTime) String

func (t SystemTime) String() string

func (*SystemTime) UnmarshalUT0311L0x

func (t *SystemTime) UnmarshalUT0311L0x(bytes []byte) (interface{}, error)

type Task added in v0.7.1

type Task struct {
	Task     TaskType `json:"task"`
	Door     uint8    `json:"door,omitempty"`
	From     Date     `json:"start-date,omitempty"`
	To       Date     `json:"end-date,omitempty"`
	Weekdays Weekdays `json:"weekdays,omitempty"`
	Start    HHmm     `json:"start,omitempty"`
	Cards    uint8    `json:"cards,omitempty"`
}

func (Task) String added in v0.7.1

func (t Task) String() string

func (*Task) UnmarshalJSON added in v0.7.1

func (t *Task) UnmarshalJSON(bytes []byte) error

type TaskType added in v0.7.1

type TaskType int
const (
	DoorControlled TaskType = iota
	DoorNormallyOpen
	DoorNormallyClosed
	DisableTimeProfile
	EnableTimeProfile
	CardNoPassword
	CardInPassword
	CardInOutPassword
	EnableMoreCards
	DisableMoreCards
	TriggerOnce
	DisablePushButton
	EnablePushButton
)

func (TaskType) MarshalJSON added in v0.7.1

func (tt TaskType) MarshalJSON() ([]byte, error)

func (TaskType) String added in v0.7.1

func (tt TaskType) String() string

func (*TaskType) UnmarshalJSON added in v0.7.1

func (tt *TaskType) UnmarshalJSON(b []byte) error

Unmarshals a TaskType from a JSON field that may be either a numeric task type ID or a task description string. Numeric task type IDs range from 1..13, corresponding to the tasks:

- control door - unlock door - lock door - disable time profile - enable time profile - enable card, no password - enable card+in password - enable card+password - enable more cards - disable more cards - trigger once - disable push button - enable push button

Task description strings are case- and space-insensitive.

Note that the task type IDs used by the UHPPOTE range from 0..12 - the uhppote-core 'bumps' this by one so that the default JSON value of 0 can be discarded as invalid.

func (*TaskType) UnmarshalTSV added in v0.7.1

func (tt *TaskType) UnmarshalTSV(s string) (interface{}, error)

type Time

type Time struct {
	SerialNumber SerialNumber
	DateTime     DateTime
}

func (Time) String

func (t Time) String() string

type TimeProfile added in v0.7.0

type TimeProfile struct {
	ID              uint8    `json:"id"`
	LinkedProfileID uint8    `json:"linked-profile,omitempty"`
	From            Date     `json:"start-date,omitempty"`
	To              Date     `json:"end-date,omitempty"`
	Weekdays        Weekdays `json:"weekdays,omitempty"`
	Segments        Segments `json:"segments,omitempty"`
}

func (TimeProfile) String added in v0.7.0

func (t TimeProfile) String() string

func (*TimeProfile) UnmarshalJSON added in v0.7.0

func (t *TimeProfile) UnmarshalJSON(bytes []byte) error

type Version

type Version uint16

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

func (Version) MarshalUT0311L0x

func (v Version) MarshalUT0311L0x() ([]byte, error)

func (Version) String added in v0.6.8

func (v Version) String() string

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(bytes []byte) error

func (*Version) UnmarshalUT0311L0x

func (v *Version) UnmarshalUT0311L0x(bytes []byte) (interface{}, error)

type Weekdays added in v0.7.0

type Weekdays map[time.Weekday]bool

func (Weekdays) MarshalJSON added in v0.7.0

func (w Weekdays) MarshalJSON() ([]byte, error)

func (Weekdays) String added in v0.7.0

func (w Weekdays) String() string

func (*Weekdays) UnmarshalJSON added in v0.7.0

func (w *Weekdays) UnmarshalJSON(bytes []byte) error

Jump to

Keyboard shortcuts

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