hap-controller
Version:
Library to implement a HAP (HomeKit) controller
168 lines • 5.04 kB
TypeScript
/**
* Zeroconf wrappers for finding HAP devices.
*/
import { EventEmitter } from 'events';
/**
* Service data structure returned by discovery methods
*/
export interface HapServiceIp {
/**
* name: the Bonjour name of the HomeKit accessory (i.e. Testsensor1._hap._tcp.local.)
*/
name: string;
/**
* address: the first discovered IP address of the accessory
*/
address: string;
/**
* allAddresses: all discovered IP addresses of the accessory
*/
allAddresses: string[];
/**
* port: the used port
*/
port: number;
/**
* c#: the configuration number (required),
* monitor that value and refresh device definition if it increases
*
* From Specs:
* Must update when an accessory, service, or characteristic is added or removed
* on the accessory server. Accessories must increment the config number after a firmware update.
* This must have a range of 1-65535 and wrap to 1 when it overflows.
* This value must persist across reboots, power cycles, etc.
*/
'c#': number;
/**
* ff / flags: the numerical and human readable version of the feature flags
*
* From Specs:
* Pairing Feature flags (e.g. ”0x3” for bits 0 and 1). Required if non-zero.
* See Table 5-4 (page 49).
* See PairingFeatureFlags
*/
ff: number;
/**
* id: Device ID (”5.4 Device ID” (page 31)) of the accessory.
*
* From Specs:
* The Device ID must be formatted as ”XX:XX:XX:XX:XX:XX”, where ”XX” is a hexadecimal string
* representing a byte. Required.
* This value is also used as the accessoryʼs Pairing Identifier.
*/
id: string;
/**
* md: the Model name of the accessory (e.g. ”Device1,1”). Required.
*/
md: string;
/**
* pv: the protocol version
*
* From Specs:
* Protocol version string ”X.Y” (e.g. ”1.0”). Required if value is not ”1.0”.
* (see ”6.6.3 IP Protocol Version” (page 61))
* It must be set to ”1.1” for this version of HAP IP.
*/
pv: string;
/**
* s#: Current state number. Required.
*
* From Specs:
* This must have a value of ”1”.
*/
's#': number;
/**
* sf / statusflags: Status flags. Required
*
* From Specs:
* (e.g. ”0x04” for bit 3). Value should be an unsigned integer.
* See Table 6-8 (page 58)
* See DiscoveryStatusFlags
*/
sf: number;
/**
* ci / category: the category identifier in numerical and human readable form. Required.
*
* From Specs:
* Indicates the category that best describes the primary function of the accessory.
* This must have a range of 1-65535. This must take values defined in
* ”13-1 Accessory Categories” (page 252).
* This must persist across reboots, power cycles, etc.
*/
ci: number;
/**
* Added in v2 of the HAP specifications but no details known
* sh: Setup Hash.
*
* From Specs:
* See (”?? ??” (page ??)) Required if the accessory supports enhanced setup payload information.
*/
/**
* availableToPair: is the device available for pairing?
*/
availableToPair: boolean;
}
/**
* See Table 6-8
*/
declare const DiscoveryPairingStatusFlags: {
AccessoryNotPaired: number;
AccessoryNotConfiguredToJoinWifi: number;
AccessoryHasProblems: number;
};
/**
* See Table 5-4
*/
declare const DiscoveryPairingFeatureFlags: {
SupportsAppleAuthenticationCoprocessor: number;
SupportsSoftwareAuthentication: number;
};
export { DiscoveryPairingStatusFlags, DiscoveryPairingFeatureFlags };
/**
* Handle discovery of IP devices
*
* @fires IPDiscovery#serviceUp
* @fires IPDiscovery#serviceDown
* @fires IPDiscovery#serviceChanged
*/
export default class IPDiscovery extends EventEmitter {
private browser;
private iface?;
private services;
/**
* Initialize the IPDiscovery object.
*
* @param {string?} iface - Optional interface to bind to
*/
constructor(iface?: string);
/**
* Convert a DNS-SD service record to a HAP service object.
*
* See Table 5-7
*
* @param {Object} service - Service record to convert
*/
private static _serviceToHapService;
/**
* Get PairMethod to use for pairing from the data received during discovery
*
* @param {HapServiceIp} service Discovered service object to check
* @returns {Promise<number>} Promise which resolves with the PairMethod to use
*/
getPairMethod(service: HapServiceIp): Promise<number>;
/**
* Start searching for HAP devices on the network.
*/
start(): void;
/**
* List the currently known services.
*
* @returns {HapServiceIp[]} Array of services
*/
list(): HapServiceIp[];
/**
* Stop an ongoing discovery process.
*/
stop(): void;
}
//# sourceMappingURL=ip-discovery.d.ts.map