import { BluetoothAutomationProductConfig, BluetoothAutomationRuntimeMode, BluetoothAutomationMode, BluetoothDeviceMonitorStateType } from './constants'; import EventEmitter from 'event-emitter-for-miniprogram'; import { BlueToothAdapter4Mp, BlueToothDeviceInfo, DeviceAdapter } from 'qcloud-iotexplorer-bluetooth-adapter'; import { BluetoothAutomationReporter } from './BluetoothAutomationReporter'; import { BluetoothAutomationUserConfig } from './BluetoothAutomationUserConfig'; import { BluetoothDeviceMonitorState } from './BluetoothDeviceMonitorState'; import { Observable } from 'rxjs'; import type { Subscription } from 'rxjs'; interface MonitoredBluetoothDeviceOptions { isDeviceAdapterBusy: () => boolean; isDeviceAdapterInUse: () => boolean; isDevMode: () => boolean; disableDeviceAutomation: () => Promise; handleUserAuthDeny: () => void; setBluetoothBackgroundMode: (enable: boolean) => Promise; prefetchDeviceTicket: () => Promise; blueToothAdapter: BlueToothAdapter4Mp; getSearchResult: () => Promise; fetchAutomationConfig: () => Promise; getRuntimeMode: () => BluetoothAutomationRuntimeMode; reportDeviceEvent: (options: { DeviceId: string; EventId: string; Params: Record; }) => Promise; reporter: BluetoothAutomationReporter; } export interface ExecuteActionEventParams { explorerDeviceId: string; bluetoothDeviceId: string; actionName: string; } export interface StateChangeEventParams { oldState: BluetoothDeviceMonitorState; newState: BluetoothDeviceMonitorState; } export declare class BluetoothDeviceMonitor extends EventEmitter { userConfig: BluetoothAutomationUserConfig; protected options: MonitoredBluetoothDeviceOptions; /** 对应产品的无感配置 */ config: BluetoothAutomationProductConfig; deviceAdapterObservable: Observable; /** 状态机状态转移队列,用于在嵌套的状态转移操作中保持正确的时序 */ protected stateChangeQueue: Array<{ oldState: BluetoothDeviceMonitorState; newState: BluetoothDeviceMonitorState; }>; /** 状态机当前的状态对象 */ protected state: BluetoothDeviceMonitorState; /** 当前操作的 DeviceAdapter */ protected deviceAdapter: DeviceAdapter | null; protected runningSolution: Subscription; constructor(userConfig: BluetoothAutomationUserConfig, options: MonitoredBluetoothDeviceOptions); destroy(): void; get explorerDeviceId(): string; get bluetoothDeviceId(): string; get currentStateType(): BluetoothDeviceMonitorStateType; get currentState(): BluetoothDeviceMonitorState; startMonitoring(): Promise; stopMonitoring({ keepConnection }?: { keepConnection?: boolean; }): void; updateUserConfig(userConfig: BluetoothAutomationUserConfig): void; updateConfig(config: BluetoothAutomationProductConfig): void; startSolution(): void; stopRunningSolution(): void; update(deltaTime: number): void; /** 状态机状态转移 */ enterState(oldState: BluetoothDeviceMonitorState, newState: BluetoothDeviceMonitorState): void; getDeviceAdapter(): DeviceAdapter; setDeviceAdapter(adapter: DeviceAdapter): void; tryGetDeviceAdapter(): DeviceAdapter | null; setBluetoothBackgroundMode(enable: boolean): Promise; prefetchDeviceTicket(): Promise; onExecuteAction(handler: (params: ExecuteActionEventParams) => void): void; offExecuteAction(handler?: (params: ExecuteActionEventParams) => void): void; onStateChange(handler: (params: StateChangeEventParams) => void): void; offStateChange(handler?: (params: StateChangeEventParams) => void): void; onDisable(handler: () => void): void; offDisable(handler?: () => void): void; emitDisable(): void; disableDeviceAutomation(): Promise; handleUserAuthDeny(): void; handleDeviceConnectStatusChange({ connected }: { connected: boolean; }): void; getSearchResult(): Promise; fetchAutomationConfig(): Promise; getCurrentStateByType(type: BluetoothDeviceMonitorStateType): T | null; controlDeviceProperty(deviceData: Record): Promise; reportDeviceEvent(options: { EventId: string; Params: Record; }): Promise; callDeviceAction(actionId: string, params: Record): Promise; isBluetoothEnabled(): boolean; emitSolutionEvent(event: string, payload?: unknown): void; get isDeviceAdapterBusy(): boolean; get isDeviceAdapterInUse(): boolean; get isDevMode(): boolean; get modeConfig(): BluetoothAutomationMode; get commonReportParams(): { explorerDeviceId: string; bluetoothDeviceId: string; }; get blueToothAdapter(): BlueToothAdapter4Mp; get reporter(): BluetoothAutomationReporter; get solutionTypeStr(): string; protected enterStateInternal(oldState: BluetoothDeviceMonitorState, newState: BluetoothDeviceMonitorState): void; } export {};