# Beacon management

## Pair a beacon to a vehicle

The following function allows you to create a logical pairing between a beacon and a vehicle. The results of data analysis containing a beacon will be assigned to the vehicle to which the beacon has been paired with.

{% tabs %}
{% tab title="DriveKitVehicle" %}

```kotlin
fun addBeaconToVehicle(
    beacon: Beacon,
    vehicle: Vehicle,
    listener: VehicleAddBeaconQueryListener
)
```

{% endtab %}
{% endtabs %}

| Name    | Type                                                      | Description                                     |
| ------- | --------------------------------------------------------- | ----------------------------------------------- |
| beacon  | [Beacon](/vehicle/android/references-android.md#beacon)   | The beacon data you want to pair to the vehicle |
| vehicle | [Vehicle](/vehicle/android/references-android.md#vehicle) | The vehicle you wish to pair with a beacon      |

{% hint style="info" %}
All fields are required. If you don't know the uniqueId of your beacons, just add an empty field.
{% endhint %}

Check the `VehicleBeaconStatus` value to ensure your beacon is correctly paired:

| Value               | Description                                                                                                                                                |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SUCCESS             | The beacon has been successfully paired to the specified vehicle. The vehicle data in the local database is automatically updated.                         |
| ERROR               | An error occurred when trying to pair the beacon to the vehicle, for example if the user has no network during when the method is called.                  |
| UNKNOWN\_VEHICLE    | An error occurred: the specified vehicle does not belong to the user.                                                                                      |
| UNAVAILABLE\_BEACON | The provided beacon is currently paired to another vehicle. You must unpair the beacon to that vehicle before in order to pair it to your desired vehicle. |

## Replace the beacon of a vehicle

If a beacon is already paired with a vehicle, it can be replaced. The following function is used to change the beacon paired with a vehicle:

{% tabs %}
{% tab title="DriveKitVehicle" %}

```kotlin
fun changeBeaconToVehicle(
    beacon: Beacon,
    vehicle: Vehicle,
    listener: VehicleChangeBeaconQueryListener
)
```

{% endtab %}
{% endtabs %}

This method have the following parameters:

| Name    | Type                                                      | Description                                          |
| ------- | --------------------------------------------------------- | ---------------------------------------------------- |
| beacon  | [Beacon](/vehicle/android/references-android.md#beacon)   | The new beacon data you want to pair to the vehicle. |
| vehicle | [Vehicle](/vehicle/android/references-android.md#vehicle) | The vehicle you wish to change the beacon            |

{% hint style="info" %}
All fields are required. If you don't know the uniqueId of your beacons, just add an empty field.
{% endhint %}

Check the `VehicleBeaconStatus` value to ensure your beacon is correctly changed:

| Value               | Description                                                                                                                                                |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SUCCESS             | The beacon has been successfully replaced for the specified vehicle. The vehicles data in the local database are automatically updated.                    |
| ERROR               | An error occurred when trying to replace the beacon of the vehicle.                                                                                        |
| UNKNOWN\_VEHICLE    | An error occurred: the specified vehicle does not belong to the user.                                                                                      |
| UNAVAILABLE\_BEACON | The provided beacon is currently paired to another vehicle. You must unpair the beacon to that vehicle before in order to pair it to your desired vehicle. |

## Unpair the beacon from a vehicle

The following function can be used to delete the pairing between a beacon and a vehicle:

{% tabs %}
{% tab title="DriveKitVehicle" %}

<pre class="language-kotlin"><code class="lang-kotlin"><strong>fun removeBeaconToVehicle(
</strong><strong>    vehicle: Vehicle,
</strong>    listener: VehicleRemoveBeaconQueryListener
)
</code></pre>

{% endtab %}
{% endtabs %}

This method have the following parameter:

| Name    | Type                                                      | Description                                |
| ------- | --------------------------------------------------------- | ------------------------------------------ |
| vehicle | [Vehicle](/vehicle/android/references-android.md#vehicle) | The vehicle you want to unpair the beacon. |

Check the `VehicleBeaconRemoveStatus` value to ensure your beacon is correctly unpaired:

| Value            | Description                                                                                                                           |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| SUCCESS          | The beacon has been successfully removed from the specified vehicle. The vehicle data in the local database is automatically updated. |
| ERROR            | An error occurred when trying to remove the beacon of the vehicle.                                                                    |
| UNKNOWN\_VEHICLE | An error occurred: the specified vehicle does not belong to the user.                                                                 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.drivequant.com/vehicle/android/beacon-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
