Documentation
¶
Index ¶
- Constants
- func PrepareServer(server *http.Server, acc map[uint16]Accessory, options ...option) *http.Server
- func WithLogger(logger log.Logger) option
- func WriteJSON(rw http.ResponseWriter, httpCode int, data interface{}) error
- func WriteStatus(rw http.ResponseWriter, httpCode int, hapCode Status) error
- type Accessory
- type AccessoryResource
- type Characteristic
- type CharacteristicID
- type CharacteristicMeta
- type CharacteristicNotifier
- type CharacteristicReader
- type CharacteristicWriter
- type Handler
- type Notifier
- type Service
- type Status
Constants ¶
View Source
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) )
Variables ¶
This section is empty.
Functions ¶
func PrepareServer ¶
PrepareServer will create a notification.Manager, hook it to the connection events and wrap the server.Handler with an initialized hapip.Handler.
func WithLogger ¶
WithLogger adds structured logging to the pairing server.
func WriteStatus ¶
func WriteStatus(rw http.ResponseWriter, httpCode int, hapCode Status) error
Types ¶
type AccessoryResource ¶
type Characteristic ¶
type Characteristic interface {
Type() string
Meta() CharacteristicMeta
}
type CharacteristicID ¶
func (CharacteristicID) String ¶
func (cid CharacteristicID) String() string
type CharacteristicMeta ¶
type CharacteristicNotifier ¶
type CharacteristicNotifier interface {
Characteristic
Notify(func(ctx context.Context, val, old interface{}))
}
type CharacteristicReader ¶
type CharacteristicReader interface {
Characteristic
Read(context.Context) (interface{}, error)
}
type CharacteristicWriter ¶
type CharacteristicWriter interface {
Characteristic
Write(context.Context, json.RawMessage) error
}
type Handler ¶
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().
func (*Handler) Initialize ¶
func (h *Handler) Initialize()
type Notifier ¶
type Notifier interface {
Subscribe(context.Context, CharacteristicID, bool) error
IsSubscribed(context.Context, CharacteristicID) (bool, error)
Publish(context.Context, CharacteristicID, io.WriterTo)
}
type Service ¶
type Service interface {
Type() string
Characteristics() []Characteristic
IsPrimary() bool
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.