Documentation ¶
Index ¶
- Constants
- Variables
- func Append(items ...any) (b []byte)
- func DecodeKey(s string) []byte
- func GenerateKey() []byte
- func GenerateUUID() string
- func ReadResponse(r *bufio.Reader, req *http.Request) (*http.Response, error)
- func SanitizePin(pin string) (string, error)
- func Unpair(rawURL string) error
- func WriteResponse(w *bufio.Writer, statusCode int, contentType string, body []byte) error
- type Accessory
- type Character
- func (c *Character) AddListener(w io.Writer)
- func (c *Character) GenerateEvent() (data []byte, err error)
- func (c *Character) NotifyListeners(ignore io.Writer) error
- func (c *Character) ReadBool() bool
- func (c *Character) ReadTLV8(v any) (err error)
- func (c *Character) RemoveListener(w io.Writer)
- func (c *Character) Set(v any) (err error)
- func (c *Character) String() string
- func (c *Character) Write(v any) (err error)
- type Client
- func (c *Client) ClientPublic() []byte
- func (c *Client) Close() error
- func (c *Client) DeletePairing(id string) error
- func (c *Client) DeviceHost() string
- func (c *Client) Dial() (err error)
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) Get(path string) (*http.Response, error)
- func (c *Client) GetAccessories() ([]*Accessory, error)
- func (c *Client) GetCharacter(char *Character) error
- func (c *Client) GetCharacters(query string) ([]JSONCharacter, error)
- func (c *Client) GetFirstAccessory() (*Accessory, error)
- func (c *Client) GetImage(width, height int) ([]byte, error)
- func (c *Client) ListPairings() error
- func (c *Client) LocalIP() string
- func (c *Client) Pair(feature, pin string) (err error)
- func (c *Client) PairingsAdd(clientID string, clientPublic []byte, admin bool) error
- func (c *Client) Post(path, contentType string, body io.Reader) (*http.Response, error)
- func (c *Client) Put(path, contentType string, body io.Reader) (*http.Response, error)
- func (c *Client) PutCharacters(characters ...*Character) error
- func (c *Client) Request(method, path, contentType string, body io.Reader) (*http.Response, error)
- func (c *Client) URL() string
- type HandlerFunc
- type JSONAccessories
- type JSONCharacter
- type JSONCharacters
- type Server
- type Service
Constants ¶
View Source
const ( FormatString = "string" FormatBool = "bool" FormatFloat = "float" FormatUInt8 = "uint8" FormatUInt16 = "uint16" FormatUInt32 = "uint32" FormatInt32 = "int32" FormatUInt64 = "uint64" FormatData = "data" FormatTLV8 = "tlv8" UnitPercentage = "percentage" )
View Source
const ( ConnDialTimeout = time.Second * 3 ConnDeadline = time.Second * 3 )
View Source
const ( MimeTLV8 = "application/pairing+tlv8" MimeJSON = "application/hap+json" PathPairSetup = "/pair-setup" PathPairVerify = "/pair-verify" PathPairings = "/pairings" PathAccessories = "/accessories" PathCharacteristics = "/characteristics" PathResource = "/resource" )
View Source
const ( TXTConfigNumber = "c#" // Current configuration number (ex. 1, 2, 3) TXTDeviceID = "id" // Device ID of the accessory (ex. 77:75:87:A0:7D:F4) TXTModel = "md" // Model name of the accessory (ex. MJCTD02YL) TXTProtoVersion = "pv" // Protocol version string (ex. 1.1) TXTStateNumber = "s#" // Current state number (ex. 1) TXTCategory = "ci" // Accessory Category Identifier (ex. 2, 5, 17) TXTSetupHash = "sh" // Setup hash (ex. Y9w9hQ==) // TXTFeatureFlags // - 0001b - Supports Apple Authentication Coprocessor // - 0010b - Supports Software Authentication TXTFeatureFlags = "ff" // Pairing Feature flags (ex. 0, 1, 2) // TXTStatusFlags // - 0001b - Accessory has not been paired with any controllers // - 0100b - A problem has been detected on the accessory TXTStatusFlags = "sf" // Status flags (ex. 0, 1) StatusPaired = "0" StatusNotPaired = "1" CategoryBridge = "2" CategoryCamera = "17" CategoryDoorbell = "18" StateM1 = 1 StateM2 = 2 StateM3 = 3 StateM4 = 4 StateM5 = 5 StateM6 = 6 MethodPair = 0 MethodPairMFi = 1 // if device has MFI cert MethodVerifyPair = 2 MethodAddPairing = 3 MethodDeletePairing = 4 MethodListPairings = 5 PermissionUser = 0 PermissionAdmin = 1 )
View Source
const ( PairMethodSetup = iota PairMethodSetupWithAuth PairMethodVerify PairMethodAdd PairMethodRemove PairMethodList )
View Source
const DeviceAID = 1 // TODO: fix someday
View Source
const ProtoEvent = "EVENT/1.0"
Variables ¶
View Source
var EVPR = []string{"ev", "pr"}
View Source
var EVPRPW = []string{"ev", "pr", "pw"}
View Source
var PR = []string{"pr"}
View Source
var PRPW = []string{"pr", "pw"}
View Source
var PW = []string{"pw"}
Functions ¶
func GenerateKey ¶
func GenerateKey() []byte
func GenerateUUID ¶
func GenerateUUID() string
func SanitizePin ¶
Types ¶
type Accessory ¶
type Accessory struct { AID uint8 `json:"aid"` // 150 unique accessories per bridge Services []*Service `json:"services"` }
func (*Accessory) GetCharacter ¶
func (*Accessory) GetCharacterByID ¶
func (*Accessory) GetService ¶
type Character ¶
type Character struct { Desc string `json:"description,omitempty"` IID uint64 `json:"iid"` Type string `json:"type"` Format string `json:"format"` Value any `json:"value,omitempty"` Perms []string `json:"perms"` // contains filtered or unexported fields }
Character - Aqara props order Value should be omit for PW Value may be empty for PR
func (*Character) AddListener ¶
func (*Character) GenerateEvent ¶
GenerateEvent with raw HTTP headers
func (*Character) RemoveListener ¶
type Client ¶
type Client struct { DeviceAddress string // including port DeviceID string // aka. Accessory DevicePublic []byte ClientID string // aka. Controller ClientPrivate []byte OnEvent func(res *http.Response) Conn net.Conn // contains filtered or unexported fields }
Client for HomeKit. DevicePublic can be null.
func (*Client) ClientPublic ¶
func (*Client) DeletePairing ¶
func (*Client) DeviceHost ¶
func (*Client) GetAccessories ¶
func (*Client) GetCharacter ¶
func (*Client) GetCharacters ¶
func (c *Client) GetCharacters(query string) ([]JSONCharacter, error)
func (*Client) GetFirstAccessory ¶
func (*Client) ListPairings ¶
func (*Client) PairingsAdd ¶
func (*Client) PutCharacters ¶
type HandlerFunc ¶
type JSONAccessories ¶
type JSONAccessories struct {
Value []*Accessory `json:"accessories"`
}
type JSONCharacter ¶
type JSONCharacters ¶
type JSONCharacters struct {
Value []JSONCharacter `json:"characteristics"`
}
type Server ¶
type Server struct { Pin string DeviceID string DevicePrivate []byte GetPair func(conn net.Conn, id string) []byte AddPair func(conn net.Conn, id string, public []byte, permissions byte) Handler HandlerFunc }
func (*Server) PairVerify ¶
func (*Server) ServerPublic ¶
type Service ¶
type Service struct { Desc string `json:"description,omitempty"` Type string `json:"type"` IID uint64 `json:"iid"` Primary bool `json:"primary,omitempty"` Characters []*Character `json:"characteristics"` Linked []int `json:"linked,omitempty"` }
func ServiceHAPProtocolInformation ¶
func ServiceHAPProtocolInformation() *Service
func (*Service) GetCharacter ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.