@@ -118,6 +118,7 @@ public class BluetoothLePlugin extends CordovaPlugin {
118118 private final String keyIsScanning = "isScanning" ;
119119 private final String keyIsConnected = "isConnected" ;
120120 private final String keyIsDiscovered = "isDiscovered" ;
121+ private final String keyIsBonded = "isBonded" ;
121122 private final String keyPeripheral = "peripheral" ;
122123 private final String keyState = "state" ;
123124 private final String keyDiscoveredState = "discoveredState" ;
@@ -371,6 +372,8 @@ public boolean execute(String action, final JSONArray args, final CallbackContex
371372 isConnectedAction (args ,callbackContext );
372373 } else if ("isDiscovered" .equals (action )) {
373374 isDiscoveredAction (args , callbackContext );
375+ } else if ("isBonded" .equals (action )) {
376+ isBondedAction (args , callbackContext );
374377 } else if ("requestConnectionPriority" .equals (action )) {
375378 requestConnectionPriorityAction (args , callbackContext );
376379 } else if ("mtu" .equals (action )) {
@@ -2393,6 +2396,40 @@ private void isDiscoveredAction(JSONArray args, CallbackContext callbackContext)
23932396 callbackContext .success (returnObj );
23942397 }
23952398
2399+ private void isBondedAction (JSONArray args , CallbackContext callbackContext ) {
2400+ if (isNotInitialized (callbackContext , true )) {
2401+ return ;
2402+ }
2403+
2404+ JSONObject obj = getArgsObject (args );
2405+ if (isNotArgsObject (obj , callbackContext )) {
2406+ return ;
2407+ }
2408+
2409+ String address = getAddress (obj );
2410+ if (isNotAddress (address , callbackContext )) {
2411+ return ;
2412+ }
2413+
2414+ HashMap <Object , Object > connection = wasNeverConnected (address , callbackContext );
2415+ if (connection == null ) {
2416+ return ;
2417+ }
2418+
2419+ BluetoothGatt bluetoothGatt = (BluetoothGatt )connection .get (keyPeripheral );
2420+ BluetoothDevice device = bluetoothGatt .getDevice ();
2421+
2422+ boolean result = (device .getBondState () == BluetoothDevice .BOND_BONDED );
2423+
2424+ JSONObject returnObj = new JSONObject ();
2425+
2426+ addProperty (returnObj , keyIsConnected , result );
2427+
2428+ addDevice (returnObj , device );
2429+
2430+ callbackContext .success (returnObj );
2431+ }
2432+
23962433 private void requestConnectionPriorityAction (JSONArray args , CallbackContext callbackContext ) {
23972434 if (isNotInitialized (callbackContext , true )) {
23982435 return ;
0 commit comments