UNPKG

react-native-ble-nitro

Version:

High-performance React Native BLE library built on Nitro Modules - drop-in replacement for react-native-ble-plx

54 lines (53 loc) 4.31 kB
/** * BleManager Compatibility Factory * * Creates BleManager instances with full react-native-ble-plx compatibility * by wrapping the Nitro implementation with compatibility shims */ import type { BleManagerOptions, UUID, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, ScanOptions, NativeService, NativeCharacteristic, NativeDescriptor, LogLevel, Subscription } from './specs/types'; import { DeviceWrapper } from './compatibility/deviceWrapper'; /** * BleManager wrapper that provides react-native-ble-plx compatibility */ export declare class BleManagerCompat { private bleManager; constructor(options?: BleManagerOptions); destroy(): Promise<void>; setLogLevel(logLevel: LogLevel | string): Promise<string>; logLevel(): Promise<string>; cancelTransaction(transactionId: TransactionId): Promise<void>; enable(transactionId?: TransactionId): Promise<BleManagerCompat>; disable(transactionId?: TransactionId): Promise<BleManagerCompat>; state(): Promise<string>; onStateChange(listener: (newState: string) => void, emitCurrentState?: boolean): Subscription; startDeviceScan(uuids: UUID[] | null, options: ScanOptions | null, listener: (error: any | null, scannedDevice: DeviceWrapper | null) => void): Promise<void>; stopDeviceScan(): Promise<void>; connectToDevice(deviceIdentifier: DeviceId, options?: Partial<ConnectionOptions>): Promise<DeviceWrapper>; cancelDeviceConnection(deviceIdentifier: DeviceId): Promise<DeviceWrapper>; isDeviceConnected(deviceIdentifier: DeviceId): Promise<boolean>; onDeviceDisconnected(deviceIdentifier: DeviceId, listener: (error: any | null, device: DeviceWrapper | null) => void): Subscription; devices(deviceIdentifiers: DeviceId[]): Promise<DeviceWrapper[]>; connectedDevices(serviceUUIDs: UUID[]): Promise<DeviceWrapper[]>; readRSSIForDevice(deviceIdentifier: DeviceId, transactionId?: TransactionId): Promise<DeviceWrapper>; requestMTUForDevice(deviceIdentifier: DeviceId, mtu: number, transactionId?: TransactionId): Promise<DeviceWrapper>; requestConnectionPriorityForDevice(deviceIdentifier: DeviceId, connectionPriority: ConnectionPriority, transactionId?: TransactionId): Promise<DeviceWrapper>; discoverAllServicesAndCharacteristicsForDevice(deviceIdentifier: DeviceId, transactionId?: TransactionId): Promise<DeviceWrapper>; servicesForDevice(deviceIdentifier: DeviceId): Promise<NativeService[]>; characteristicsForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID): Promise<NativeCharacteristic[]>; readCharacteristicForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, transactionId?: TransactionId): Promise<NativeCharacteristic>; writeCharacteristicWithResponseForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, base64Value: string, transactionId?: TransactionId): Promise<NativeCharacteristic>; writeCharacteristicWithoutResponseForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, base64Value: string, transactionId?: TransactionId): Promise<NativeCharacteristic>; monitorCharacteristicForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, listener: (error: any | null, characteristic: NativeCharacteristic | null) => void, transactionId?: TransactionId, subscriptionType?: 'notification' | 'indication'): Subscription; descriptorsForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID): Promise<NativeDescriptor[]>; readDescriptorForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, descriptorUUID: UUID, transactionId?: TransactionId): Promise<NativeDescriptor>; writeDescriptorForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, descriptorUUID: UUID, valueBase64: string, transactionId?: TransactionId): Promise<NativeDescriptor>; /** * Helper method to create a Device wrapper from NativeDevice data * This is a temporary method until we have proper Device Nitro objects */ private createDeviceFromNative; } /** * Factory function to create a compatibility BleManager */ export declare function createBleManagerCompat(options?: BleManagerOptions): BleManagerCompat;