Last Updated on : 2024-07-10 09:22:44download
This tutorial will walk you through the basic features of a smart travel app, enabling you to kickstart the development process easily.
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
The UI is built using the API from the Smart Travel SDK.
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 Travel SDK depends on the Smart Life App SDK. Implement creating an account and adding a home before incorporating travel-specific features. For more information, see Quick Start with Smart Life App SDK.
Prepare a Tuya-enabled travel product. This tutorial demonstrates the process using a two-wheeler. Visit TuyaGo to explore Tuya-enabled products.
Integrate the Smart Life App SDK and Smart Travel SDK into your project using CocoaPods. For more information, see SDK Integration.
Tuya-enabled travel devices support pairing over Bluetooth or Cat.1. You can select the pairing mode that best suits your needs. For more information, see Device Pairing.
Tuya-enabled devices are controlled through bidirectional communication regarding a range of data points (DPs). The Smart Travel SDK is built using the DP methods from ThingSmartDevice
. It is recommended to use the following methods for controlling all travel-related DPs. If you are unfamiliar with the concept of DP, check out Device Control and Product Functions.
public interface IThingDevice {
/**
* Distributed according to the specified channel sequence
*
* @param dps
* @param orders
* @param callback
*/
void publishDps(String dps, String orders, IResultCallback callback);
}
Methods
IThingDevice thingDevice = ThingHomeSdk.newDeviceInstance(deviceId)
thingDevice.publishDps(xx,xx,xx)
This example demonstrates how to use the basic APIs for automatic unlocking over Bluetooth. See Automatic Unlocking for details.
Core methods
Class | Method | Description |
---|---|---|
IODBtInductiveUnlock | boolean isInductiveUnlockTurnOn(); | Get automatic unlocking on/off status |
IODBtInductiveUnlock | void turnOnInductiveUnlock(InductiveUnlockCallback callback); | Enable automatic unlocking |
IODBtInductiveUnlock | void turnOffInductiveUnlock(IResultCallback callback); | Disable automatic unlocking |
Automatic unlocking requires a Bluetooth connection. Verify if the app has permission to access the phone’s Bluetooth and the current connection status. If necessary, ask the user to enable it.
Check the pairing status for automatic unlocking:
boolean isTurnOn = getInductiveUnlock().isInductiveUnlockTurnOn();
Enable automatic unlocking:
getInductiveUnlock().turnOnInductiveUnlock(new InductiveUnlockCallback() {
@Override
public boolean interceptBluetoothPairing(String bluetoothName) {
// Intercept pairing. The pairing mode varies by mobile phone, which may require manual operations. See the documentation for details.
return super.interceptBluetoothPairing(bluetoothName);
}
@Override
public void onError(String code, String error) {
// Failed to enable.
}
@Override
public void onSuccess() {
// Enabled successfully.
}
});
Disable automatic unlocking:
getInductiveUnlock().turnOffInductiveUnlock(new IResultCallback() {
@Override
public void onError(String code, String error) {
// Failed to disable.
}
@Override
public void onSuccess() {
// Disabled successfully.
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback