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.

func addBeacon(
    vehicleId: String,
    beacon: DKBeacon,
    completionHandler: @escaping (DKVehicleBeaconStatus) -> Void
)

This method have the following parameters:

NameTypeDescription

beacon

The beacon data you want to pair to the vehicle

vehicleId

String

The identifier of vehicle that you wish to pair with a beacon

remark: All fields are required. If you don't know the uniqueId of your beacons, just add an empty field.

Check the DKVehicleBeaconStatus value to ensure your beacon is correctly paired:

ValueDescription

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.

unknownVehicle

An error occurred: the specified vehicle does not belong to the user.

unavailableBeacon

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:

func changeBeacon(
    vehicleId: String,
    oldVehicleId: String,
    beacon: DKBeacon,
    completionHandler: @escaping (DKVehicleBeaconStatus) -> Void
)

This method have the following parameters:

NameTypeDescription

beacon

The new beacon data you want to pair to the vehicle.

vehicleId

String

The identifier of the vehicle for which you wish to change the beacon

oldVehicleId

String

The identifier of the old vehicle paired to the beacon

remark: All fields are required. If you don't know the uniqueId of your beacons, just add an empty field.

Check the DKVehicleBeaconStatus value to ensure your beacon is correctly changed:

ValueDescription

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.

unknownVehicle

An error occurred: the specified vehicle does not belong to the user.

unavailableBeacon

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:

func removeBeacon(
    vehicleId: String,
    completionHandler: @escaping (DKVehicleBeaconRemoveStatus) -> Void
)

This method have the following parameter:

NameTypeDescription

vehicleId

String

The identifier of the vehicle for which you want to unpair the beacon.

Check the DKVehicleBeaconRemoveStatus value to ensure your beacon is correctly unpaired:

ValueDescription

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.

unknownVehicle

An error occurred: the specified vehicle does not belong to the user.

Last updated