import "code.pfad.fr/gohmekit/hapip"
const ( StatusSuccess = Status(0) StatusInsufficientPrivileges = Status(-70401) StatusServiceCommunicationFailure = Status(-70402) StatusResourceBusy = Status(-70403) StatusReadOnlyCharacteristic = Status(-70404) StatusWriteOnlyCharacteristic = Status(-70405) StatusNotificationNotSupported = Status(-70406) StatusOutOfResource = Status(-70407) StatusOperationTimedOut = Status(-70408) StatusResourceDoesNotExist = Status(-70409) StatusInvalidValueInRequest = Status(-70410) )
PrepareServer will create a notification.Manager, hook it to the connection events and wrap the server.Handler with an initialized hapip.Handler.
WithLogger adds structured logging to the pairing server.
func WriteJSON(rw http.ResponseWriter, httpCode int, data interface{}) error
type AccessoryResource interface { Accessory Resource(rw http.ResponseWriter, typ string, width, height int) error }
type Characteristic interface { Type() string Meta() CharacteristicMeta }
func (cid CharacteristicID) String() string
type CharacteristicMeta struct { Format string // Optional Description string Unit string MaxLen int MinValue interface{} MaxValue interface{} MinStep interface{} ValidValues interface{} ValidRange interface{} MaxDataLen int }
type CharacteristicNotifier interface { Characteristic Notify(func(ctx context.Context, val, old interface{})) }
type CharacteristicReader interface { Characteristic Read(context.Context) (interface{}, error) }
type CharacteristicWriter interface { Characteristic Write(context.Context, json.RawMessage) error }
type Handler struct { Logger log.Logger Notifier Notifier Accessories map[uint16]Accessory // contains filtered or unexported fields }
Handler is a http.Handler to handle /accessories and /characterisitc request. It fields must not be changed after calling .Initialize().
type Notifier interface { Subscribe(context.Context, CharacteristicID, bool) error IsSubscribed(context.Context, CharacteristicID) (bool, error) Publish(context.Context, CharacteristicID, io.WriterTo) }
type Service interface { Type() string Characteristics() []Characteristic IsPrimary() bool }
handle_accessories.go handle_characteristics.go handle_notification.go handle_prepare.go handle_resource.go handler.go json.go
Path | Synopsis |
---|---|
characteristic | |
notification |