💾 Archived View for code.pfad.fr › gohmekit › hapip captured on 2024-02-05 at 09:36:59. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-12-28)

-=-=-=-=-=-=-

hapip package - code.pfad.fr/gohmekit

import "code.pfad.fr/gohmekit/hapip"

Constants

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

Functions

func PrepareServer

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

func WithLogger(logger log.Logger) option

WithLogger adds structured logging to the pairing server.

func WriteJSON

func WriteJSON(rw http.ResponseWriter, httpCode int, data interface{}) error

func WriteStatus

func WriteStatus(rw http.ResponseWriter, httpCode int, hapCode Status) error

Types

type Accessory

type Accessory interface {
	Services() []Service
}

type AccessoryResource

type AccessoryResource interface {
	Accessory
	Resource(rw http.ResponseWriter, typ string, width, height int) error
}

type Characteristic

type Characteristic interface {
	Type() string
	Meta() CharacteristicMeta
}

type CharacteristicID

type CharacteristicID struct {
	AID uint16
	IID uint32
}

func (CharacteristicID) String

func (cid CharacteristicID) String() string

type CharacteristicMeta

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

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()

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

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
}

type Status

type Status int

Files

handle_accessories.go

handle_characteristics.go

handle_notification.go

handle_prepare.go

handle_resource.go

handler.go

json.go

Directories

characteristic

notification

Breadcrumb

code.pfad.fr/gohmekit