💾 Archived View for code.pfad.fr › gohmekit › hapip captured on 2023-12-28 at 15:35:32. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
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) )
func PrepareServer(server *http.Server, acc map[uint16]Accessory, options ...option) *http.Server
PrepareServer will create a notification.Manager, hook it to the connection events and wrap the server.Handler with an initialized hapip.Handler.
func WithLogger(logger log.Logger) option
WithLogger adds structured logging to the pairing server.
func WriteJSON(rw http.ResponseWriter, httpCode int, data interface{}) error
func WriteStatus(rw http.ResponseWriter, httpCode int, hapCode Status) error
type Accessory interface { Services() []Service }
type AccessoryResource interface { Accessory Resource(rw http.ResponseWriter, typ string, width, height int) error }
type Characteristic interface { Type() string Meta() CharacteristicMeta }
type CharacteristicID struct { AID uint16 IID uint32 }
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().
func (h *Handler) Initialize()
func (h Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
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 }
type Status int