strike

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package strike provides mechanisms to interface with an electric door strike via a Raspberry Pi GPIO interface. This package was designed with two requirements in mind. The first being that the strike should only need to be unlocked for a given duration of time and it should not be up to the consumer to ensure the strike is locked again. The second being that if the strike is requested to be unlocked while it is already unlocked, the duration elapsed should be the time already elapsed plus the last unlock duration.

Index

Constants

View Source
const (
	// ErrStrikeNotInitialized is returned when unlock is called after Done() has been called on the strike.
	ErrStrikeNotInitialized = "strike cannot be unlocked after Done() has been called"

	// ErrCouldNotInitializeGPIOPin is returned when the GPIO pin for the strike can not be initialized.
	ErrCouldNotInitializeGPIOPin = "could not initialize the GPIO pin for the strike"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DoorStrike

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

DoorStrike is an implementation of the strike interface to control an electric door strike with a Raspberry Pi via the GPIO interface.

func NewDefaultDoorStrike

func NewDefaultDoorStrike() (*DoorStrike, error)

NewDefaultDoorStrike returns an initialized door strike on the default GPIO pin.

func NewDoorStrike

func NewDoorStrike(pin gpio.PinIO) (*DoorStrike, error)

NewDoorStrike returns an initialized DoorStrike ready for use.

func (*DoorStrike) Done

func (ds *DoorStrike) Done()

Done will clean up the electric strike cleanly and will allow for the GPIO pin to be reused.

func (*DoorStrike) Unlock

func (ds *DoorStrike) Unlock(dur time.Duration) error

Unlock unlocks the electric door strike for the provided duration. Unlock is thread safe and can be called simultaneously from multiple threads. If the duration of a previous call to Unlock has not elapsed, the total duration will be the elapsed duration of the previous call plus the new duration.

type Strike

type Strike interface {
	Unlock(dur time.Duration) error
	Done()
}

Strike is an interface for an electric door strike. This interface was created for the sole purpose of generating a mock for this package which can be found in the internal/mocks package.

Jump to

Keyboard shortcuts

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