Is this page helpful?
YesNoLast Updated on : 2022-01-04 07:21:36download
With custom development solutions on the Tuya IoT Development Platform, you can build IoT projects for most industry scenarios in which assets and users can be managed. You can create multiple applications for a custom development project to share the assets and users. This topic describes how to create a cloud development project with custom development methods. In the following example, a smart office project is created.
On the Tuya IoT Development Platform, simulate the remote management of smart lights on the first floor of Building A of the East Lake Square. For example, turn on and off the smart lights and switch the working modes.
The cloud development projects support a variety of ways to link devices. This topic describes the whole process of project creation, taking Link Devices by Android App for example. The following figure shows the procedure.
Log in to the Platform.
In the left-side navigation bar, choose Cloud > Projects.
On the page that appears, click Create.
On the Create Project page, configure Project Name, Description, Industry, Development Method, and Availability Zone. From the drop-down list of Development Method, select Custom Development.
Note: Tuya has deployed six data centers around the world to provide more stable IoT cloud services. You can select one or multiple desired zones, which can be modified in the future.
Click Create to complete project creation.
On the page of Authorize API Products, add Device OTA Update and Industry Project Client Service, and click Authorize.
Note: IoT Core and Authorization API products have been selected by default.
Enter the asset and account information, and the asset will be automatically created and authorized to the account. In this example, the East Lake Building is set as the asset name.
Note: For more information about assets, see Manage Assets.
Click Create.
Download the Sample project to the local.
Generate your own keyStore
file for Sample and note down the file password. Perform the following steps:
Note: Currently, the suffix of the generated file is
.jks
, instead of the previous.keyStore
.
Import the Sample file through Android Studio.
Click Build.
Select Generate Signed Bundle / APK from the drop-down box.
Select APK and follow the prompts to create a keyStore
file.
According to the keyStore
file, configure signingConfigs in the build.gradle of the project. In storeFile
, set the storage location of .jks
.
Run the following command in the .jks
storage path to filter the generated .jks
files.
keytool -list -v -keystore xx.jks
{Enter a password}
Get the value of SHA1 key in the file.
Valid from Tue Mar 16 10:22:14 CST 2021 to Sun Mar 06 10:22:14 CST 2061
Certificate fingerprint:
MD5: 6B:8C:94:15:35:7C:2E:E8:6E:76:7F:8C:F9:4B:05:BC
SHA1: 8F:AC:5D:50:65:22:C2:2A:E4:96:3D:8F:9E:DC:5B:43:11:49:55:B1
SHA256: 0B:98:89:D8:D5:FC:B1:23:9A:76:B1:2B:8F:4C:5E:24:BF:E7:60:E8:FF:EF:E9:40: 48:14:60:D3:62:00:5C:5F
Signature algorithm name: SHA256withRSA
Subject public key algorithm: 2048-bit RSA key
Version: 3
Get the package name. You can customize the package name.
Create an application.
.jks
file.com.tuya.iotapp.sample
.Choose Applications > App, and on the page that appears, get the values of Client ID and Client Secret of the created Andriod application.
Copy it to the location of the BaseApplication.java
file in the Sample code, as shown in the figure below.
For example, add a white and colored light (RGBW).
Prerequisites
Create assets.
The East Lake Square where the smart device is located is divided into Building A and Building B, with one floor and two floors respectively. The process of building the asset structure is as follows.
Run the Sample file through Android Studio.
Select the time zone, enter the username and password of the app account, and log in to the app.
On the Devices page of the East Lake Square/Building A/F1 node, click AP Pairing and follow the prompts to add devices.
After adding, refresh the page to view the added device.
On the Devices page of the East Lake Square/Building A/F1 node on the Tuya IoT Platform, view the synced device and note down the Device ID.
Note: The device ID is required for subsequent API requests.
After you add the device, you can call API operations to remotely turn on and off the light, and switch the working mode. On the API Explorer page, you can make an API request to control the devices.
Click Cloud > API Explorer.
From the drop-down list of subscribed APIs, select IoT Core.
On the API Explorer page, call the Send commands API, enter device_id
and commands
to implement different operations.
Note: For more information, see Standard Instruction Set.
{
"code": "switch_led",
"value": true
}
{
"code":"work_mode",
"value":"colour"
}
{
"code":"flash_scene_1",
"value":{
"bright":100,
"frequency":76,
"hsv":[
{
"h":210.0,
"s":169.0,
"v":146.0
}
],
"temperature":84
}
}
{
"code": "switch_led",
"value": false
}
Is this page helpful?
YesNoIs this page helpful?
YesNo