Quick Start

Last Updated on : 2024-04-26 06:31:27download

This topic describes how to compile the laser robot vacuum demo, run the program, and verify basic functionalities.

Prerequisites

In Tuya Wind IDE, you have requested access to the type development kit based on X86_64 development platform for the TuyaOS SDK development mode. For more information, see Get Development Kit.

Directory

The following table shows the directory of software/TuyaOS:

Name Description
apps The application code.
build The build configuration files (leave it as is).
include The header files.
libs The libraries.
Makefile The Makefile.
output The output directory.
scripts The build framework (leave it as is).
vendor The development environment. It is downloaded to the local computer when you execute the build command.
build_app.sh The build script.

Modify application

  1. Populate the PID, UUID, and KEY with the value for the laser robot vacuum product you created on the Tuya Developer Platform.

    The UUID you fill in must be unique and cannot be reused for other devices.

    /************pid uuid authkey for testing only.************/
    CHAR_T s_ty_pid[64]= "PID value"; // The PID of the test device.
    CHAR_T s_ty_uuid[64]="UUID value";// The UUID of the test device.
    CHAR_T s_ty_authkey[64]="KEY value";// The Authkey of the test device.
    /************pid uuid authkey for testing only.************/
    
  2. Create a storage path in non-volatile memory to save parameters of device pairing and activation. The implementation is as follows:

    #define TY_APP_STORAGE_PATH "/tmp/" //Virtual storage path used for testing.
    /* Prepare the read and write storage path of the file system. For real devices, you need to fill in the path assigned locally by the device. */
    TY_INIT_PARAMS_S init_param = {0};
    init_param.init_db = TRUE;
    strcpy(init_param.sys_env, TARGET_PLATFORM);
    TUYA_CALL_ERR_LOG(tuya_iot_init_params(TY_APP_STORAGE_PATH, &init_param));
    

Build project

Option 1: Graphical user interface

In Tuya Wind IDE, right-click the demo directory under software/TuyaOS/apps/ and choose Build Project.

Quick Start

Option 2: Shell script

Navigate to software/TuyaOS/ and run the following command:

./build_app.sh $1 $2 $3 $4

Among which:

  • $1: the path of the application project, for example, apps/tuyaos_demo_robot/.
  • $2: the name of the generated application, for example, tuyaos_demo_robot.
  • $3: the version number, in the format XX.XX.XX, for example, 1.0.0.
  • $4: user command (optional), for example, clean.

Option 3: Makefile

On the command line, navigate to software/TuyaOS/, run make, and specify the application to compile.

Run program

Recommended start command:

./output/x86_64_tuyaos_demo_robot/firmware/tuyaos_demo_robot -c apps/tuyaos_demo_robot -m 0 -t AYGFnn3je2Fi7I -r ./apps/tuyaos_demo_robot
  • c: specifies the directory of tuya_device_cfg.json. No modification is needed.

  • m: the mode. Select AP pairing to run the demo, and the corresponding value is 0.

        /* Tuya SDK definition of Wi-Fi start mode */
        typedef BYTE_T GW_WF_START_MODE;
        #define WF_START_AP_ONLY        0   // only have ap-cfg mode
        #define WF_START_SMART_ONLY     1   // only have smart-cfg mode
        #define WF_START_AP_FIRST       2   // have both ap-cfg and smart-cfg. default is ap-cfg mode
        #define WF_START_SMART_FIRST    3   // have both ap-cfg and smart-cfg. default is smart-cfg mode
        #define WF_START_SMART_AP_CONCURRENT    4   // ap-cfg and smart-cfg is concurrent
    
  • t: the specified token.

    1. On the homepage of the app, tap + > Add Device in the top right corner.

    2. Choose Small Home Appliances > Clean > Robot Vacuum (IPC), and enter the Wi-Fi network name and password, which must be consistent with the Wi-Fi network of the environment where the demo is running.

    3. Tap Next, and a pairing QR code will appear. Use a QR code reader to scan and parse the code to get data like this:

      {"s":"N234","p":"12345678","t":"AYAq3v9OLa4FN9"}
      

      t refers to the specified token.

      The token you fill in is only for demo testing. During actual product development, you do not need to pass in the token value.

  • r: the directory of source files.

    The directory stores data such as maps and paths that need to be reported. It has been implemented in the demo and no modification is needed.

Verify functionalities

This section verifies the basic functionalities of the demo. Before that, you need to pay attention to the following functions. These functions are registered in TuyaOS SDK to receive status or data.

Function Description
ty_cmd_handle_dp_cmd_objs Object type DP interactions.
ty_cmd_handle_dp_raw_objs Raw type DP interactions.
ty_sdk_net_status_change_cb The callback invoked when Wi-Fi connection status is changed.
ty_sdk_app_reset_cb The callback invoked when the device is removed from the mobile app.
ty_user_upgrade_inform_cb The callback invoked when the OTA update is in progress.
ty_user_protocol_p2p_event_cb The callback invoked when the real-time map and route reporting is in progress.
  1. After the device is successfully paired and connected to the cloud, the icon will be displayed on the mobile app.

    You can determine whether the device is connected to the cloud based on the status of the ty_sdk_net_status_change_cb callback. The log is printed as follows:

    Quick Start
  2. After you open the panel, real-time map and route transmission begins.

    Real-time map and route data need to be reported in the ty_user_protocol_p2p_event_cb callback. The log is printed as follows:

    Quick Start
  3. Verify interactions with object type DPs and tap the Start Cleaning button on the mobile app.

    Object type DPs use the ty_cmd_handle_dp_cmd_objs callback to exchange data. The DPs sent by the mobile app need to get a correct reply from the device before the mobile app can display them accordingly. The log is printed as follows:

    Quick Start
  4. Verify raw type DP interactions and tap the Point and Go button on the mobile app.

    Raw type DPs use the ty_cmd_handle_dp_raw_objs callback to exchange data. The raw data format complies with the Tuya laser robot vacuum protocol (byte format) and related logic instructions. For more information, you can consult your Tuya project manager. The log is printed as follows:

    Quick Start
  5. To report historical data, you need to enter the oss_map command in the terminal where the program is running, and select the 6 subcommand to report cleaning history.

    To report other relevant historical data, refer to the comments of the demo for verification. The cleaning history log is printed as follows:

    Quick Start Quick Start
  6. Perform device OTA update. Refer to Manage Firmware and fill in the firmware information. Afterwards, the mobile app will prompt you for available firmware updates.

    During the OTA update process, the ty_user_upgrade_inform_cb callback is used to receive data. The log is printed as follows:

    Quick Start
  7. You can tap and hold the robot vacuum icon on the mobile app to remove the device.

    The ty_sdk_app_reset_cb API is called to remove a device. After the device is successfully removed, the log is printed as follows:

    Quick Start
  8. Refer to the comments on the demo and verify other functionalities.