Bluetooth Lock Implementation Process

Last Updated on : 2024-06-21 03:35:19download

This topic describes the implementation of Bluetooth lock functions. For example, you can pair the device, view unlocking records, view alerts, and manage passwords.

Pair the device

Scenario

For first-time pairing or pairing again after a device is removed, you do not need to manually set the data points (DPs).

Implementation process

After successful pairing, power on the module to transmit data and wait for the server connection result returned from the module.

Bluetooth Lock Implementation Process

Protocol:

  • 0x01: Get microcontroller unit (MCU) information.
  • 0x02: Request the working mode of the module.
  • 0x03: Send the working status of the module.
  • 0x04: Reset the module.

Display the battery level

Scenario

Display the current battery level of a device.

DPs

  • DP 8: the remaining battery capacity.

  • DP 9: the battery level.

    Note: Select either of these DPs. If both DPs are selected, the battery level is displayed. You can select a DP based on your device requirements.

Description

  • Remaining battery capacity: Display the battery percentage. Valid values: 0 to 100.
  • Battery level: Display the battery level. Valid values: high, medium, low, and out of battery.
  • Report the battery level in the following scenarios:
    • First-time pairing or pairing again.
    • Device reboot after specific operations, for example, after the battery is replaced.
    • The battery level is changed.
    • Regular reporting, such as reporting once every 10 days.

Protocol: 0x07 is used to report real-time status.

View unlocking records

Scenario

View the unlocking records on the app.

DPs

  • DP 12: unlock the door with fingerprints

  • DP 13: unlock the door with passwords

  • DP 14: unlock with dynamic passwords

  • DP 15: unlock the door with cards

  • DP 16: unlock the door with mechanical keys

  • DP 17: door opening and closing events

  • DP 18: unlock from the inside of the door

  • DP 19: Bluetooth-based unlocking records

  • DP 39: unlock with face recognition

  • DP 41: unlock with irises

  • DP 42: unlock with palm prints

  • DP 43: unlock with finger veins

  • DP 55: unlock with temporary passwords

    Note: Contact the project manager to grant permissions and allow users to view the unlocking records on the app without the limit on the number of displayed records.

Description

  • Records of unlocking with fingerprints, passwords, cards, face recognition, irises, palm prints, finger veins, and Bluetooth connections: The DP values are used to distinguish members. Valid values: 0 to 999. The unlocking records are displayed on the app and show member information in each entry.
  • Records of unlocking with mechanical keys, dynamic passwords, and temporary passwords: The DP values do not have a special meaning. Valid values: 0 to 999. The unlocking records are displayed on the app and do not show member information in each entry.

Implementation process

When the door is opened, the DP of the used unlocking method is reported. If the door is disconnected from the network, the time when an unlocking event occurs must be recorded. Therefore, we recommend that the records of actual status are reported. In this case, the module stores the records that failed to be reported and reports them along with other latest unlocking records after network recovery. The records use the local time of the device. The following table describes the DP values.

Unlocking method DP to be reported DP value
Unlock with fingerprints Unlock with fingerprints Indicate the actual DP status.
Unlock with passwords Unlock with passwords Indicate the actual DP status.
Unlock with dynamic passwords Unlock with dynamic passwords Any values are supported.
Unlock with cards Unlock with cards Indicate the actual DP status.
Unlock with mechanical keys Unlock with mechanical keys Any values are supported.
Unlock from the inside of the door Unlock from the inside of the door 00/01
Unlock with Bluetooth connections Unlock with Bluetooth connections Indicate the actual DP status.
Unlock with face recognition Unlock with face recognition Indicate the actual DP status.
Unlock with irises Unlock with irises Indicate the actual DP status.
Unlock with palm prints Unlock with palm prints Indicate the actual DP status.
Unlock with finger veins Unlock with finger veins Indicate the actual DP status.
Unlock with temporary passwords Unlock with temporary passwords Any values are supported.

Bluetooth Lock Implementation Process

Protocol: 0xE0 is used to report status records.

View alerts

Scenario

If an alert is triggered, the app instantly shows the alert. Users can view the alerts on the app.

DPs

  • DP 21: lock alerts
  • DP 22: duress alarms
  • DP 24: doorbell calls

Note: Contact the project manager to grant permissions to allow users to view the unlocking records on the app without the limit on the number of displayed records.

Description

  • Lock alerts: The alerts cover multiple scenarios, including fingerprint attempts, password attempts, card attempts, face recognition attempts, stuck bolts, high temperature, overtime unlocked reminders, electronic lock tongue not ejected, anti-pry design, key insertion, low battery, running out of battery, and vibration alerts.
  • Duress alarm: The fingerprint number that indicates a duress alarm is marked on the app. When the fingerprint is used to unlock, a duress alarm is triggered.
  • Doorbell call: If the door lock hardware supports the doorbell call function, after a visitor presses the doorbell on the door lock, the app notifies the user of the doorbell call and generates a doorbell alert.

Implementation process

  • Implementation logic

    After an alert is triggered, the MCU reports the specified alert DP value.

    Note: When status records are reported, the accurate local time of the device is included in the records. If the local time of the device lags behind the actual time, when the app receives an alert, the alert icon on the app does not blink. Users can tap the icon to view the alert. If the server time prevails, after the device is reconnected after network recovery, the record time does not reflect the actual event time.

  • Flowchart

    Bluetooth Lock Implementation Process

Protocol: 0xE0 is used to report status records.

Manage temporary passwords

Scenario

The user sets a temporary password on the app. A visitor can enter the temporary password within the validity period of the password to unlock the door. To enable this function, a real-time clock (RTC) must be integrated into the smart lock. We recommend that you get the temporary password and store it locally on the lock.

