uhppoted

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 13 Imported by: 10

Documentation

Index

Constants

View Source
const (
	StatusOK                  = http.StatusOK
	StatusBadRequest          = http.StatusBadRequest
	StatusNotFound            = http.StatusNotFound
	StatusUnauthorized        = http.StatusUnauthorized
	StatusInternalServerError = http.StatusInternalServerError
)

Variables

View Source
var (
	ErrBadRequest          = errors.New("bad request")
	ErrNotFound            = errors.New("not found")
	ErrUnauthorized        = errors.New("not authorized")
	ErrInternalServerError = errors.New("internal server error")
	ErrFailed              = errors.New("request failed")
)

Functions

This section is empty.

Types

type ClearTimeProfilesRequest

type ClearTimeProfilesRequest struct {
	DeviceID uint32
}

type ClearTimeProfilesResponse

type ClearTimeProfilesResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Cleared  bool     `json:"cleared"`
}

type DateRange

type DateRange struct {
	Start *types.DateTime `json:"start,omitempty"`
	End   *types.DateTime `json:"end,omitempty"`
}

func (*DateRange) String

func (d *DateRange) String() string

type DeleteCardRequest

type DeleteCardRequest struct {
	DeviceID   DeviceID
	CardNumber uint32
}

type DeleteCardResponse

type DeleteCardResponse struct {
	DeviceID   DeviceID `json:"device-id"`
	CardNumber uint32   `json:"card-number"`
	Deleted    bool     `json:"deleted"`
}

type DeleteCardsRequest

type DeleteCardsRequest struct {
	DeviceID DeviceID
}

type DeleteCardsResponse

type DeleteCardsResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Deleted  bool     `json:"deleted"`
}

type DeviceID

type DeviceID uint32

func (*DeviceID) UnmarshalJSON

func (id *DeviceID) UnmarshalJSON(bytes []byte) (err error)

type DeviceSummary

type DeviceSummary struct {
	DeviceType string `json:"device-type"`
	Address    net.IP `json:"ip-address"`
	Port       int    `json:"port"`
}

TODO rename Address to IpAddress and use Address for IP:Port

type Event

type Event struct {
	DeviceID   uint32         `json:"device-id"`
	Index      uint32         `json:"event-id"`
	Type       uint8          `json:"event-type"`
	Granted    bool           `json:"access-granted"`
	Door       uint8          `json:"door-id"`
	Direction  uint8          `json:"direction"`
	CardNumber uint32         `json:"card-number"`
	Timestamp  types.DateTime `json:"timestamp"`
	Reason     uint8          `json:"event-reason"`
}

FIXME: remove - superseded by reworked uhppote-core/types/Event

func (Event) IsZero added in v0.8.7

func (e Event) IsZero() bool

type GetCardRecordsRequest

type GetCardRecordsRequest struct {
	DeviceID DeviceID
}

type GetCardRecordsResponse

type GetCardRecordsResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Cards    uint32   `json:"cards"`
}

type GetCardRequest

type GetCardRequest struct {
	DeviceID   DeviceID
	CardNumber uint32
}

type GetCardResponse

type GetCardResponse struct {
	DeviceID DeviceID   `json:"device-id"`
	Card     types.Card `json:"card"`
}

type GetCardsRequest

type GetCardsRequest struct {
	DeviceID DeviceID
}

type GetCardsResponse

type GetCardsResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Cards    []uint32 `json:"cards"`
}

type GetDeviceRequest

type GetDeviceRequest struct {
	DeviceID DeviceID
}

type GetDeviceResponse

type GetDeviceResponse struct {
	DeviceType string           `json:"device-type"`
	DeviceID   DeviceID         `json:"device-id"`
	IpAddress  net.IP           `json:"ip-address"`
	SubnetMask net.IP           `json:"subnet-mask"`
	Gateway    net.IP           `json:"gateway-address"`
	MacAddress types.MacAddress `json:"mac-address"`
	Version    types.Version    `json:"version"`
	Date       types.Date       `json:"date"`
	Address    net.UDPAddr      `json:"address"`
	TimeZone   *time.Location   `json:"timezone,omitempty"`
}

