# Bluetooth - Android

{% hint style="info" %}
You'll need to import the javascript file in your website before starting from this [link](https://docs.webtonative.com/javascript-apis/getting-started).
{% endhint %}

{% tabs %}
{% tab title="Plain Javascript" %}
{% code overflow="wrap" %}

```
const { Bluetooth } = window.WTN

//To start scanning for bluetooth devices
Bluetooth.startBluetoothScan({
    callback: function(data){
        //Contains data which has a list of available bluetooth devices
    }
})


//To connect bluetooth device with specific address
Bluetooth.pairDevice({
    address, //Device address that you want to connect
    timeout, //Time till the app should try to connect before returning not paired status
    callback: function(data){
        //Contains data which has result as PAIRED | NOT_PAIRED
    }
})


//To disconnect from the connected bluetooth device
Bluetooth.startBluetoothScan({
    address, //Device address that you want to connect
    callback: function(data){
        //Contains data which has result UNPAIRED | ERROR DURING UNPAIRING
    }
})
```

{% endcode %}
{% endtab %}

{% tab title="ES5+" %}

```
import { Bluetooth } from "webtonative";

//To start scanning for bluetooth devices
Bluetooth.startBluetoothScan({
    callback: function(data){
        //Contains data which has a list of available bluetooth devices
    }
})


//To connect bluetooth device with specific address
Bluetooth.pairDevice({
    address, //Device address that you want to connect
    timeout, //Time till the app should try to connect before returning not paired status
    callback: function(data){
        //Contains data which has result as PAIRED | NOT_PAIRED
    }
})


//To disconnect from the connected bluetooth device
Bluetooth.startBluetoothScan({
    address, //Device address that you want to connect
    callback: function(data){
        //Contains data which has result UNPAIRED | ERROR DURING UNPAIRING
    }
})
```

{% endtab %}
{% endtabs %}
