react-native-ble-nitro
Version:
High-performance React Native BLE library built on Nitro Modules - drop-in replacement for react-native-ble-plx
100 lines (99 loc) • 4.8 kB
TypeScript
/**
* Device wrapper for compatibility
*
* Wraps Nitro Device objects to provide the original react-native-ble-plx API
*/
import type { Device as NitroDevice } from '../specs/Device.nitro';
import type { UUID, Base64, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, NativeService, NativeCharacteristic, NativeDescriptor, Subscription } from '../specs/types';
/**
* Device wrapper that provides react-native-ble-plx compatibility
* Maps Nitro device properties to the expected API surface
*/
export declare class DeviceWrapper {
private nitroDevice;
constructor(nitroDevice: NitroDevice | any);
get id(): DeviceId;
get name(): string | null;
get rssi(): number | null;
get mtu(): number;
get manufacturerData(): Base64 | null;
get rawScanRecord(): Base64;
get serviceData(): {
[uuid: string]: Base64;
} | null;
get serviceUUIDs(): UUID[] | null;
get localName(): string | null;
get txPowerLevel(): number | null;
get solicitedServiceUUIDs(): UUID[] | null;
get isConnectable(): boolean | null;
get overflowServiceUUIDs(): UUID[] | null;
requestConnectionPriority(connectionPriority: ConnectionPriority, transactionId?: TransactionId): Promise<DeviceWrapper>;
readRSSI(transactionId?: TransactionId): Promise<DeviceWrapper>;
requestMTU(mtu: number, transactionId?: TransactionId): Promise<DeviceWrapper>;
connect(options?: Partial<ConnectionOptions>): Promise<DeviceWrapper>;
cancelConnection(): Promise<DeviceWrapper>;
isConnected(): Promise<boolean>;
onDisconnected(listener: (error: any | null, device: DeviceWrapper) => void): Subscription;
discoverAllServicesAndCharacteristics(transactionId?: TransactionId): Promise<DeviceWrapper>;
services(): Promise<ServiceWrapper[]>;
characteristicsForService(serviceUUID: UUID): Promise<CharacteristicWrapper[]>;
readCharacteristicForService(serviceUUID: UUID, characteristicUUID: UUID, transactionId?: TransactionId): Promise<CharacteristicWrapper>;
writeCharacteristicWithResponseForService(serviceUUID: UUID, characteristicUUID: UUID, valueBase64: Base64, transactionId?: TransactionId): Promise<CharacteristicWrapper>;
writeCharacteristicWithoutResponseForService(serviceUUID: UUID, characteristicUUID: UUID, valueBase64: Base64, transactionId?: TransactionId): Promise<CharacteristicWrapper>;
monitorCharacteristicForService(serviceUUID: UUID, characteristicUUID: UUID, listener: (error: any | null, characteristic: CharacteristicWrapper | null) => void, transactionId?: TransactionId, subscriptionType?: 'notification' | 'indication'): Subscription;
descriptorsForService(serviceUUID: UUID, characteristicUUID: UUID): Promise<DescriptorWrapper[]>;
readDescriptorForService(serviceUUID: UUID, characteristicUUID: UUID, descriptorUUID: UUID, transactionId?: TransactionId): Promise<DescriptorWrapper>;
writeDescriptorForService(serviceUUID: UUID, characteristicUUID: UUID, descriptorUUID: UUID, valueBase64: Base64, transactionId?: TransactionId): Promise<DescriptorWrapper>;
}
/**
* Service wrapper for compatibility
*/
export declare class ServiceWrapper {
private nativeService;
private nitroDevice;
constructor(nativeService: NativeService, nitroDevice: NitroDevice);
get id(): number;
get uuid(): UUID;
get deviceID(): DeviceId;
get isPrimary(): boolean;
characteristics(): Promise<CharacteristicWrapper[]>;
readCharacteristic(characteristicUUID: UUID, transactionId?: TransactionId): Promise<CharacteristicWrapper>;
}
/**
* Characteristic wrapper for compatibility
*/
export declare class CharacteristicWrapper {
private nativeCharacteristic;
private nitroDevice;
constructor(nativeCharacteristic: NativeCharacteristic, nitroDevice: NitroDevice);
get id(): number;
get uuid(): UUID;
get serviceID(): number;
get serviceUUID(): UUID;
get deviceID(): DeviceId;
get isReadable(): boolean;
get isWritableWithResponse(): boolean;
get isWritableWithoutResponse(): boolean;
get isNotifiable(): boolean;
get isNotifying(): boolean;
get isIndicatable(): boolean;
get value(): Base64 | null;
read(transactionId?: TransactionId): Promise<CharacteristicWrapper>;
}
/**
* Descriptor wrapper for compatibility
*/
export declare class DescriptorWrapper {
private nativeDescriptor;
private nitroDevice;
constructor(nativeDescriptor: NativeDescriptor, nitroDevice: NitroDevice);
get id(): number;
get uuid(): UUID;
get characteristicID(): number;
get characteristicUUID(): UUID;
get serviceID(): number;
get serviceUUID(): UUID;
get deviceID(): DeviceId;
get value(): Base64 | null;
read(transactionId?: TransactionId): Promise<DescriptorWrapper>;
}