Human Interface Device (HID)

Last Updated on : 2024-06-25 10:07:41download

Most electric vehicles on the market support Bluetooth connection, allowing users to unlock their devices by tapping on the mobile app. The HID solution based on Tuya Bluetooth SDK enables automatic unlocking over Bluetooth as users’ mobile app is approaching the device. This provides hands-free operation without taking out the phone.

Features

The HID solution allows users to enable or disable automatic unlocking and specify the distance for activation, which is distinguished by the Bluetooth signal strength.

After a Bluetooth device is paired, it can achieve one-to-one unlocking based on automatic Bluetooth reconnection and the received signal strength indicator (RSSI).

How it works

This solution adopts the Bluetooth Low Energy (LE) HID and Security Manager (SM) protocols, as shown below.

Human Interface Device (HID)
  • Automatic unlocking is implemented by using the particular feature provided by the Bluetooth LE protocol. There are no HID data exchanges.
  • For more information about the SM protocol, see Bluetooth Core Specification Version 5.2 ([Vol 3], Part H).

Comparison with common Bluetooth solution

Operation Common Bluetooth LE devices HID-based Bluetooth LE devices
Connect and bind Not supports the binding state. Bluetooth is connected or disconnected as users open or close the mobile app.
  • Device is not bound: The mobile app can receive a pairing request from the device.
  • Device is bound: The mobile app can get the information of the paired device.
Unbind
  • Connected: A Bluetooth LE command is sent to the device for unbinding.
  • Disconnected: The mobile app or gateway sends a command to unbind from an offline device.
  • Connected: A Bluetooth LE command is sent to the device for unbinding and erasing the pairing information.
  • Disconnected: Unbinding is not available.

The following lists the reasons why a disconnected Bluetooth device cannot be unbound.

  • If an offline device is unbound, any mobile app can pair with it, which exposes to device security threats.
  • If an offline device is unbound but the pairing information is not removed from the mobile app, this device can still be unlocked automatically as the users’ mobile app is approaching it. Assume users have sold their vehicle. If they can unbind an offline vehicle, they can walk off with their sold vehicle without being noticed.

Description

This section describes how to implement the HID feature on the device and the mobile app.

Device

  • Initialize Generic Access Profile (GAP) and disable pairing. Enable automatic unlocking in the mobile app. The device sends a pairing and binding request to the mobile app.

  • The device implements the HID and Bluetooth LE services.

  • After the Bluetooth device reconnects to the mobile app, it reads the RSSI data every 200 ms and determines whether to unlock the device based on the obtained RSSI values.

  • Multiple devices can be managed. Up to three devices can be shared currently.

  • Locally polling for connection is supported. The device is not allowed to erase pairing information without commands from the cloud.

    Human Interface Device (HID)

Mobile app

  • Android and iOS devices can receive the pairing request from Bluetooth devices in a flexible manner.

  • Only the device can initiate a pairing request and the data exchanges are encrypted, ensuring a secure Bluetooth pairing.

  • After receiving a pairing request, Android and iOS devices will first determine if the initiator is already in the paired device list. If it does, the mobile phone will read the new advertising packet through a specific characteristic value. If the initiator is not on the list, it will be paired.

    The following block diagram shows the reconnection mechanism.

    Human Interface Device (HID)

Solution design

The following diagram shows how the Bluetooth device interacts with the mobile app.

Human Interface Device (HID)
  • The automatic unlocking can only be enabled by using Tuya’s mobile app. Any third-party apps or channels do not have access. If automatic unlocking is enabled for an unpaired device, only this device can initiate a pairing request.

  • The unique Identity Resolving Key (IRK) is written to a specified location on the device. As the mobile phone approaches the device, the IRK information will be verified. After users enable automatic locking or unlocking, IRK check will be activated.

    Human Interface Device (HID)

HID demo

Download the HID demo and get started with your development.

FAQs

How does automatic unlocking work?

In a nutshell, the mobile app connects to a Bluetooth device. The locking or unlocking action is triggered based on the distance between the phone and the device.

Automatic Bluetooth reconnection and RSSI-based distance determination together achieve automatic unlocking.

How can I ensure the automatic unlocking is secure?

The device can initiate a pairing request only after its IRK information is verified.

Besides, the unlocking distance is within 10 meters, making the target device reachable and controllable.

What will happen if users just pass by?

Automatic locking is disabled by default. It can be enabled separately.

Besides, automatic locking and unlocking states are associated to avoid the unlocked state.

Can the device be controllable after a misoperation?

After any misoperations occur, the device can only be controlled by encrypted commands.