import type * as Noble from "@stoprocent/noble"; import type { Chars, NobleTypes, SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from "./types/types.js"; import { Buffer } from "node:buffer"; import { EventEmitter } from "node:events"; /** * Represents a Switchbot Device. */ export declare class SwitchbotDevice extends EventEmitter { [x: string]: any; deviceAddress: string; private peripheral; private noble; private characteristics; private deviceId; private deviceModel; private deviceModelName; private deviceFriendlyName; private explicitlyConnected; private isConnected; private onNotify; private onDisconnect; private onConnect; /** * Initializes a new instance of the SwitchbotDevice class. * @param peripheral The peripheral object from noble. * @param noble The Noble object. */ constructor(peripheral: NobleTypes["peripheral"], noble: NobleTypes["noble"]); /** * Logs a message with the specified log level. * @param level The severity level of the log (e.g., 'info', 'warn', 'error'). * @param message The log message to be emitted. */ log(level: string, message: string): Promise; get id(): string; get address(): string; get model(): SwitchBotBLEModel; get modelName(): SwitchBotBLEModelName; get friendlyName(): SwitchBotBLEModelFriendlyName; get connectionState(): string; get onConnectHandler(): () => Promise; set onConnectHandler(func: () => Promise); get onDisconnectHandler(): () => Promise; set onDisconnectHandler(func: () => Promise); /** * Connects to the device. * @returns A Promise that resolves when the connection is complete. */ connect(): Promise; /** * Internal method to handle the connection process. * @returns A Promise that resolves when the connection is complete. */ private internalConnect; /** * Retrieves the device characteristics. * @returns A Promise that resolves with the device characteristics. */ getCharacteristics(): Promise; /** * Discovers the device services. * @returns A Promise that resolves with the list of services. */ discoverServices(): Promise; /** * Discovers the characteristics of a service. * @param service The service to discover characteristics for. * @returns A Promise that resolves with the list of characteristics. */ private discoverCharacteristics; /** * Subscribes to the notify characteristic. * @returns A Promise that resolves when the subscription is complete. */ private subscribeToNotify; /** * Unsubscribes from the notify characteristic. * @returns A Promise that resolves when the unsubscription is complete. */ unsubscribeFromNotify(): Promise; /** * Disconnects from the device. * @returns A Promise that resolves when the disconnection is complete. */ disconnect(): Promise; /** * Internal method to handle disconnection if not explicitly initiated. * @returns A Promise that resolves when the disconnection is complete. */ private internalDisconnect; /** * Retrieves the device name. * @returns A Promise that resolves with the device name. */ getDeviceName(): Promise; /** * Sets the device name. * @param name The new device name. * @returns A Promise that resolves when the name is set. */ setDeviceName(name: string): Promise; commandWithoutResponse(reqBuf: Buffer): Promise; /** * Sends a command to the device and awaits a response. * @param reqBuf The command buffer. * @returns A Promise that resolves with the response buffer. */ command(reqBuf: Buffer): Promise; /** * Waits for a response from the device after sending a command. * @returns A Promise that resolves with the response buffer. */ private waitForCommandResponse; /** * Reads data from a characteristic with a timeout. * @param char The characteristic to read from. * @returns A Promise that resolves with the data buffer. */ private readCharacteristic; /** * Writes data to a characteristic with a timeout. * @param char The characteristic to write to. * @param buf The data buffer. * @returns A Promise that resolves when the write is complete. */ private writeCharacteristic; } //# sourceMappingURL=device.d.ts.map