Create a project
tos.py new project creates a new project in the TuyaOpen development environment. The command initializes the basic structure of a project from a predefined template.
Create the projectโ
Run tos.py new project. The command prompts you for the project name and the platform.
โฏ tos.py new project
[INFO]: Running tos.py ...
[NOTE]: Input new project name.
input: new-project
The command creates a folder named new-project in the current directory, containing the basic project structure.
Directoryโ
new-project
โโโ app_default.config # Default configuration file
โโโ CMakeLists.txt # CMake build configuration
โโโ src
โโโ hello_world.c # Sample code file
Parametersโ
-f, --framework [base|arduino]: the framework type the project uses.
base(default): creates a base framework project.arduino: creates an Arduino framework project.
Next stepsโ
After creating the project, build and verify it, write your code, adjust the configuration to verify functionality, and save the default configuration for other developers.
Build and verifyโ
- Run
tos.py config choiceto select the chip platform configuration. - Run
tos.py buildto verify the compilation.
Write codeโ
-
Determine your code's directory structure, then configure the source and header file paths required by
add_library(${EXAMPLE_LIB})inCMakeLists.txt.${EXAMPLE_LIB}is the library name variable. The main framework defines it, so you do not modify it manually.- Configure the
APP_SRCandAPP_INCvariables using standardCMakesyntax.
-
Develop your code. Use the interfaces provided in
${tuyaopen_root}/srcand${tuyaopen_root}/platform/.../tuyaos_adapter. Refer to the official sample code underappsandexamples. -
Change the configuration. Run
tos.py config menuto open the configuration interface, then adjust the TuyaOpen configuration options.
Verify functionalityโ
Flash the firmware and verify the code's functionality.
Save the default configurationโ
Run tos.py config save to save the current configuration as the default configuration file.