Last Updated on : 2024-06-04 06:33:21download
This topic describes the commands for the DP service.
The following table defines the data units for a DP.
Field | Bytes | Description |
---|---|---|
dpid | 1 | The DP ID. |
type | 1 | The data type of DP defined on the Tuya Developer Platform. For more information, see the description of the type field in the following table. |
len | 2 | The length of a value , in bytes. For more information, see the description of the type field in the following table. |
value | 1/2/4/N | Represented in hexadecimal format. Data greater than one byte is transmitted in big-endian format. |
Description of the type
field:
type |
Data type | Bytes | Description |
---|---|---|---|
0x00 | Raw | N | Represents a DP of raw data type. The module transmits the raw data to the receiver. |
0x01 | Boolean | 1 | Represents a DP of Boolean data type. Valid values include 0x00 and 0x01 . |
0x02 | Value | 4 | Represents a DP of integer data type. The data is represented in big-endian format. |
0x03 | String | N | Represents a DP of string data type. |
0x04 | Enum | 1 | Represents a DP of enum data type, ranging from 0 to 255. |
0x05 | Bitmap | 1/2/4 | Data greater than one byte is transmitted in big-endian format. |
The module sends the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x06 |
Data length | 2 | It depends on the types and the number of data units. |
Data | N | Data units |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Suppose that DP 3 of Boolean type is used for on/off control, and 1 means to turn on the device, the module sends 0x55aa 00 06 0005 03 01 0001 01 10 to the MCU.
The MCU responds when dp_ack
is enabled in the product information.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x06 |
Data length | 2 | 0x0001 |
Data | 1 |
|
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
For more information, see Data units.
This is an asynchronous command. The MCU uses it to report device status to the module, which can be triggered by three mechanisms.
After the MCU executes the command received from the module, it reports the changed DP status to the module.
When the MCU proactively detects status changes of DPs, it reports the changed DP status to the module.
When the MCU receives the DP status query, it sends the status of all DPs to the module.
The MCU can report the status of multiple DPs.
The MCU sends the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x07 |
Data length | 2 | It depends on the types and the number of data units. |
Data | N | Data units |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Suppose that DP 5 of value type is used for reporting the current humidity, and the current humidity is 30%, the MCU reports 0x55aa 03 07 0008 05 02 0004 0000001e 3a to the module.
The module asynchronously queries the status of all object DPs. When the MCU receives a query, it sends the status of DPs to the module through the command 0x07.
The module sends a status query to the MCU when the following two events occur.
When powered on for the first time, the module sends a status query after it connects to the MCU and cloud.
When the module detects the MCU is restarted or disconnected and then goes online, the module sends a status query.
The module sends the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x08 |
Data length | 2 | 0x0000 |
Data | 0 | None |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Example: 0x55aa 00 08 0000 07
This is a synchronous command. The MCU reports DP status and then waits for the result from the module.
The MCU should not send a new request until receiving a response to the previous status reporting.
If the data fails to be reported to the cloud due to poor network quality, the module will return a failure code five seconds later. In this case, the MCU should wait for more than five seconds.
For more information, see Data units.
The MCU can report the status of multiple DPs.
The MCU sends the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x22 |
Data length | 2 | It depends on the types and the number of data units. |
Data | N | Data units |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
The module returns the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x23 |
Data length | 2 | 0x01 |
Data | 1 |
|
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
This is a synchronous command. The MCU reports DP status and then waits for the result from the module.
The MCU should not send a new request until receiving a response to the previous status reporting.
If the data fails to be reported to the cloud due to poor network quality, the module will return a failure code five seconds later. In this case, the MCU should wait for more than five seconds.
For more information, see Data units.
The MCU can report the status of multiple DPs.
The MCU sends the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x26 |
Data length | 2 | The length of the DP data unit plus seven |
Timestamp | 7 |
|
Data | N | Data units |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
The module returns the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x26 |
Data length | 2 | 0x0001 |
Data | 1 |
|
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback