应用开发

创建产品并获取产品的 PID

参考文档 https://developer.tuya.com/cn/docs/iot-device-dev/application-creation?id=Kbxw7ket3aujchttps://iot.tuya.com 下创建产品,并获取到创建产品的 PID 。

然后替换对应工程目录下 tuya_config.h 文件中 TUYA_PRODUCT_KEY 宏分别对应 pid。

TuyaOpen 授权码

Tuyaopen Framework 包括:

均采用 TuyaOpen 专用授权码,使用其他授权码无法正常连接涂鸦云。

[tuya_main.c:220] Replace the TUYA_DEVICE_UUID and TUYA_DEVICE_AUTHKEY contents, otherwise the demo cannot work
[tuya_main.c:220] uuid uuidxxxxxxxxxxxxxxxx, authkey keyxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

可通过以下方式获取 TuyaOpen 专用授权码:

../_images/authorization_code.png
tuya_iot_license_t license;

if (OPRT_OK != tuya_iot_license_read(&license)) {
   license.uuid = TUYA_DEVICE_UUID;
   license.authkey = TUYA_DEVICE_AUTHKEY;
   PR_WARN("Replace the TUYA_DEVICE_UUID and TUYA_DEVICE_AUTHKEY contents, otherwise the demo cannot work");
}

tuya_iot_license_read() 接口返回 OPRT_OK,则表示当前设备已经烧录了 TuyaOpen 授权码,否则表示当前模组并未烧录 TuyaOpen 授权码。

编译烧录

  • 运行 tos config_choice 命令, 选择当前运行的开发板或 platform。

  • 如需修改配置,请先运行 tos menuconfig 命令修改配置。

  • 运行 tos build 命令,编译工程。

  • 使用 tos flash 命令进行一键烧录。

更多 tos 具体请参考 tos 使用指南

配网激活

使用 涂鸦APP 通过蓝牙或者 Wi-Fi AP 模式配网并激活设备

TuyaOpen 典型应用