type GetDevicesRequest

type GetDevicesRequest struct {
}

type GetDevicesResponse

type GetDevicesResponse struct {
	Devices map[uint32]DeviceSummary `json:"devices"`
}

type GetDoorControlRequest

type GetDoorControlRequest struct {
	DeviceID DeviceID
	Door     uint8
}

type GetDoorControlResponse

type GetDoorControlResponse struct {
	DeviceID DeviceID           `json:"device-id"`
	Door     uint8              `json:"door"`
	Control  types.ControlState `json:"control"`
}

type GetDoorDelayRequest

type GetDoorDelayRequest struct {
	DeviceID DeviceID
	Door     uint8
}

type GetDoorDelayResponse

type GetDoorDelayResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Door     uint8    `json:"door"`
	Delay    uint8    `json:"delay"`
}

type GetTimeProfileRequest

type GetTimeProfileRequest struct {
	DeviceID  uint32
	ProfileID uint8
}

type GetTimeProfileResponse

type GetTimeProfileResponse struct {
	DeviceID    DeviceID          `json:"device-id"`
	TimeProfile types.TimeProfile `json:"time-profile"`
}

type GetTimeProfilesRequest

type GetTimeProfilesRequest struct {
	DeviceID uint32
	From     int
	To       int
}

type GetTimeProfilesResponse

type GetTimeProfilesResponse struct {
	DeviceID DeviceID            `json:"device-id"`
	Profiles []types.TimeProfile `json:"profiles"`
}

type GetTimeRequest

type GetTimeRequest struct {
	DeviceID DeviceID
}

type GetTimeResponse

type GetTimeResponse struct {
	DeviceID DeviceID       `json:"device-id"`
	DateTime types.DateTime `json:"date-time"`
}

type IUHPPOTED

type IUHPPOTED interface {
	GetDevices(request GetDevicesRequest) (*GetDevicesResponse, error)
	GetDevice(request GetDeviceRequest) (*GetDeviceResponse, error)
	GetTime(request GetTimeRequest) (*GetTimeResponse, error)
	SetTime(request SetTimeRequest) (*SetTimeResponse, error)
	GetDoorDelay(request GetDoorDelayRequest) (*GetDoorDelayResponse, error)
	GetDoorControl(request GetDoorControlRequest) (*GetDoorControlResponse, error)
	GetCardRecords(request GetCardRecordsRequest) (*GetCardRecordsResponse, error)
	GetCards(request GetCardsRequest) (*GetCardsResponse, error)
	DeleteCards(request DeleteCardsRequest) (*DeleteCardsResponse, error)
	GetCard(request GetCardRequest) (*GetCardResponse, error)
	DeleteCard(request DeleteCardRequest) (*DeleteCardResponse, error)
	GetTimeProfiles(request GetTimeProfilesRequest) (*GetTimeProfilesResponse, error)
	PutTimeProfiles(request PutTimeProfilesRequest) (*PutTimeProfilesResponse, int, error)
	GetTimeProfile(request GetTimeProfileRequest) (*GetTimeProfileResponse, error)
	PutTimeProfile(request PutTimeProfileRequest) (*PutTimeProfileResponse, error)
	ClearTimeProfiles(request ClearTimeProfilesRequest) (*ClearTimeProfilesResponse, error)
	PutTaskList(request PutTaskListRequest) (*PutTaskListResponse, int, error)
	OpenDoor(request OpenDoorRequest) (*OpenDoorResponse, error)

	SetDoorControl(controller uint32, door uint8, mode types.ControlState) error
	SetDoorDelay(controller uint32, door uint8, delay uint8) error
	SetDoorPasscodes(controller uint32, door uint8, passcodes ...uint32) error
	SetInterlock(controller uint32, interlock types.Interlock) error
	ActivateKeypads(controller uint32, keypads map[uint8]bool) error
	GetStatus(controller uint32) (*Status, error)
	GetEventIndices(controller uint32) (uint32, uint32, uint32, error)
	GetEvent(controller uint32, index uint32) (*Event, error)
	GetEvents(controller uint32, N int) ([]Event, error)
	FetchEvents(controller uint32, from, N uint32) ([]types.Event, error)
	RecordSpecialEvents(controller uint32, enable bool) (bool, error)
	PutCard(controller uint32, card types.Card) (bool, error)
	RestoreDefaultParameters(controller uint32) error
}