DPs

  • DP 51: add a temporary password
  • DP 52: delete a temporary password
  • DP 53: modify a temporary password
  • DP 55: unlock with a temporary password

Description

  • Add a temporary password: Create a temporary password on the app and send it to the lock.
  • Delete a temporary password: Delete the temporary password on the app. Each password to be deleted is assigned a unique password number by the server. The deleted password cannot be recovered.
  • Modify a temporary password: Modify a password on the app. Each password to be modified is assigned a unique password number by the server.

Implementation process

Bluetooth Lock Implementation Process

Manage dynamic passwords

Scenario

The user sets a dynamic password on the app. A visitor can enter the dynamic password within the validity period of the password to unlock the door.

DPs

DP 14: unlock with dynamic passwords

Implementation process

A dynamic password is generated on the app. When a visitor uses this dynamic password to unlock the door, the lock reports this event. The module returns the verification result. The lock controls the unlocking operation based on the verification result. The dynamic password can be used on an offline lock. The password is valid within five minutes after it is generated and must be generated again after the password expires.

Note: The dynamic password is generated on the app. Currently, administrator password comparison is not supported by the all-in-one Bluetooth lock panels but is supported on the embedded system and server.

Bluetooth Lock Implementation Process

Protocol: 0xE6 is used to get a one-time dynamic password.

Manage SMS notifications

Scenario

  • This function is used along with the temporary password function. When the user creates a temporary password on the Tuya Smart app or OEM app, a text message is sent to a specified mobile number. The text message contains the device name, password, validity period, and expiry time.
  • To create a temporary password on the app, the user can select the country or region code.

DPs

DP 25: SMS notifications

Description

  • This DP is optional. This function is a paid offer.

  • After you select this DP, go to the Functional Expansion tab on the value-added services (VAS) platform and subscribe to the Door Lock SMS Notification function.

    Bluetooth Lock Implementation Process

    Note: No protocol settings are required to enable this function.

Manage unlocking methods

Scenario

Add, modify, or delete unlocking methods on the app. Then, the lock applies these settings and returns the setting results. These settings are associated with the home members of the lock.

DPs

  • DP 1: add an unlocking method
  • DP 2: delete an unlocking method
  • DP 3: modify an unlocking method
  • DP 4: freeze an unlocking method (deprecated)
  • DP 5: unfreeze an unlocking method (deprecated)
  • DP 35: synchronize unlocking methods of a member between the app and the lock (deprecated)
  • DP 49: unfreeze users
  • DP 50: freeze users
  • DP 54: synchronize unlocking methods

Description

  • Add, modify, and delete an unlocking method: After a Bluetooth connection is established with the lock within a short distance, cards, passwords, or fingerprints can be created, deleted, and modified on the app.
  • Synchronize unlocking methods of a member: Synchronize all unlocking methods of a member. This enables the app to get all unlocking methods that are available to a member in real time. This ensures consistency between the app and the device. (deprecated)
  • Freeze and unfreeze users: Freeze and unfreeze users on the app. The associated unlocking methods are disabled after the users are frozen, and these methods are enabled after they are unfrozen.
  • Synchronize unlocking methods: Unlocking methods can be added to the app and the lock. Each time users open the device list or pull down to refresh the device list on the app, all unlocking methods are synchronized between the app and the lock. This ensures consistent unlocking methods between the app and the lock.

Implementation process

Bluetooth Lock Implementation Process

The implementation process is complex. For more information, see DP Reference.

Unlock with Bluetooth connections

Scenario

After the door is connected with the app over Bluetooth, users can tap a specific button on the app to unlock the door.

DPs

  • DP 6: unlock with Bluetooth connections
  • DP 7: get feedback for Bluetooth-based unlocking
  • DP 19: Bluetooth-based unlocking records

Implementation process

Bluetooth Lock Implementation Process

Unlock remotely with the app or a smart speaker

Scenario

After the door is connected with the app over Bluetooth, users can tap a specific button on the app or talk to a smart speaker to unlock the door.

DPs

  • DP 60: remote unlocking configurations
  • DP 61: remote unlocking
  • DP 62: remote unlocking with a mobile phone
  • DP 63: remote unlocking with a smart speaker

Implementation process

Bluetooth Lock Implementation Process

Manage members

Scenario

Manage permissions of different members on the app.

Role permissions

Role Belong to the home served by the device App account created Manage administrators and common members (add, modify, query, and delete) Manage cards, passwords, and fingerprints Temporary passwords Dynamic passwords and remote unlocking on the app Validity period View records and device status
Administrator Yes Yes Yes Yes Yes Yes Permanent Yes
Home member Yes Yes No Optional, enabled by default, and can be disabled No Optional, enabled by default, and can be disabled Permanent Yes, only the unlocking records for the specified account available
Sharing by common members No Yes No Optional, enabled by default, and can be disabled No Optional, enabled by default, and can be disabled Optional Yes, only the unlocking records for the specified account available
Common members No No No Optional, enabled by default, and can be disabled No Optional, enabled by default, and can be disabled Optional Yes, only the unlocking records for the specified account available

Other usage notes

Perform a production test

  • Use the 0x0E command to implement the radio frequency (RF) test during a production test of the lock.

  • Test tool: Bluetooth beacon provided by Tuya. This tool is used to emit a broadcast signal named ty_mdev.

  • Test steps: Put the beacon about 0.5 meters away from the module. Send the RF test command through the serial port. The module searches for the Bluetooth beacon and returns the signal strength value. If the signal strength is greater than -70 dB, the RF of the module works as expected.

Set alerts

To send push notifications to the app, configure this function on the Tuya Developer Platform. For more information, see Configure Push Notification.