环境搭建
概述
首先,完成在不同系统(Linux、Windows、macOS)中的必要工具准备。
然后,使用 tos.py
工具对项目进行配置、编译、烧录等操作。
最后,对设备授权并使用 涂鸦 App 进行配网。
环境准备
信息
推荐使用 Ubuntu24/22/20 的 LTS 版本。
安装必要的工具:
sudo apt-get install lcov cmake-curses-gui build-essential ninja-build wget git python3 python3-pip python3-venv libc6-i386 libsystemd-dev
下载并激活 TuyaOpen
下载 TuyaOpen
仓库:
# 使用 github
git clone https://github.com/tuya/TuyaOpen.git
# 或者使用 gitee
git clone https://gitee.com/tuya-open/TuyaOpen.git
cd TuyaOpen
激活 tos.py
:
. ./export.sh
验证,使用命令 tos.py version
以及 tos.py check
,会出现如下信息:
❯ tos.py version
[INFO]: Running tos.py ...
[INFO]: v1.3.0
❯ tos.py check
[INFO]: Running tos.py ...
[INFO]: [git] (2.43.0 >= 2.0.0) is ok.
[INFO]: [cmake] (4.0.2 >= 3.28.0) is ok.
[INFO]: [make] (4.3 >= 3.0.0) is ok.
[INFO]: [ninja] (1.11.1 >= 1.6.0) is ok.
[INFO]: Downloading submoudules ...
[INFO]: [do subprocess]: cd /home/huatuo/work/open/TuyaOpen && git submodule update --init
[INFO]: Download submoudules successfully.
若 check 命令失败:
# 工具校验不合格,请安装或升级对应工具
# submodules 下载失败,手动执行 git 命令
git submodule update --init
使用如下命令退出激活 tos.py
:
deactivate
关于 tos.py
更详细的说明方法,可使用命令 tos.py --help
进行查看,或参考 tos.py工具使用。
项目操作
选择项目
TuyaOpen 中,可编译项目可在 apps
、example
中进行选择。
这里以switch_demo
为例。首先,进入项目目录。
cd apps/tuya_cloud/switch_demo
配置项目
使用命令 tos.py config choice
,对项目进行配置。
该命令会提供已经验证过的配置选项,用户可根据自己的硬件设备进行选择。
❯ tos.py config choice
[INFO]: Running tos.py ...
[INFO]: Fullclean success.
--------------------
1. LN882H.config
2. EWT103-W15.config
3. Ubuntu.config
4. ESP32-C3.config
5. ESP32-S3.config
6. ESP32.config
7. T3.config
8. T5AI.config
9. T2.config
10. BK7231X.config
--------------------
Input "q" to exit.
Choice config file:
这里以涂鸦 T5 系列开发板为例,需要选择 T5AI.config
。
编译产物
编译项目,使用命令 tos.py build
。
❯ tos.py build
...
[INFO]: ******************************
[INFO]: /xxx/TuyaOpen/apps/tuya_cloud/switch_demo/.build/bin/switch_demo_QIO_1.0.0.bin
[INFO]: ******************************
[INFO]: ******* Build Success ********
[INFO]: ******************************