type OpenDoorRequest

type OpenDoorRequest struct {
	DeviceID DeviceID
	Door     uint8
}

type OpenDoorResponse

type OpenDoorResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Door     uint8    `json:"door"`
	Opened   bool     `json:"opened"`
}

type PutTaskListRequest

type PutTaskListRequest struct {
	DeviceID uint32
	Tasks    []types.Task `json:"tasks"`
}

type PutTaskListResponse

type PutTaskListResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Warnings []error  `json:"warnings"`
}

type PutTimeProfileRequest

type PutTimeProfileRequest struct {
	DeviceID    uint32
	TimeProfile types.TimeProfile
}

type PutTimeProfileResponse

type PutTimeProfileResponse struct {
	DeviceID    DeviceID          `json:"device-id"`
	TimeProfile types.TimeProfile `json:"time-profile"`
}

type PutTimeProfilesRequest

type PutTimeProfilesRequest struct {
	DeviceID uint32
	Profiles []types.TimeProfile `json:"profiles"`
}

type PutTimeProfilesResponse

type PutTimeProfilesResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Warnings []error  `json:"warnings"`
}

type SetTimeRequest

type SetTimeRequest struct {
	DeviceID DeviceID
	DateTime types.DateTime
}

type SetTimeResponse

type SetTimeResponse struct {
	DeviceID DeviceID       `json:"device-id"`
	DateTime types.DateTime `json:"date-time"`
}

type Status

type Status struct {
	DoorState      map[uint8]bool `json:"door-states"`
	DoorButton     map[uint8]bool `json:"door-buttons"`
	SystemError    uint8          `json:"system-error"`
	SystemDateTime types.DateTime `json:"system-datetime"`
	SequenceId     uint32         `json:"sequence-id"`
	SpecialInfo    uint8          `json:"special-info"`
	RelayState     uint8          `json:"relay-state"`
	InputState     uint8          `json:"input-state"`
	Event          Event          `json:"event,omitempty"`
}

type UHPPOTED

type UHPPOTED struct {
	UHPPOTE         uhppote.IUHPPOTE
	ListenBatchSize int
}

func (*UHPPOTED) ActivateKeypads added in v0.8.6

func (u *UHPPOTED) ActivateKeypads(controller uint32, keypads map[uint8]bool) error

func (*UHPPOTED) ClearTimeProfiles

func (u *UHPPOTED) ClearTimeProfiles(request ClearTimeProfilesRequest) (*ClearTimeProfilesResponse, error)

func (*UHPPOTED) DeleteCard

func (u *UHPPOTED) DeleteCard(request DeleteCardRequest) (*DeleteCardResponse, error)

func (*UHPPOTED) DeleteCards

func (u *UHPPOTED) DeleteCards(request DeleteCardsRequest) (*DeleteCardsResponse, error)

func (*UHPPOTED) FetchEvents added in v0.8.7

func (u *UHPPOTED) FetchEvents(controller uint32, from uint32, N uint32) ([]types.Event, error)

func (*UHPPOTED) GetCard

func (u *UHPPOTED) GetCard(request GetCardRequest) (*GetCardResponse, error)

func (*UHPPOTED) GetCardRecords

func (u *UHPPOTED) GetCardRecords(request GetCardRecordsRequest) (*GetCardRecordsResponse, error)

func (*UHPPOTED) GetCards

func (u *UHPPOTED) GetCards(request GetCardsRequest) (*GetCardsResponse, error)

func (*UHPPOTED) GetDevice

func (u *UHPPOTED) GetDevice(request GetDeviceRequest) (*GetDeviceResponse, error)

func (*UHPPOTED) GetDevices

