Last Updated on : 2024-05-09 08:49:36download
The Tuya-defined serial communication protocol specifies how the MCU and network module talk to each other, and applies to all standard network modules that are compatible with Tuya. It supports various wireless protocols, including Wi-Fi, Wi-Fi and Bluetooth combo, Bluetooth, Bluetooth mesh, Zigbee, NB-IoT, and LTE Cat.1.
The MCU standard protocol supports two connection modes: standard power consumption and low power consumption, as shown below.
Parameter | Description |
---|---|
Baud (bit/s) |
|
Data bit | 8 |
Parity | None |
Stop bit | 1 |
Data flow control | None |
For more information about auto-baud detection, see the serial communication protocol for a specific wireless technology.
The following wireless technologies use the standard protocol for integration:
Field | Bytes | Description |
---|---|---|
Header | 2 | It is fixed to 0x55aa . |
Version | 1 | It is used for updates and extensions. |
Command | 1 | The frame type. |
Data length | 2 | Big-endian format. |
Data | N | The payload. |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
The Zigbee technology uses the extended protocol for integration:
Field | Bytes | Description |
---|---|---|
Header | 2 | It is fixed to 0x55aa . |
Version | 1 | It is used for updates and extensions. |
Packet ID | 2 | The sequence number of a packet, ranging from 0 to 0xFFF0 . When it reaches 0xFFF0 , it resets to 0 . |
Command | 1 | The frame type. |
Data length | 2 | Big-endian format. |
Data | N | The payload. |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
version
field is used for extended features.One command is sent by one party and received by the other party synchronously. That is, one party sends a command and waits for a response from the other party.
If the sender does not receive a correct response within a specified time period, it will resend the packet after a timeout.
See the Protocol List for the commands applying to a specific wireless technology.
Both command sending and status reporting use asynchronous transmission. For example, the network module sends a command X
and the MCU reports a command Y
. Data transmission is performed as shown below.
The module sends a control command:
Assume that the module sends a command X
and the MCU reports a command Y
.
0x04
.0x04
packet.0x05
.0x05
packet matches the one of the 0x04
packet.The MCU reports status:
The MCU reports status to the module in an asynchronous manner. The MCU reports status either proactively or passively.
Field | Length (byte) | Description | |||
---|---|---|---|---|---|
dpid | 1 | The identifier of a DP (DP ID). | |||
type | 1 | The data type of DP, identified by a value. | |||
Type | Value | Length (byte) | Description | ||
Raw | 0x00 | N | Represents a DP of raw data type. | ||
Boolean | 0x01 | 1 | Represents a DP of Boolean data type. Valid values include 0x00 and 0x01. | ||
Value | 0x02 | 4 | Represents a DP of integer data type, in big-endian format. | ||
String | 0x03 | N | Represents a DP of string data type. | ||
Enum | 0x04 | 1 | Represents a DP of enum data type, ranging from 0 to 255. | ||
Bitmap | 0x05 | 1/2/4 | Data greater than one byte is transmitted in big-endian format. | ||
len | 2 | The length is the number of bytes of a value. | |||
Value | 1/2/4/N | Represented in hexadecimal format. Data greater than one byte is transmitted in big-endian format. |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback