@@ -94,6 +94,7 @@ export function stringToUint8Array(value, encoding = 'iso-8859-1') {
9494}
9595
9696import { iOSNativeHelper } from '@nativescript/core/utils/native-helper' ;
97+ import { DisconnectOptions } from './bluetooth' ;
9798
9899export type SubPeripheralDelegate = Partial < CBPeripheralDelegate > ;
99100export type SubCentralManagerDelegate = Partial < CBCentralManagerDelegate > ;
@@ -482,6 +483,7 @@ export class CBCentralManagerDelegateImpl extends NSObject implements CBCentralM
482483 localName : advertismentData . localName ,
483484 RSSI ,
484485 advertismentData,
486+ nativeDevice : peripheral ,
485487 state : this . _owner . get ( ) . _getState ( peripheral . state ) ,
486488 manufacturerId : advertismentData . manufacturerId ,
487489 } ;
@@ -894,6 +896,22 @@ export class Bluetooth extends BluetoothCommon {
894896 this . _advData = { } ;
895897 }
896898
899+ @bluetoothEnabled
900+ @prepareArgs
901+ public async getDevice ( args : DisconnectOptions ) {
902+ const methodName = 'getDevice' ;
903+ if ( ! args . UUID ) {
904+ return Promise . reject (
905+ new BluetoothError ( BluetoothCommon . msg_missing_parameter , {
906+ method : methodName ,
907+ type : BluetoothCommon . UUIDKey ,
908+ arguments : args ,
909+ } )
910+ ) ;
911+ }
912+ return this . findDiscoverPeripheral ( args . UUID ) ;
913+ }
914+
897915 @bluetoothEnabled
898916 @prepareArgs
899917 public async connect ( args : ConnectOptions ) {
@@ -970,6 +988,7 @@ export class Bluetooth extends BluetoothCommon {
970988 name : peripheral . name ,
971989 state : this . _getState ( peripheral . state ) ,
972990 services,
991+ nativeDevice : peripheral ,
973992 localName : adv ?. localName ,
974993 manufacturerId : adv ?. manufacturerId ,
975994 advertismentData : adv ,
0 commit comments