Automatic Unlocking

Last Updated on : 2024-04-26 07:52:05download

Bluetooth is widely used for IoT-enabled vehicles, such as electric bicycles and automotive cars. For example, smart vehicles can be automatically unlocked over Bluetooth as users approach them. Travel SDK supports this efficient unlocking feature.

In the traditional unlocking process, users need to keep the vehicle connected to the app, open the panel, and then manually tap to unlock the device.

Bluetooth automatic unlocking simplifies the whole process. Users only need to enable this feature when they access it for the first time on the app. Then, whenever they take the mobile phone that runs the app and approach the target vehicle, the app automatically unlocks or disarms the vehicle.

Types of automatic unlocking methods

  • Travel SDK supports two types of automatic unlocking methods: Bluetooth LE_HID and Bluetooth.
  • They are intended for different types of vehicles. You can make an API request to query the type of automatic unlocking method supported by the target device to get the automatic unlocking control class.

Bluetooth LE_HID

Bluetooth LE_HID automatic unlocking is implemented based on the Bluetooth Low Energy (LE) human interface device (HID) protocol.

Automatic Unlocking

Bluetooth

Bluetooth automatic unlocking is implemented based on pairing over Bluetooth Classic.

Automatic Unlocking

Automatic unlocking management class

Get automatic unlocking management class

Example

IODInductiveUnlockManager inductiveUnlockManager = ThingODSDK.getODInductiveUnlockManagerInstance();

Get type of automatic unlocking method

API description

void getInductiveUnlockType(String devId, IThingResultCallback<InductiveUnlockType> callback)

Request parameters

Parameter Type Required Example Description
devId String Yes - The device ID.
callback IThingResultCallback<InductiveUnlockType> Yes - The callback.

Data model of InductiveUnlockType

Enum value Description
Bluetooth LE_HID Bluetooth LE_HID automatic unlocking
Bluetooth Bluetooth automatic unlocking
NONE Automatic unlocking not supported

Example

ThingODSDK.getODInductiveUnlockManagerInstance()
    .getInductiveUnlockType(deviceId, new IThingResultCallback<InductiveUnlockType>() {
            @Override
            public void onSuccess(InductiveUnlockType result) {
        Log.d(TAG, "result:" + result);
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Log.d(TAG, "errorCode:" + errorCode + " errorMessage:" + errorMessage);
            }
        });

Get control class of Bluetooth LE_HID automatic unlocking

API description

IODHidInductiveUnlock newHidInductiveUnlockInstance(String devId);

Request parameters

Parameter Type Required Example Description
devId String Yes - The device ID.

Example

IODHidInductiveUnlock inductiveUnlock = ThingODSDK.getODInductiveUnlockManagerInstance()
      .newHidInductiveUnlockInstance(devId);

Get control class of Bluetooth automatic unlocking

API description

IODBtInductiveUnlock newBtInductiveUnlockInstance(String devId);

Request parameters

Parameter Type Required Example Description
devId String Yes - The device ID.

Example

IODBtInductiveUnlock inductiveUnlock = ThingODSDK.getODInductiveUnlockManagerInstance()
  .newBtInductiveUnlockInstance(devId);

Bluetooth LE_HID automatic unlocking

Get automatic unlocking switch status

API description

boolean isInductiveUnlockTurnOn();

Example

inductiveUnlock.isInductiveUnlockTurnOn();

Enable automatic unlocking

API description

void turnOnInductiveUnlock(InductiveUnlockCallback callback);

Request parameters

Parameter Type Required Example Description
callback InductiveUnlockCallback Yes - The callback.

Example

inductiveUnlock.turnOnInductiveUnlock(new InductiveUnlockCallback() {
  @Override
  public void onError(String code, String error) {
    Log.d(TAG, "onError: " + code + " " + error);
  }

  @Override
  public void onSuccess() {
    Log.d(TAG, "onSuccess");
  }
});

Disable automatic unlocking

API description

void turnOffInductiveUnlock(IResultCallback callback);

Request parameters

Parameter Type Required Example Description
callback IResultCallback Yes - The callback.

Example

inductiveUnlock.turnOffInductiveUnlock(new IResultCallback() {
  @Override
  public void onError(String code, String error) {
    Log.d(TAG, "onError: " + code + " " + error);
  }

  @Override
  public void onSuccess() {
    Log.d(TAG, "onSuccess");
  }
});

Get Bluetooth pairing status

API description

HidBindStatus getHidBindStatus();

Data model of HidBindStatus

Enum value Description
BIND The HID device is bound.
UNBIND The HID device is not bound.

Set arming distance

API description

