Authorize Devices
Overview
For information about licenses, see License.
You can use either of the following authorization methods:
- Run the authorization command
- Modify header file
Run the authorization command
-
Run the command
tos.py monitor -b 115200.tipSelect the serial port number used for flashing.
tipThe prerequisite for using this command is that you must be in the application project path (where
tos.py buildis executed) and the project has been successfully compiled. -
Enter the interactive command, use
auth,and then press Enter. You will get the following information:[INFO]: Run Tuya Uart Tool.
--------------------
1. /dev/ttyACM1
2. /dev/ttyACM0
--------------------
Select serial port: 2
[INFO]: Open Monitor. (Quit: Ctrl+c)
auth
auth
Use like: auth uuidxxxxxxxxxxxxxxxx keyxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tuya> -
Use
authas prompted to writeuuidandauthkey.tuya>
auth uuid9f6a6xxxxxxxxxxx cGuDnU2YxjHJldjxxxxxxxxxxxxxxxxx
auth uuid9f6a6xxxxxxxxxxx cGuDnU2YxjHJldjxxxxxxxxxxxxxxxxx
Authorization write succeeds. -
Use the
auth-readcommand to verify if the authorization was successful.The following output indicates successful authorization:
tuya>
auth-read
auth-read
uuid9f6a6xxxxxxxxxxx
cGuDnU2YxjHJldjxxxxxxxxxxxxxxxxx -
After successful operation, reboot the device for the authorization information to take effect.
If the device does not support authorization commands, refer to the section below to configure authorization information by modifying the header file.
Modify header file
-
Locate the
tuya_config.hfile in your project directory. The directory might vary by project (check either thesrcorincludedirectory). -
Modify the configuration of the authorization information in the file as follows:
#define TUYA_OPENSDK_UUID "uuidxxxxxxxxxxxxxxxx" // Change to the correct uuid
#define TUYA_OPENSDK_AUTHKEY "keyxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Change to the correct authkey -
Rebuild the firmware, flash it to the device, and then power on the device.