func (u *UHPPOTED) GetDevices(request GetDevicesRequest) (*GetDevicesResponse, error)

func (*UHPPOTED) GetDoorControl

func (u *UHPPOTED) GetDoorControl(request GetDoorControlRequest) (*GetDoorControlResponse, error)

func (*UHPPOTED) GetDoorDelay

func (u *UHPPOTED) GetDoorDelay(request GetDoorDelayRequest) (*GetDoorDelayResponse, error)

func (*UHPPOTED) GetEvent

func (u *UHPPOTED) GetEvent(deviceID uint32, index uint32) (*Event, error)

func (*UHPPOTED) GetEventIndices added in v0.7.2

func (u *UHPPOTED) GetEventIndices(deviceID uint32) (uint32, uint32, uint32, error)

func (*UHPPOTED) GetEvents added in v0.7.2

func (u *UHPPOTED) GetEvents(deviceID uint32, N int) ([]Event, error)

Retrieves up to N events subsequent to the 'current' event index (or the 'first' event if the current event index is less than the first event index). The on-device index is updated to the index of the last retrieved event.

func (*UHPPOTED) GetStatus

func (u *UHPPOTED) GetStatus(deviceID uint32) (*Status, error)

func (*UHPPOTED) GetTime

func (u *UHPPOTED) GetTime(request GetTimeRequest) (*GetTimeResponse, error)

func (*UHPPOTED) GetTimeProfile

func (u *UHPPOTED) GetTimeProfile(request GetTimeProfileRequest) (*GetTimeProfileResponse, error)

func (*UHPPOTED) GetTimeProfiles

func (u *UHPPOTED) GetTimeProfiles(request GetTimeProfilesRequest) (*GetTimeProfilesResponse, error)

func (*UHPPOTED) OpenDoor

func (u *UHPPOTED) OpenDoor(request OpenDoorRequest) (*OpenDoorResponse, error)

func (*UHPPOTED) PutCard

func (u *UHPPOTED) PutCard(deviceID uint32, card types.Card) (bool, error)

func (*UHPPOTED) PutTaskList

func (u *UHPPOTED) PutTaskList(request PutTaskListRequest) (*PutTaskListResponse, int, error)

func (*UHPPOTED) PutTimeProfile

func (u *UHPPOTED) PutTimeProfile(request PutTimeProfileRequest) (*PutTimeProfileResponse, error)

func (*UHPPOTED) PutTimeProfiles

func (u *UHPPOTED) PutTimeProfiles(request PutTimeProfilesRequest) (*PutTimeProfilesResponse, int, error)

func (*UHPPOTED) RecordSpecialEvents

func (u *UHPPOTED) RecordSpecialEvents(deviceID uint32, enable bool) (bool, error)

Unwraps the request and dispatches the corresponding controller command to enable or disable door open, door close and door button press events for the controller.

func (*UHPPOTED) RestoreDefaultParameters added in v0.8.8

func (u *UHPPOTED) RestoreDefaultParameters(controller uint32) error

Unwraps the request and dispatches the corresponding controller command to restore the manufacturer default configuration.

func (*UHPPOTED) SetDoorControl

func (u *UHPPOTED) SetDoorControl(controller uint32, door uint8, mode types.ControlState) error

func (*UHPPOTED) SetDoorDelay

func (u *UHPPOTED) SetDoorDelay(controller uint32, door uint8, delay uint8) error

func (*UHPPOTED) SetDoorPasscodes added in v0.8.7

func (u *UHPPOTED) SetDoorPasscodes(controller uint32, door uint8, passcodes ...uint32) error

func (*UHPPOTED) SetEventListener added in v0.7.3

func (u *UHPPOTED) SetEventListener(deviceID uint32, address types.ListenAddr) (bool, error)

func (*UHPPOTED) SetInterlock added in v0.8.5

func (u *UHPPOTED) SetInterlock(controller uint32, interlock types.Interlock) error

func (*UHPPOTED) SetTime

func (u *UHPPOTED) SetTime(request SetTimeRequest) (*SetTimeResponse, error)

Jump to

Keyboard shortcuts

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