import { EventReceiver } from "@systemic-games/pixels-core-utils"; import { AdvertisementData, BluetoothState, ConnectionEventReason, ConnectionStatus, Device } from "./BluetoothLE"; /** * The possible statuses of the scanner. */ export type ScanStatus = "stopped" | "starting" | "scanning"; /** * Reason why the scan was stopped. */ export type ScanStopReason = Exclude | "failedToStart" | "success"; /** * Possible errors that prevented the scan to start (Android only). */ export type ScanStartErrorCode = "alreadyStarted" | "registrationFailed" | "internalError" | "unsupported" | "outOfHardwareResources"; /** * A scanned peripheral is BLE device and its advertisement data. */ export type ScannedPeripheral = Device & Readonly<{ advertisementData: AdvertisementData; }>; /** * Event map for {@link Central} class. * This is the list of supported events where the property name * is the event name and the property type the event data type. */ export type CentralEventMap = Readonly<{ bluetoothState: { readonly state: BluetoothState; }; scanStatus: Readonly<{ status: ScanStatus; stopReason?: ScanStopReason; startError?: ScanStartErrorCode; context?: unknown; }>; scannedPeripheral: Readonly<{ peripheral: ScannedPeripheral; context?: unknown; }>; peripheralConnectionStatus: Readonly<{ peripheral: ScannedPeripheral; connectionStatus: ConnectionStatus; reason: ConnectionEventReason; }>; }>; /** * Event emitted when a peripheral characteristic value has changed. */ export type PeripheralCharacteristicValueChangedEvent = Readonly<{ peripheral: ScannedPeripheral; service: string; characteristic: string; characteristicIndex: number; value: readonly number[]; }>; export type PeripheralOrSystemId = ScannedPeripheral | string; export declare const Central: { readonly initialize: () => void; readonly shutdown: () => void; readonly isInitialized: () => boolean; readonly getBluetoothState: () => BluetoothState; readonly getScanStatus: () => ScanStatus; readonly addListener: (type: K, listener: EventReceiver) => void; readonly removeListener: (type: T, listener: (ev: CentralEventMap[T]) => void) => void; readonly addPeripheralConnectionListener: (peripheral: PeripheralOrSystemId, listener: (ev: CentralEventMap["peripheralConnectionStatus"]) => void) => void; readonly removePeripheralConnectionListener: (peripheral: PeripheralOrSystemId, listener: (ev: CentralEventMap["peripheralConnectionStatus"]) => void) => void; readonly startScan: (services?: string | readonly string[], context?: unknown) => Promise; readonly stopScan: () => Promise; readonly connectPeripheral: (peripheral: PeripheralOrSystemId, timeoutMs?: number) => Promise; readonly disconnectPeripheral: (peripheral: PeripheralOrSystemId) => Promise; readonly releasePeripheral: (peripheral: PeripheralOrSystemId) => Promise; readonly getPeripheralName: (peripheral: PeripheralOrSystemId) => Promise; readonly getPeripheralMtu: (peripheral: PeripheralOrSystemId) => Promise; readonly readPeripheralRssi: (peripheral: PeripheralOrSystemId, _timeoutMs?: 10000) => Promise; readonly getDiscoveredServices: (peripheral: PeripheralOrSystemId) => Promise; readonly getServiceCharacteristics: (peripheral: PeripheralOrSystemId, serviceUuid: string) => Promise; readonly getCharacteristicProperties: (peripheral: PeripheralOrSystemId, serviceUuid: string, characteristicUuid: string, instanceIndex?: number) => Promise; readonly readCharacteristic: (peripheral: PeripheralOrSystemId, serviceUuid: string, characteristicUuid: string, options?: { instanceIndex?: number; timeoutMs?: number; }) => Promise; readonly writeCharacteristic: (peripheral: PeripheralOrSystemId, serviceUuid: string, characteristicUuid: string, data: ArrayBuffer, options?: { withoutResponse?: boolean; instanceIndex?: number; timeoutMs?: number; }) => Promise; readonly subscribeCharacteristic: (peripheral: PeripheralOrSystemId, serviceUuid: string, characteristicUuid: string, onValueChanged: (ev: PeripheralCharacteristicValueChangedEvent) => void, options?: { instanceIndex?: number; timeoutMs?: number; }) => Promise; readonly unsubscribeCharacteristic: (peripheral: PeripheralOrSystemId, serviceUuid: string, characteristicUuid: string, options?: { instanceIndex?: number; timeoutMs?: number; }) => Promise; }; //# sourceMappingURL=Central.d.ts.map