import { BaseAdapter, IPrinterAdapter, IAdapterOptions } from './BaseAdapter'; /** * React Native BLE Manager interface * Compatible with react-native-ble-plx API */ interface BLEManager { startDeviceScan(serviceUUIDs: string[] | null, options: Record | null, onDeviceScanned: (error: unknown, device: unknown) => void): void; stopDeviceScan(): void; connectToDevice(deviceIdentifier: string, options: Record): Promise; disconnectFromDevice(deviceIdentifier: string, force?: boolean): Promise; discoverAllServicesAndCharacteristicsForDevice(deviceIdentifier: string): Promise; writeCharacteristicWithResponseForDevice(deviceIdentifier: string, serviceUUID: string, characteristicUUID: string, value: string, transactionId?: string): Promise; writeCharacteristicWithoutResponseForDevice(deviceIdentifier: string, serviceUUID: string, characteristicUUID: string, value: string, transactionId?: string): Promise; readCharacteristicForDevice(deviceIdentifier: string, serviceUUID: string, characteristicUUID: string, transactionId?: string): Promise; monitorCharacteristicForDevice(deviceIdentifier: string, serviceUUID: string, characteristicUUID: string, onUpdate: (error: unknown, characteristic: unknown) => void, transactionId?: string): { remove: () => void; }; } /** * React Native Bluetooth Low Energy adapter * * Uses react-native-ble-plx for BLE operations on iOS and Android. * This adapter does NOT extend MiniProgramAdapter because React Native * has a fundamentally different BLE API compared to mini-program platforms. * * @example * ```typescript * import BleManager from 'react-native-ble-plx'; * import { ReactNativeAdapter } from 'taro-bluetooth-print'; * * BleManager.start({ showAlert: false }); * * const adapter = new ReactNativeAdapter({ bleManager: BleManager }); * await adapter.connect('device-uuid-123'); * await adapter.write('device-uuid-123', buffer); * await adapter.disconnect('device-uuid-123'); * ``` */ export declare class ReactNativeAdapter extends BaseAdapter implements IPrinterAdapter { private bleManager; private deviceCache; private writeStrategy; /** * Creates a new ReactNativeAdapter instance * * @param options - Configuration options * @param options.bleManager - BLE Manager instance (e.g., from react-native-ble-plx) * @throws {BluetoothPrintError} If bleManager is not provided or not supported */ constructor(options: { bleManager: BLEManager; }); /** * Connect to a Bluetooth device and discover services * * @param deviceId - Unique identifier (UUID) of the device to connect to * @throws {BluetoothPrintError} When connection fails or device not found */ connect(deviceId: string): Promise; /** * Perform the actual BLE connection */ private performConnect; /** * Disconnect from a Bluetooth device * * @param deviceId - Unique identifier of the device to disconnect from */ disconnect(deviceId: string): Promise; /** * Write data to the Bluetooth device in chunks * * Features: * - Automatic chunk size adjustment * - Dynamic delay for congestion control * - Retry with exponential backoff * - Write timeout per chunk * * @param deviceId - Unique identifier of the connected device * @param buffer - Data to write as ArrayBuffer * @param options - Optional write settings (chunkSize, delay, retries) * @throws {BluetoothPrintError} When write fails after all retries */ write(deviceId: string, buffer: ArrayBuffer, options?: IAdapterOptions): Promise; /** * Start discovering nearby Bluetooth devices * * Note: This is optional in IPrinterAdapter. In React Native BLE, * device discovery is typically done via scan events. */ startDiscovery?(): Promise; /** * Stop discovering nearby Bluetooth devices */ stopDiscovery?(): Promise; /** * Discover services and characteristics for a connected device * * @param deviceId - Device identifier * @param device - Connected device object */ private discoverServices; /** * Convert ArrayBuffer to base64 string for react-native-ble-plx * * @param buffer - ArrayBuffer to convert * @returns Base64 encoded string */ private arrayBufferToBase64; } export {};