@@ -1098,45 +1098,37 @@ export class Bluetooth extends BluetoothCommon {
10981098
10991099 @bluetoothEnabled
11001100 @prepareArgs
1101- public isConnected ( args ) {
1101+ public async isConnected ( args ) {
11021102 const methodName = 'isConnected' ;
11031103 try {
11041104 if ( ! args . UUID ) {
1105- return Promise . reject (
1106- new BluetoothError ( BluetoothCommon . msg_missing_parameter , {
1107- method : methodName ,
1108- type : BluetoothCommon . UUIDKey ,
1109- arguments : args ,
1110- } )
1111- ) ;
1105+ throw new BluetoothError ( BluetoothCommon . msg_missing_parameter , {
1106+ method : methodName ,
1107+ type : BluetoothCommon . UUIDKey ,
1108+ arguments : args ,
1109+ } ) ;
1110+
11121111 }
11131112 const peripheral = this . findPeripheral ( args . UUID ) ;
11141113 if ( peripheral === null ) {
1115- return Promise . reject (
1116- new BluetoothError ( BluetoothCommon . msg_no_peripheral , {
1117- method : methodName ,
1118- arguments : args ,
1119- } )
1120- ) ;
1114+ return false ;
11211115 } else {
11221116 if ( Trace . isEnabled ( ) ) {
11231117 CLog ( CLogTypes . info , methodName , '---- checking connection with peripheral UUID:' , args . UUID ) ;
11241118 }
1125- return Promise . resolve ( peripheral . state === CBPeripheralState . Connected ) ;
1119+ return peripheral . state === CBPeripheralState . Connected ;
11261120 }
11271121 } catch ( ex ) {
11281122 if ( Trace . isEnabled ( ) ) {
11291123 CLog ( CLogTypes . error , methodName , '---- error:' , ex ) ;
11301124 }
11311125
1132- return Promise . reject (
1133- new BluetoothError ( ex . message , {
1134- stack : ex . stack ,
1135- nativeException : ex . nativeException ,
1136- method : methodName ,
1137- arguments : args ,
1138- } )
1139- ) ;
1126+ throw new BluetoothError ( ex . message , {
1127+ stack : ex . stack ,
1128+ nativeException : ex . nativeException ,
1129+ method : methodName ,
1130+ arguments : args ,
1131+ } ) ;
11401132 }
11411133 }
11421134
0 commit comments