void recordFortifyDistance(IResultCallback callback);

Request parameters

Parameter Type Required Example Description
callback IResultCallback Yes - The callback.

Example

inductiveUnlock.recordFortifyDistance(new IResultCallback() {
    @Override
    public void onError(String code, String error) {
        Log.d(TAG, "onError: " + code + " " + error);
    }

    @Override
    public void onSuccess() {
        Log.d(TAG, "onSuccess");
    }
});

Set disarming distance

API description

void recordDisarmDistance(IResultCallback callback);

Request parameters

Parameter Type Required Example Description
callback IResultCallback Yes - The callback.

Example

inductiveUnlock.recordDisarmDistance(new IResultCallback() {
    @Override
    public void onError(String code, String error) {
        Log.d(TAG, "onError: " + code + " " + error);
    }

    @Override
    public void onSuccess() {
        Log.d(TAG, "onSuccess");
    }
});

Bluetooth automatic unlocking

Get automatic unlocking switch status

API description

boolean isInductiveUnlockTurnOn();

Example

inductiveUnlock.isInductiveUnlockTurnOn();

Enable automatic unlocking

API description

void turnOnInductiveUnlock(InductiveUnlockCallback callback);

Request parameters

Parameter Type Required Example Description
callback InductiveUnlockCallback Yes - The callback.

Example

inductiveUnlock.turnOnInductiveUnlock(new InductiveUnlockCallback() {
  @Override
  public void onError(String code, String error) {
    Log.d(TAG, "onError: " + code + " " + error);
  }

  @Override
  public void onSuccess() {
    Log.d(TAG, "onSuccess");
  }
});

Disable automatic unlocking

API description

void turnOffInductiveUnlock(IResultCallback callback);

Request parameters

Parameter Type Required Example Description
callback IResultCallback Yes - The callback.

Example

inductiveUnlock.turnOffInductiveUnlock(new IResultCallback() {
  @Override
  public void onError(String code, String error) {
    Log.d(TAG, "onError: " + code + " " + error);
  }

  @Override
  public void onSuccess() {
    Log.d(TAG, "onSuccess");
  }
});

Set unlocking distance

API description

void setInductiveUnlockDistance(int distance, IResultCallback callback);

Request parameters

Parameter Type Required Example Description
distance int Yes - The unlocking distance. Value range: 1 to 5.
callback IResultCallback Yes - The callback.

Example

inductiveUnlock.setInductiveUnlockDistance(1, new IResultCallback() {
    @Override
    public void onError(String code, String error) {
        Log.d(TAG, "onError: " + code + " " + error);
    }

    @Override
    public void onSuccess() {
        Log.d(TAG, "onSuccess");
    }
});

Get unlocking distance

API description

Integer getInductiveUnlockDistance();

Return parameters

Type Example Description
Integer 1 The unlocking distance. A value of null indicates that automatic unlocking is not enabled.

Example

Integer btInductiveUnlockDistance = inductiveUnlock.getInductiveUnlockDistance();

Device management

Supports device management respecting automatic unlocking.

Get device control class

Example

IODDevice mODDevice = ThingODSDK.newODDeviceInstance(devId);

Remove a device

Removes a device from the device list. When users remove a device that has automatic unlocking enabled, the system also makes attempts to remove the Bluetooth connection.

API description

void removeDevice(IResultCallback callback);

Request parameters

Parameter Type Required Example Description
callback IResultCallback Yes - The callback.

Example

mODDevice.removeDevice(new IResultCallback() {
  @Override
  public void onError(String errorCode, String errorMsg) {
        Log.d(TAG, "onError: " + code + " " + error);
  }

  @Override
  public void onSuccess() {
        Log.d(TAG, "onSuccess");
  }
});

Restore factory defaults

After factory defaults are restored for the device, the device data is cleared and the device gets ready for pairing again. When users remove a device that has automatic unlocking enabled, the system also makes attempts to remove the Bluetooth connection.

API description

void resetFactory(IResultCallback callback);

Request parameters

Parameter Type Required Example Description
callback IResultCallback Yes - The callback.

Example

mODDevice.resetFactory(new IResultCallback() {
  @Override
  public void onError(String errorCode, String errorMsg) {
        Log.d(TAG, "onError: " + code + " " + error);
  }

  @Override
  public void onSuccess() {
        Log.d(TAG, "onSuccess");
  }
});

Error codes

Error code Description
-6000 The operation timed out.
-6001 The number of paired Bluetooth devices has exceeded the upper limit.
-6002 Device pairing is canceled.
-6003 The device has been paired over Bluetooth with another mobile phone.