/** * Data for a connection event. * @category Pixels */ export interface PixelSessionConnectionEvent { systemId: string; status: "connecting" | "connected" | "failedToConnect" | "ready" | "disconnecting" | "disconnected"; reason: "unknown" | "success" | "canceled" | "notSupported" | "timeout" | "linkLoss" | "bluetoothOff" | "host" | "peripheral"; } /** * List of possible connection statuses for a {@link PixelSession}. * @category Pixels */ export type PixelSessionConnectionStatus = PixelSessionConnectionEvent["status"]; /** * List of possible reasons for a connection event of a {@link PixelSession}. * @category Pixels */ export type PixelSessionConnectionEventReason = PixelSessionConnectionEvent["reason"]; /** * Represents a session with a Pixel die. * This class is used to abstract the underlying platform used to connect to Pixels. * @category Pixels */ export declare abstract class PixelSession { protected readonly _systemId: string; protected _connStatusCb?: (ev: PixelSessionConnectionEvent) => void; private _lastConnStatus; private _name; /** * Instantiates a session with a Pixel. * No attempt is made to connect to the die at this point. * @param systemId The peripheral system id (as assigned by the OS). */ constructor(systemId: string, name?: string); /** Gets the peripheral system id (as assigned by the OS). */ get systemId(): string; /** * Gets the Pixel name. * @remarks It may be undefined until connected. */ get pixelName(): string | undefined; /** Gets the last known connection status. */ get lastConnectionStatus(): PixelSessionConnectionStatus; /** * Sets the function to be called when the Pixel connection status changes. * @param connectionStatusListener The function called when the Pixel connection status changes. */ setConnectionEventListener(connectionStatusListener?: (ev: PixelSessionConnectionEvent) => void): void; /** Release resources used by the session object. */ abstract dispose(): void; /** Connects to the Pixel. */ abstract connect(timeoutMs: number): Promise; /** Disconnects from the Pixel. */ abstract disconnect(): Promise; /** * Subscribes to the "notify" characteristic and returns unsubscribe function. * @param listener The function to be called when the Pixel connection status changes. */ abstract subscribe(listener: (dataView: DataView) => void): Promise<() => void>; /** * Sends data to Pixel using the "write" characteristic * @param data The raw data to send to the Pixel. * @param withoutResponse Whether or not to request the device to acknowledge having received the data. * @param timeoutMs The timeout in milliseconds before throwing an error when waiting for the device to acknowledgement. */ abstract writeValue(data: ArrayBuffer, withoutResponse?: boolean, timeoutMs?: number): Promise; protected _notifyConnectionEvent(status: PixelSessionConnectionStatus, reason?: PixelSessionConnectionEventReason): void; protected _setName(name: string): void; } //# sourceMappingURL=PixelSession.d.ts.map