uhppoted

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: MIT Imports: 17 Imported by: 10

Documentation

Index

Constants

View Source
const (
	StatusOK                  = http.StatusOK
	StatusBadRequest          = http.StatusBadRequest
	StatusNotFound            = http.StatusNotFound
	StatusUnauthorized        = http.StatusUnauthorized
	StatusInternalServerError = http.StatusInternalServerError
)
View Source
const BATCHSIZE = 32
View Source
const ROLLOVER = uint32(100000)

Variables

View Source
var (
	BadRequest          = errors.New("Bad Request")
	NotFound            = errors.New("Not Found")
	Unauthorized        = errors.New("Not Authorized")
	InternalServerError = errors.New("INTERNAL SERVER ERROR")
)

Functions

func IsDevNull

func IsDevNull(path string) bool

Types

type ClearTimeProfilesRequest

type ClearTimeProfilesRequest struct {
	DeviceID uint32
}

type ClearTimeProfilesResponse

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

type ControlState

type ControlState uint8
const (
	NormallyOpen   ControlState = 1
	NormallyClosed ControlState = 2
	Controlled     ControlState = 3
)

func (ControlState) MarshalJSON

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

func (*ControlState) UnmarshalJSON

func (s *ControlState) UnmarshalJSON(bytes []byte) (err error)

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 {
	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"`
}

type EventHandler

type EventHandler func(EventMessage) bool

type EventIndex

type EventIndex uint32

type EventMap

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

func NewEventMap

func NewEventMap(file string) *EventMap

func (*EventMap) Load

func (m *EventMap) Load(log *log.Logger) error

type EventMessage

type EventMessage struct {
	Event ListenEvent `json:"event"`
}

type EventRange

type EventRange struct {
	First *uint32 `json:"first,omitempty"`
	Last  *uint32 `json:"last,omitempty"`
}

func (*EventRange) String

func (e *EventRange) String() string

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  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 GetEventRangeRequest

type GetEventRangeRequest struct {
	DeviceID DeviceID
	Start    *types.DateTime
	End      *types.DateTime
}

type GetEventRangeResponse

type GetEventRangeResponse struct {
	DeviceID DeviceID    `json:"device-id,omitempty"`
	Dates    *DateRange  `json:"dates,omitempty"`
	Events   *EventRange `json:"events,omitempty"`
}

type GetEventRequest

type GetEventRequest struct {
	DeviceID DeviceID
	EventID  uint32
}

type GetEventResponse

type GetEventResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Event    Event    `json:"event"`
}

type GetStatusRequest

type GetStatusRequest struct {
	DeviceID DeviceID
}

type GetStatusResponse

type GetStatusResponse struct {
	DeviceID DeviceID `json:"device-id"`
	Status   Status   `json:"status"`
}

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)
	SetDoorDelay(request SetDoorDelayRequest) (*SetDoorDelayResponse, error)
	GetDoorControl(request GetDoorControlRequest) (*GetDoorControlResponse, error)
	SetDoorControl(request SetDoorControlRequest) (*SetDoorControlResponse, error)
	RecordSpecialEvents(request RecordSpecialEventsRequest) (*RecordSpecialEventsResponse, error)
	GetStatus(request GetStatusRequest) (*GetStatusResponse, error)
	GetCardRecords(request GetCardRecordsRequest) (*GetCardRecordsResponse, error)
	GetCards(request GetCardsRequest) (*GetCardsResponse, error)
	DeleteCards(request DeleteCardsRequest) (*DeleteCardsResponse, error)
	GetCard(request GetCardRequest) (*GetCardResponse, error)
	PutCard(request PutCardRequest) (*PutCardResponse, 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)
	GetEventRange(request GetEventRangeRequest) (*GetEventRangeResponse, error)
	GetEvent(request GetEventRequest) (*GetEventResponse, error)
	OpenDoor(request OpenDoorRequest) (*OpenDoorResponse, error)
}

type ListenEvent

type ListenEvent struct {
	DeviceID   DeviceID       `json:"device-id"`
	EventID    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"`
}

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 PutCardRequest

type PutCardRequest struct {
	DeviceID DeviceID
	Card     types.Card
}

type PutCardResponse

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

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 RecordSpecialEventsRequest

type RecordSpecialEventsRequest struct {
	DeviceID DeviceID
	Enable   bool
}

type RecordSpecialEventsResponse

type RecordSpecialEventsResponse struct {
	DeviceID DeviceID
	Enable   bool
	Updated  bool
}

type SetDoorControlRequest

type SetDoorControlRequest struct {
	DeviceID DeviceID
	Door     uint8
	Control  ControlState
}

type SetDoorControlResponse

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

type SetDoorDelayRequest

type SetDoorDelayRequest struct {
	DeviceID DeviceID
	Door     uint8
	Delay    uint8
}

type SetDoorDelayResponse

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

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          *StatusEvent   `json:"event,omitempty"`
}

type StatusEvent

type StatusEvent struct {
	Index      uint32          `json:"index"`
	Type       byte            `json:"type"`
	Granted    bool            `json:"access-granted"`
	Door       byte            `json:"door"`
	Direction  uint8           `json:"direction"`
	CardNumber uint32          `json:"card-number"`
	Timestamp  *types.DateTime `json:"timestamp,omitempty"`
	Reason     uint8           `json:"reason"`
}

type UHPPOTED

type UHPPOTED struct {
	UHPPOTE         uhppote.IUHPPOTE
	ListenBatchSize int
	Log             *log.Logger
}

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) 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(request GetEventRequest) (*GetEventResponse, error)

func (*UHPPOTED) GetEventRange

func (u *UHPPOTED) GetEventRange(request GetEventRangeRequest) (*GetEventRangeResponse, error)

func (*UHPPOTED) GetStatus

func (u *UHPPOTED) GetStatus(request GetStatusRequest) (*GetStatusResponse, 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) Listen

func (u *UHPPOTED) Listen(handler EventHandler, received *EventMap, q chan os.Signal)

func (*UHPPOTED) OpenDoor

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

func (*UHPPOTED) PutCard

func (u *UHPPOTED) PutCard(request PutCardRequest) (*PutCardResponse, 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(request RecordSpecialEventsRequest) (*RecordSpecialEventsResponse, 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) SetDoorControl

func (u *UHPPOTED) SetDoorControl(request SetDoorControlRequest) (*SetDoorControlResponse, error)

func (*UHPPOTED) SetDoorDelay

func (u *UHPPOTED) SetDoorDelay(request SetDoorDelayRequest) (*SetDoorDelayResponse, 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