hap-controller
Version:
Library to implement a HAP (HomeKit) controller
98 lines • 3.2 kB
TypeScript
/**
* Class to represent a multi-request GATT connection.
*/
import { EventEmitter } from 'events';
import { Characteristic, Peripheral } from '@stoprocent/noble';
import { SessionKeys } from '../../protocol/pairing-protocol';
export default class GattConnection extends EventEmitter {
private peripheral;
private sessionKeys;
private a2cCounter;
private c2aCounter;
private queue;
/**
* Initialize the GattConnection object.
*
* @param {Object} peripheral - Peripheral object from noble
*/
constructor(peripheral: Peripheral);
/**
* Queue an operation for the connection.
*
* @param {function} op - Function to add to the queue
* @returns {Promise} Promise which resolves when the function is called.
*/
private _queueOperation;
/**
* Set the session keys for the connection.
*
* @param {Object} keys - The session key object obtained from PairingProtocol
*/
setSessionKeys(keys: SessionKeys): void;
/**
* Get the State of the peripheral connection
* Deprecated, please change to "isConnected"
*
* @returns {Boolean} Connection State
* @deprecated
*/
isPeripheralConnected(): boolean;
/**
* Get the State of the peripheral connection
*
* @returns {Boolean} Connection State
*/
isConnected(): boolean;
/**
* Connect to the peripheral if necessary.
*
* @returns {Promise} Promise which resolves when the connection is
* established.
*/
connect(): Promise<void>;
/**
* Disconnect from the peripheral if necessary.
*
* @returns {Promise} Promise which resolves when the connection is destroyed.
*/
disconnect(): Promise<void>;
/**
* Encrypt a series of PDUs.
*
* @param {Buffer[]} pdus - List of PDUs to encrypt
* @returns {Buffer[]} List of encrypted PDUs.
*/
private _encryptPdus;
/**
* Decrypt a series of PDUs.
*
* @param {Buffer} pdu - PDU to decrypt
* @returns {Buffer} Decrypted PDU.
*/
private _decryptPdu;
/**
* Write a series of PDUs to a characteristic.
*
* @param {Object} characteristic - Characteristic object to write to
* @param {Buffer[]} pdus - List of PDUs to send
* @returns {Promise} Promise which resolves to a list of responses when all
* writes are sent.
*/
writeCharacteristic(characteristic: Characteristic, pdus: Buffer[]): Promise<Buffer[]>;
/**
* Read a series of PDUs from a characteristic.
*
* @param {Object} characteristic - Characteristic object to write to
* @param {Buffer[]} pdus - List of PDUs already read
* @returns {Promise} Promise which resolves to a list of PDUs.
*/
private _readCharacteristicInner;
/**
* Read a series of PDUs from a characteristic.
*
* @param {Object} characteristic - Characteristic object to write to
* @returns {Promise} Promise which resolves to a list of PDUs.
*/
readCharacteristic(characteristic: Characteristic): Promise<Buffer[]>;
}
//# sourceMappingURL=gatt-connection.d.ts.map