Samsung Electronics logo

Pairing Bluetooth Devices



Learning how to pair with other devices is a basic Bluetooth management skill:

  1. Retrieve a BluetoothAdapter object with the getDefaultAdapter() method:

    var adapter = webapis.bluetooth.getDefaultAdapter();
    
  2. To pair with another device, use the createBonding() method:

    function onBondingSuccessCallback(device)
    {
       console.log("A bonding is created – name: " + device.name);
    }
    
    function onErrorCallback(e) 
    {
       console.log("Cannot create a bonding, reason: " + e.message);
    }
    
    adapter.createBonding("35:F4:59:D1:7A:03", onBondingSuccessCallback, onErrorCallback);
    
  3. Note
    The MAC address of the Bluetooth device in the range is a BluetoothAddress object, which can be retrieved after the discovery process. You can get the MAC address of the peer device from the BluetoothDevice object, which is returned in the success event handlers of the BluetoothAdapter's getKnownDevices() and discoverDevices() methods.
  4. To end the pairing between devices, use the destroyBonding() method:

    adapter.destroyBonding("35:F4:59:D1:7A:03");