Last Updated on : 2024-06-18 08:01:28download
Smart locks use different protocols, such as Bluetooth, Wi-Fi, Wi-Fi with camera, and Zigbee. The Smart Lock SDK is built on top of the Smart Life App SDK. This tutorial walks you through a few steps to develop a mobile app with the SDK in an hour. You will learn how to implement the following features:
You can go to GitHub and download the sample code. This tutorial is broken down into sections based on features, making it easy for you to quickly locate the code.
App SDK Development GitHub Sample
With this tutorial and some knowledge of panel development, you will be able to create an Android app like this.
Before starting, ensure you have the following prepared.
Create a Tuya Developer Platform account and an app, with the AppKey
and AppSecret
ready. For more information, see Preparation.
The Smart Lock SDK depends on the Smart Life App SDK. Implement creating an account and adding a home before incorporating lock-specific features. For more information, see Quick Start with Smart Life App SDK.
Prepare a Tuya-enabled lock. This tutorial demonstrates the process using a lock. Visit TuyaGo to explore Tuya-enabled products.
Integrate the Smart Life App SDK and Smart Lock SDK into your project using dependencies. For more information, see SDK Integration.
Tuya-enabled smart locks support all pairing modes available in the Smart Life App SDK, including Wi-Fi access point (AP) mode and Bluetooth pairing. For more information, see Device Pairing.
Before connecting, unlocking, or locking the Bluetooth lock, check the lock’s Bluetooth connection status.
Query Bluetooth connection status
/// Check if the device and phone have established a Bluetooth connection. If it is false, you can call autoConnect to connect.
tuyaLockDevice.isBLEConnected
/// Check device connection status (determine if the gateway is online).
tuyaLockDevice.isOnline
Connect to a Bluetooth lock
/// If the connection fails or gets disconnected, you can call this method to reconnect.
tuyaLockDevice.autoConnect
Unlock a Bluetooth lock
tuyaLockDevice.bleUnlock(Integer lockUserId, IResultCallback callBack)
Lock a Bluetooth lock
void bleManualLock(IResultCallback callBack)
Unlock a Wi-Fi lock remotely
wifiLock?.replyRemoteUnlock(unlock boolean, callback IThingResultCallback<Boolean>)
Review the following documentation to explore more lock SDK features:
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback