MCU Integration Protocol for Gateway Pro

Last Updated on : 2024-07-01 08:47:27download

This topic describes the serial protocol that is used to implement serial communication between Tuya’s Wi-Fi module and the third-party MCU.

MCU Integration Protocol for Gateway Pro

Serial communication

  • Baud: 115200
  • Data bit: 8
  • Parity check: none
  • Stop bit: 1
  • Data flow control: none
  • MCU: microcontroller unit. Your MCU communicates with Tuya’s modules through the serial port.

Frame format

Field Length (byte) Description
Header 2 It is fixed to 0x55aa.
Version 1 The firmware version number of your MCU.
Command 1 A specific command to instruct the hardware to act and perform certain tasks.
Data length 2 Data in big-endian format.
Data Depends on data The payload.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Basic protocol

Query product information

Product information consists of the product ID and the MCU software version number.

  • Product ID (PID): a unique identifier assigned to each product created on the Tuya IoT Development Platform for storing product information in the cloud.
  • MCU software version number: It is expressed in dot-decimal notation, x.x.x. x is a decimal digit between 0 and 99.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 Valid values:
  • 0x00: Getting the PID is not supported.
  • 0x01: Getting the PID is supported.
Command 1 0x01
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 01 0000 00

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 Valid values:
  • 0x00
  • 0x01
Command 1 0x01
Data length 2 N
Data Depends on data See the example.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Example: {"v":"1.0.0", "m":0, "cap":0, "p":"mhnmpqzf7ntzm***", "s":0,}

  • v: the MCU firmware version. Example: 1.0.0

  • m: the pairing mode. The gateway pro only supports the default pairing mode.

    • 0: the default pairing mode.
  • cap: the capability that a gateway has. The value of this parameter is a decimal value to which a hexadecimal value converts. The feature represented by each bit:

    • Bit2: support for data point (DP).

    • Bit4: support for updating MCU’s firmware.

    • Bit5: support for group control command sub_id.

    • The unused bits are padded with zeros.

      Assume a gateway does not support the local group control (bit0 is 0) and the local scenes (bit1 is 0) but supports the data point (bit2 is 1). The value of cap is 0000 0000 0000 0100 in hex, which is 4 in decimal.

  • p: the product ID (PID). In the example, the PID is mhnmpqzf7ntz****.

  • (Optional) s: specifies whether a gateway supports the security feature. Its value defaults to 0.

    • 0: a common gateway, without the security feature.
    • 1: a gateway with the security feature.

Report network status

When the network status of the module changes, the module will proactively send its current status to the MCU.

Network status Description Status value
Status 2 Pair a gateway in AP mode. 0x01
Status 3 The Wi-Fi network is set up, but the device is not connected to the router. 0x02
Status 4 The Wi-Fi network is set up, and the device is connected to the router. 0x03
Status 5 The device is connected to the router and the cloud. 0x04

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x03
Data length 2 0x0001
Data 1 Valid values that represent the Wi-Fi network status:
  • 0x01: Status 2
  • 0x02: Status 3
  • 0x03: Status 4
  • 0x04: Status 5
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 03 0001 00 03

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x03
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 03 0000 02

Reset Wi-Fi connection

After a gateway is unbound from the mobile app, it will enter the AP pairing mode (status value 0x01).

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x04
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 04 0000 03

The module returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x04
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 04 0000 03

Allow sub-devices to join network

The app sends a command to the gateway to allow a sub-device to join the network within a specified time period.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x06
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.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x06
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.

Disallow sub-devices to join network

The app sends a command to the gateway to stop allowing a device to join the network.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x07
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.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x07
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.

Connect sub-devices to gateway

  • The MCU sends a joining request to the module.
  • (Optional) pk_type: default to 1.
  • channel is required if you enable the OTA update feature for the sub-device. Its value defaults to 10. Go to the Tuya IoT Development Platform > Hardware Development > Add Custom Firmware > Update Channel to set the channel for OTA update.
    • The current version of the SDK does not support updating sub-devices by using OTA.
    • Incorrect configuration of the update channel might cause the OTA feature to fail.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x08
Data length 2 N
Data N
  • Example:
    {
    “pk_type”:xx
    “sub_id”:“xxxx”,
    “pid”:“xxxx”,
    “ver”:“x.x.x”,
    “channel”:xxx,
    “ota”:x
    }
  • Parameter description
    • (Optional) pk_type: the custom product type.
    • sub_id: the identifier of a sub-device, maximum length 25 characters, which must be unique. You can use the MAC address or the chip ID as the sub_id but cannot use the common identifier that represents the gateway functionality such as 0000.0000.
    • pid: the PID of the product.
    • ver: the firmware version number, such as 1.0.0.
    • channel: the OTA update channel. Its value must match the update channel you configure for the custom firmware on the Tuya IoT Development Platform. The value defaults to 10.
    • ota: specifies whether a sub-device supports the OTA update feature. The value defaults to 0. 0: not support. 1: support.
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x08
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.

Delete sub-devices

The module sends the MCU the information about deleting a sub-device.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x09
Data length 2 N
Data Depends on data
  • Example:
    {
    “sub_id”:“xxxx”,
    “devkey”:“xxx”,
    “tp”:xx
    }
  • Parameter description
    • sub_id: the ID of the sub-device to delete.
    • (Optional) Devkey: the device key, used to remove a sub-device.
    • tp:
      • 0: Remove a sub-device.
      • 1: Restore a sub-device to factory settings by using the mobile app.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x09
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.

Heartbeat check

The module sends a heartbeat packet to the MCU regularly to check the status of its connection to sub-devices. The heartbeat check interval depends on the number of connected sub-devices. The more the sub-devices are connected, the shorter the interval is.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0A
Data length 2 N
Data Depends on data
  • Example: { “sub_id”:“xxxx” }
  • sub_id: The ID of the sub-device.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

The online device must respond to the heartbeat packet. If the module does not receive a response in two consecutive intervals, it will declare that a device is offline.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0A
Data length 2 N
Data Depends on data
  • Example: { “sub_id”:“xxxx”,“lp”:x,“hb_time”:0 }
  • Parameter description
    • sub_id: the ID of the sub-device.
    • lp: the power consumption of the sub-device.
      • 0: standard power
      • 1: low power
    • hb_time: Use this field if the user needs to manage the heartbeat by themselves. When hb_time is 0, it means permanently online. Use 0x2A to report sub-device status.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Query status

This module sends this command to the MCU to get the current status of the sub-device.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0B
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.

The MCU returns status by using the data reporting command.

Send commands

The module sends a command to instruct the MCU to perform a specific task.

  • All available data types except for the raw type are the object types.
  • The module can send commands of multiple DPs to the MCU.
  • Module sending commands is an asynchronous operation, corresponding to MCU reporting status.

The following table lists the format and type of the data unit.

Data segment Length (byte) Description
dpid 1 The identifier of a DP (DP ID).
type 1 It indicates the data type of a DP defined on the Tuya IoT Development Platform.
  • raw: Represents a DP of raw data type.
    • Value: 0x00
    • Length (byte): N
  • bool: Represents a DP of Boolean data type. The valid values are 0x00 and 0x01.
    • Value: 0x01
    • Length (byte): 1
  • value: Represents a DP of integer data type, in big-endian format.
    • Value: 0x02
    • Length (byte): 4
  • string: Represents a DP of string data type.
    • Value: 0x03
    • Length (byte): N
  • enum: Represents a DP of enum data type, ranging from 0 to 255.
    • Value: 0x04
    • Length (byte): 1
  • bitmap: Represents a DP of fault data type. Data greater than one byte is transmitted in big-endian format.
    • Value: 0x05
    • Length (byte): 1, 2, or 4
len 2 The length is the number of bytes of the value, in big-endian format.
value 1/2/4/N Represented in hexadecimal format. Data greater than one byte is transmitted in big-endian format.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0C
Data length 2 N
Data Depends on data
  • Example: id_len(1byte) + sub_id(nbyte)+ datapoint
  • Parameter description
    • id_len: the length of the sub-device ID.
    • sub_id: the ID of the sub-device.
      Note: If sub_id is 0000, it means this command is sent to the gateway itself rather than to the sub-device.
    • datapoint: the collection of DPs.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Report status

The sub-device responds to a status query from the gateway or proactively sends the current status of DPs to the module on the gateway.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0D
Data length 2 N
Data Depends on data
  • Example: id_len(1byte) + sub_id(nbyte)+ datapoint
  • Parameter description
    • id_len: the length of the sub-device ID.
    • sub_id: the ID of the sub-device.
      Note: If sub_id is 0000, it means this command is sent to the gateway itself rather than to the sub-device.
    • datapoint: the collection of DPs.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Add a sub-device to a group

Add a sub-device to a local group.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0E
Data length 2 N
Data Depends on data
  • Example:
    The sub-devices 12, 34, and 56 join group 01. The payload is { "gid":"01", "cids":["12","34","56"] }.
  • Parameter description
    • gid: the ID of the group.
    • cids: the collection of IDs of sub-devices that join the group.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0E
Data length 2 N
Data Depends on data
  • Example: { "gid":"12", "cids":["12","34","56"], "rets":[0,0,0] }
  • Parameter description
    • gid: the ID of the group.
    • cids: the collection of IDs of sub-devices that join the group.
    • rets: the operation results.
      • 0: The sub-device is added successfully.
      • 1: Hit the maximum number of groups.
      • 2: The sub-device times out.
      • 3: The specified value is out of range.
      • 4: Write-error occurs.
      • 5: Other errors occur.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Delete sub-devices from group

Delete a sub-device from a local group.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0F
Data length 2 N
Data Depends on data
  • Example:
    The sub-device 12 is deleted from the group 01. { "gid":"01", "cids":["12"] }
  • Parameter description
    • gid: the ID of the group.
    • cids: the collection of IDs of sub-devices.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x0F
Data length 2 N
Data Depends on data
  • Example: { "gid":"01", "cids":["12"], "rets":[0] }
  • Parameter description
    • gid: the ID of the group.
    • cids: the collection of IDs of sub-devices to be removed from the group.
    • rets: the operation results.
      • 0: Success.
      • 1: Hit the maximum number of groups.
      • 2: The sub-device times out.
      • 3: The specified value is out of range.
      • 4: Write-error occurs.
      • 5: Other errors occur.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Get the GMT

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x10
Data length 2 0x0000
Data 0 Example: 0x55aa 00 10 0000 0F
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x10
Data length 2 0x0007
Data 7
  • Example:
    0x55aa 00 10 0007 01 10 04 13 05 06 07 50 indicates the time 05:06:07 on April 19, 2016 in GMT.
  • Parameter description
    • Data[0]: indicates whether the time is obtained successfully.
      • 0: failure
      • 1: success
    • Data[1]: indicates the year. 0x00 indicates the year 2000.
    • Data[2]: indicates the month, ranging from 1 to 12.
    • Data[3]: indicates the day, ranging from 1 to 31.
    • Data[4]: indicates the hour, ranging from 0 to 23.
    • Data[5]: indicates the minute, ranging from 0 to 59.
    • Data[6]: indicates the second, ranging from 0 to 59.
    Note: The day of the month is represented as an integer from 1 to 31, which is 01 to 1F in hexadecimal. For example, 13 in hex is 19 in decimal, which means the 19th of the month.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Get local time

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x11
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.

The module returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x11
Data length 2 0x0008
Data 8
  • Example:
    0x55aa 00 10 0007 01 10 04 13 05 06 07 02 54 indicates the time 05:06:07 on April 19, 2016, Tuesday in GMT.
  • Parameter description
    • Data[0]: indicates whether the time is obtained successfully.
      • 0: failure
      • 1: success
    • Data[1]: indicates the year. 0x00 indicates the year 2000.
    • Data[2]: indicates the month, ranging from 1 to 12.
    • Data[3]: indicates the day, ranging from 1 to 31.
    • Data[4]: indicates the hour, ranging from 0 to 23.
    • Data[5]: indicates the minute, ranging from 0 to 59.
    • Data[6]: indicates the second, ranging from 0 to 59.
    • Data[7]: indicates the week, ranging from 1 to 7. 1 indicates Monday.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.
  • If the device is activated in mainland China, the local time is Beijing time (UTC+8).
  • If the device is activated in other countries or regions, the local time is the time zone on the mobile phone.

Add devices in bulk

Add sub-devices with the same PID in bulk. Up to 32 sub-devices can be added at a time.

The current version of the SDK does not support updating sub-devices by using OTA.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x12
Data length 2 N
Data Depends on data
  • Example:
    { "pid":" xxxx", "cids":["12","34","56"], "ver":"x.x.x","channel":xxx,"ota":x}
  • Parameter description
    • pid: the PID of the product.
    • cids: the collection of IDs of sub-devices.
    • ver: the firmware version number, such as 1.0.0.
    • channel: the OTA update channel for sub-devices. Its value must match the update channel you configure for the custom firmware on the Tuya IoT Development Platform. The value defaults to 10.
    • ota: specifies whether a sub-device supports the OTA update feature. The value defaults to 0.
      • 0: not support
      • 1: support
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x12
Data length 2 N
Data 1
  • 0x00: Data is received successfully.
  • 0x01: Failed to receive or parse data.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Return the result of adding sub-devices

The module sends the result of adding sub-devices to the MCU.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x13
Data length 2 N
Data N
  • Example:
    {
    “cids”:[“12”,“34”,“56”],
    “rets”:[0,0,0],
    “key”:[“xxxx”,“xxx”],
    “virt_id”: [“xxxx”,“xxx”]
    }
  • Parameter description
    • cids: the collection of IDs of sub-devices.
    • channel: the OTA update channel for sub-devices. Its value must match the update channel you configure for the custom firmware on the Tuya IoT Development Platform. The value defaults to 10.
    • ota: specifies whether a sub-device supports the OTA update feature. The value defaults to 0.
      • 0: not support
      • 1: support
    • (Optional) key: the secret key. Only the Bluetooth Low Energy devices support this field currently.
    • (Optional) virt_id: the virtual ID. Only the Bluetooth Low Energy devices support this field currently.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x13
Data length 2 0000
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.

Send group control commands

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x14
Data length 2 N
Data Depends on data
  • Example: id_len(1byte) + grp_id(nbyte)+ datapoint
  • Parameter description
    • id_len: the length of the group ID.
    • grp_id: the group ID.
    • datapoint: the collection of DPs.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x14
Data length 2 0000
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.

Test Wi-Fi functionality

The module scans the router whose SSID is tuya_mdev_test and returns the scanning result and signal strength in percentage.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x15
Data length 2 0x0000
Data Data None
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x15
Data length 2 0x0002
Data 2
  • Data[0]:
    • 0x00: failure
    • 0x01: success
  • Data[1]:
    • If Data[0] is 0x00
      • Data[1] is 0x00, indicating that the module failed to scan the designated SSID.
      • Data[1] is 0x01, indicating that the license is not flashed to the module.
    • If Data[0] is 0x01
      • Data[1] indicates the signal strength, ranging from 0 to 100, 0 for the weakest and 100 for the strongest.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Get Wi-Fi status

The MCU can send this command to the module to get the Wi-Fi status. For more information about the types of Wi-Fi status, see Report network status. The module does not respond to the network status query until the network initialization is completed.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x16
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.

The module returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x16
Data length 2 0x0001
Data 1 Valid values that represent the Wi-Fi network status:
  • 0x01: Status 2
  • 0x02: Status 3
  • 0x03: Status 4
  • 0x04: Status 5
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

(Optional) Restore factory settings

The MCU uses this command to perform a local factory reset. This command should be sent when the device is online or before the device is activated for the first time. Otherwise, it will cause the information on the local device to be out of sync with the cloud server.

After a local factory reset, Bluetooth sub-devices will be directly deleted from the app rather than added to the device list on the home page of the app.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x17
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.

Report the removal status

After receiving a command to disconnect from or perform a factory reset on a sub-device, the module will report the removal status to the MCU.

  • Disconnecting means the gateway removes its connection with a sub-device but does not delete the data of this device. After getting connected again, the information of the sub-device will be resumed and synced to the app.
  • A factory reset means the gateway removes its connection with a sub-device and deletes the data of this device.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x18
Data length 2 0x0001
Data 1
  • 0x00: local factory reset
  • 0x01: remote device removal
  • 0x02: local device removal
  • 0x03: remote factory reset
  • 0x04: clear data without disconnecting the gateway from the network
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Delete sub-devices locally

The MCU sends a command to the module to delete a sub-device.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x19
Data length 2 N
Data Depends on data Example: { “sub_id”:“xxx” }
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x19
Data length 2 0x0001
Data 1
  • 0x00: success
  • 0x01: failure
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Allow/disallow adding sub-devices locally

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1A
Data length 2 0x0003
Data 3
  • Data[0]:
    • 0x00: Disallow adding sub-devices.
    • 0x01: Allow adding sub-devices.
  • Data[1]: Allow adding timestamp, in big-endian format.
  • Data[2]: Allow adding timestamp, in little-endian format.
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1A
Data length 2 0x0001
Data 1
  • 0x00: success
  • 0x01: failure
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Query the list of sub-devices

The MCU can query all the sub-devices connected to the gateway. If the length of the list is greater than 255 bytes, the payload will be delivered in multiple packets.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1C
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.

The module returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1C
Data length 2 N
Data Depends on data
  • Example: id(1byte) + sub_num(1byte) + sub1_len(1byte) + sub1_id + … subn_len(1byte) + subn_id(1byte)
  • Parameter description
    • id:
      • 07:
        • false: All the addresses of sub-devices have been sent.
        • true: There is still data left, which will be sent in the next packet.
      • 00 to 06: the sequence number of the packet, starting with zero.
    • sub_num: the number of sub-devices included in this packet.
    • sub1_len: the length of the sub-device ID.
    • sub1_id: the ID of the sub-device.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

OTA update

You can choose the desired update options for the OTA firmware update. The module only serves as the channel for OTA data transmission, without any data parsing operation.

After the module has sent all update packets, it will send the command 0x01 to request the product information. The MCU must reply with the new MCU firmware version number within one minute. The new version number should be consistent with that configured on the Tuya IoT Development Platform.

  • The update options:

    • Update notification: Users receive a firmware update notification on the app and choose whether to install updates.
    • Forced update: Users receive a firmware update notification on the app and have no option but to update the firmware.
    • Check for updates: Users will not receive a firmware update notification on the app but need to manually check for new updates.
    • Automatic update (previously named silent update): Users will not receive any update notification. The module checks for firmware updates within the specified time period after power on and install updates if any are available. The module checks for updates every 24 hours after the first-time power on.
  • The following flowchart shows how the OTA firmware update works.

    MCU Integration Protocol for Gateway Pro

Initiate an update

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1D
Data length 2 0x0004
Data 4 The size of the update, in big-endian format.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1D
Data length 2 0x0001
Data 1 The options on the maximum size of each packet:
  • 0x00: 256 bytes. It is the default value and is compatible with legacy firmware.
  • 0x01: 512 bytes
  • 0x02: 1,024 bytes
  • 0x03: 128 bytes
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Transfer the update

  • Data format: packet offset (unsigned short) + payload.
  • When the MCU receives a frame with a data length equal to 4 bytes and the packet offset is equal to or greater than the size of the update, the transfer is completed.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1E
Data length 2 0x0004+m
m: the offset in bytes.
Data offset_addr(4byte) + pack(mbyte) offset_addr: the offset address.
pack: the payload.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Assume that the size of the update is 530 bytes. The MCU does not need to respond to the last packet.

  • For the first packet, the packet offset is 0x00000000, and the packet length is 256 bytes.

    0x55aa 00 1e 0104 00000000 xx … xx XX

  • For the second packet, the packet offset is 0x00000100, and the packet length is 256 bytes.

    0x55aa 00 1e 0104 00000100 xx … xx XX

  • For the third packet, the packet offset is 0x00000200, and the packet length is 18 bytes.

    0x55aa 00 1e 0016 00000200 xx … xx XX

  • For the last packet, the packet offset is 0x00000212, and the packet length is 0 bytes.

    0x55aa 00 1e 0004 00000212 XX

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1E
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.

Initiate sub-device update

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1F
Data length 2 None
Data Depends on data
  • Example: id_len(1byte) + sub_id(nbyte)+ file_size(4byte)
  • Parameter description
    • id_len: the length of the sub-device ID.
    • sub_id: the ID of the sub-device.
    • file_size: The size of the update, in big-endian format.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1F
Data length 2 0x0001
Data 1 The options on the maximum size of each packet:
  • 0x00: 256 bytes. It is the default value and is compatible with legacy firmware.
  • 0x01: 512 bytes
  • 0x02: 1,024 bytes
  • 0x03: 128 bytes
  • 0x04: 64 bytes
  • 0x05: 32 bytes
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Transfer the update

  • Data format: packet offset (unsigned short) + payload.
  • When the MCU receives a frame with a data length equal to 4 bytes and the packet offset is equal to or greater than the size of the update, the transfer is completed.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x20
Data length 2 None
Data Depends on data
  • Example: id_len(1byte) + sub_id(nbyte)+ offset_addr(4byte)+ pack(mbyte)
  • Parameter description
    • id_len: the length of the sub-device ID.
    • sub_id: the ID of the sub-device.
    • offset_addr: the offset address.
    • pack: the payload.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Assume that the sub_id is 1234 and the size of the update is 530 bytes. The MCU does not need to respond to the last packet.

  • For the first packet, the packet offset is 0x00000000, and the packet length is 256 bytes.

    0x55aa 00 20 0109 04 31 32 33 34 00000000 xx…xx XX

  • For the second packet, the packet offset is 0x00000100, and the packet length is 256 bytes.

    0x55aa 00 20 0109 04 31 32 33 34 00000100 xx…xx XX

  • For the third packet, the packet offset is 0x00000200, and the packet length is 18 bytes.

    0x55aa 00 20 001B 04 31 32 33 34 00000200 xx…xx XX

  • For the last packet, the packet offset is 0x00000212, and the packet length is 0 bytes.

    0x55aa 00 20 0009 04 31 32 33 34 00000212 XX

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x20
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.

Query the version number of the sub-device

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x21
Data length 2 None
Data Depends on data
  • Example: {"sub_id":"xxx"}
  • sub_id: The ID of the sub-device.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x21
Data length 2 None
Data Depends on data
  • Example: {"sub_id":"xxx", "ver":"xx.xx.xx"}
  • Parameter description
    • sub_id: the ID of the sub-device.
    • ver: The firmware version number of the sub-device.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Send group control commands (with sub_id)

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x22
Data length 2 N
Data Depends on data
  • Example: grp_len(1byte) + grp_id(nbyte)+ sub_len(1byte) + sub_id(mbyte) + datapoint
  • Parameter description
    • grp_len: the length of the group ID.
    • grp_id: the group ID.
    • sub_len: the length of the specified sub-device’s ID.
    • sub_id: the ID of the sub-device.
    • datapoint: the collection of DPs.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x22
Data length 2 0000
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.

(Optional) Pairing via serial port

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x23
Data length 2 None
Data Depends on data
  • Example: { "s":"xxx", "p":"yyy", "t":"zzz" }
  • Parameter description
    • s: the SSID of the network.
    • p: the password.
    • t: the token, generated by the app.
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x23
Data length 2 0x0001
Data None
  • 0x00: success
  • 0x01: not entering pairing mode
  • 0x02: invalid JSON data
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Query the status of DPs

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x29
Data length 2 N
Data Depends on data
  • Example: { "sub_id":"xxx", "dpid":[xx,xx,xx] }
  • Parameter description
    • sub_id: the ID of the sub-device.
    • dpid: the array of DP IDs.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns status by using the data reporting command.

Update the connection status of sub-devices

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2A
Data length 2 N
Data Depends on data
  • Example: {"all":0,"cids":["xxx","xxx"],"state":1} or {"all":1,""state":1}
  • Parameter description
    • all:
      • 0: Only the cids data is included.
      • 1: The data of all sub-devices is included. The field cdis is not needed.
    • cids: the collection of IDs of sub-devices.
    • state:
      • 0: offline
      • 1: online
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2A
Data length 2 0x0001
Data 1
  • 0x00: Success
  • 0x01: Failure
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Get the MAC address of the module

The module returns the MAC address of the wireless network interface.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2B
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.

The module returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2B
Data length 2 0x0007
Data Depends on data
  • Data[0]: indicates whether the MAC address is obtained successfully.
    • 0x00: Success
    • 0x01: Failure
  • Data[1] to Data[6]: the MAC address of the module.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Report the status of time-dependent DPs

  • For time-dependent sub-devices such as door locks, the MCU must have the timestamp when an event occurred contained in the payload when it reports status to the module.
  • This is a synchronous command. The MCU reports DP status and then waits for the result from the module.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2C
Data length 2 N
Time 7
  • Data[0]: indicates whether the event timestamp is contained in the payload.
    • 0x00: The event timestamp is not reported.
    • 0x01: The event timestamp in local time is reported.
    • 0x02: The event timestamp in GMT is reported.
    • 0x03: The timestamp, in seconds.
  • If Data[0] is 0x01 or 0x02
    • Data[1]: indicates the year. 0x00 indicates the year 2000.
    • Data[2]: indicates the month, ranging from 1 to 12.
    • Data[3]: indicates the day, ranging from 1 to 31.
    • Data[4]: indicates the hour, ranging from 0 to 23.
    • Data[5]: indicates the minute, ranging from 0 to 59.
    • Data[6]: indicates the second, ranging from 0 to 59.
  • If Data[0] is 0x03
    • Data[1] to Data[4]: a 4-byte timestamp, in big-endian format.
    • Data[5] to Data[6]: padded with zero.
Data Depends on data
  • Example: { id_len(1byte)+sub_id(nbyte)+datapoint}
  • Parameter description
    • id_len: the length of the sub-device ID.
    • sub_id: the ID of the sub-device. If sub_id is 0000, it means the MCU reports the status of DPs of the gateway itself rather than those of the sub-device.
    • datapoint: the collection of DPs.
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2C
Data length 2 0x0001
Data 1
  • 0: Success.
  • 1: Failure.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Query the binding status of sub-devices

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2D
Data length 2 N
Data Depends on data
  • Example: {"sub_id":"xxx", "d_link":x "e_val":"xxx"}
  • Parameter description
    • d_link: indicates whether a sub-device can be bound with both the mobile app and the gateway.
      • 0: not support
      • 1: support
    • (Optional) e_val: the encrypted value.
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2D
Data length 2 0x0007
Data Depends on data
  • Example: {"sub_id":"xxx", "ret":x}
  • Parameter description
    • sub_id: the ID of the sub-device.
    • ret: the current binding status.
      • 0: The sub-device is successfully bound with the gateway.
      • 1: The sub-device is not bound with the gateway but its record is stored on the gateway. This might be because this sub-device is being bound or has no record stored in the cloud.
      • 3: The sub-device is bound with the mobile app but not with the gateway.
      • 4: The sub-device is not bound with the gateway and its relationship with the mobile app is unknown.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Query the information of sub-devices in a group

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2E
Data length 2 N
Data Depends on data
  • Example: { "gid":"xxx", "idx":xx}
  • Parameter description
    • gid: the ID of the group.
    • idx: the sequence number of the sub-device to query. For example, 0 means the first sub-device.
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2E
Data length 2 N
Data Depends on data Example: {"gid":"xxx","sub_id":"xxxx" }
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Report the status-updated DP in a group

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2F
Data length 2 N
Data Depends on data
  • Example: {"gid":"xxx", "dpid":xx}
  • Parameter description
    • gid: the ID of the group.
    • dpid: the DP ID of the DP whose status is updated locally. After the module receives the reporting message, it will query the current status of this DP.
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 Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2F
Data length 2 0x0001
Data 1
  • 0: Success.
  • 1: Failure.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Extended features

Request the system time in GMT with time zone

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x33
Data length 2 0x0001
Data 1 Command: 0x03
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Example: 55 AA 00 33 00 01 03 36

The module returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x33
Data length 2 1+2+1+7
Data 11
  • Subcommand: 0x03 (1 byte)
  • Time zone (2 bytes). For example, -750 represents the GMT-7 time zone.
  • Daylight saving time (DST)
    • 0x00: DST is not applicable.
    • 0x01: DST is applicable.
  • Time value (7 bytes):
    • Data[0]: indicates whether the time is obtained successfully.
      • 0: failure
      • 1: success
    • Data[1]: indicates the year. 0x00 indicates the year 2000.
    • Data[2]: indicates the month, ranging from 1 to 12.
    • Data[3]: indicates the day, ranging from 1 to 31.
    • Data[4]: indicates the hour, ranging from 0 to 23.
    • Data[5]: indicates the minute, ranging from 0 to 59.
    • Data[6]: indicates the second, ranging from 0 to 59.
  • Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Restart device remotely

    The MCU sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0x34
    Data length 2 2
    Data 1 Subcommand: 0x09
    Status 0: Restart device
    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 Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0x34
    Data length 2 2
    Data 1 Subcommand: 0x09
    Result
    • 0: Success.
    • Other values: failure
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Turn on/off 4G channel

    This command only applies to modules that support 4G network.

    The MCU sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0x72
    Data length 2 2
    Data 1 Subcommand: 0x01
    Status
    • 0: Turn off 4G.
    • 1: Turn on 4G.
    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 Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0x72
    Data length 2 2
    Data 1 Subcommand: 0x01
    Result
    • 0: Success.
    • Other values: failure
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Extended protocol for security features

    This section describes the commands specific to the security feature. For more information about implementing the feature, see Security Gateway Capability.

    Set the arm mode

    This command is used to arm or disarm the security system.

    • If the system is being armed, to edit the arm mode, you need to disarm the system first.
    • The arm delay set by using this command is not valid. You need to set its value to 0. The arm delay setup on the mobile app prevails.
    • sub_id: NULL means the gateway itself.

    The MCU sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC0
    Data length 2 1+N
    Data Depends on data
    • Subcommand: 0x00
    • Example: { "mode":"xxx", "sub_id":"xxxxx", "delay":xx}
    • Parameter description
      • mode: the arm mode.
        • 0: disarm
        • 1: arm stay
        • 2: arm away
      • sub_id: the ID of the sub-device.
      • delay: the delay time before the system enters arm status.
        • 0: reads the delay time set by the mobile app.
        • Other values: the specified delay time, in seconds.
    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 Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC0
    Data length 2 2
    Data 1 Subcommand: 0x00
    1 Operation result:
    • 0x00: success
    • Other values: failure
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Request the current security status

    The MCU sends this command to get the current status of the security system.

    The MCU sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC0
    Data length 2 1
    Data 1 Subcommand: 0x01
    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 Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC0
    Data length 2 1+N
    Data 1 Subcommand: 0x01
    Depends on data
    • Example:
      {operation result} + {"mode":"xxx", "alarm":x, "countdown":x}
    • Parameter description
      • Operation result:
        • 0: Success.
        • 1: Failure.
      • mode: the arm mode.
        • 0: disarm
        • 1: arm stay
        • 2: arm away
      • alarm: the alarm status.
        • 0: An alarm is triggered with a delay.
        • Other values: No alarm is triggered.
      • countdown: the arm delay.
        • 0: Arm delay is running.
        • Other values: Arm delay is not set.
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Sync the security mode settings

    After receiving the security mode settings from the mobile app, the module uses this command to sync the information with the MCU.

    The module sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC0
    Data length 2 1+N
    Data 1 Subcommand: 0x02
    Depends on data
    • Example: {“mode”:“xxx”, “delay”:xx, “sound”:x}
    • Parameter description
      • mode: the arm mode.
        • 0: disarm
        • 1: arm stay
        • 2: arm away
      • delay: the delay time before the system enters arm status.
        • 0: arm delay not set.
        • Other values: the specified delay time, in seconds.
      • sound: specifies whether to play sounds.
        • 0: playing sounds.
        • Other values: not playing sounds.
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    The MCU returns the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC0
    Data length 2 1
    Data 1 Subcommand: 0x02
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Sync security events

    After receiving a disarming event, the module should notify the MCU to cancel the alarm through the DP 32. You need to set the alarm status.

    The module syncs the security events with the MCU by using this command.

    The module sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC0
    Data length 2 1+N
    Data Subcommand 0x03
    Depends on data
    • Example: { "status":x, "data":"xxx" }
    • Parameter description
      • status: the event
        • 0: Disarm
        • 1: Arming
        • 2: A false alarm triggers sound playing.
        • 3: Start countdown.
      • data: the event information.
        • 0: No countdown timer is set.
          Note: Only after the alarm delay is enabled, the countdown timer returns the time left.
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    The MCU returns the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC0
    Data length 2 1
    Data Subcommand 0x03
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Set alarm status

    The alarm delay is set by using the mobile app. After the countdown is done, the module should send the alarm status to the app. If the alarm status is not set, the cloud will also send a message to the app because of the fault tolerance mechanism. We recommend you set the alarm status.

    The MCU syncs the alarm status with the module through the DP 32.

    The MCU sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC1
    Data length 2 2
    Data Subcommand 0x00
    The alarm status.
    • 0: Success
    • Other values: alarming
    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 Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC1
    Data length 2 2
    Data Subcommand 0x00
    Operation result
    • 0: Success.
    • Other values: failure
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Sync the alarm delay status

    When alarm delay is running, the module syncs the current alarm status to the MCU.

    The module sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC1
    Data length 2 2
    Data 1 Subcommand: 0x03
    1 Alarm delay status
    • 0: Alarm delay is not created.
    • 1: Alarm delay is running.
    • 2: Alarm delay is completed.
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    The MCU returns the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC1
    Data length 2 1
    Data 1 Subcommand: 0x03
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Sync alarm information (new)

    This is a new command used to sync alarm information. It works with bit0 of the A field in the 0x01 command. If bit0 is enabled, processing 0xc101 and 0xc102 is not necessary.

    • The GP field is not supported.
    • Non-environmental sensing devices: indicates devices that are not used to sense and monitor the environment.
    • Environmental sensing devices: indicates devices that can sense and monitor the environment.
    • The payload content depends on the enabled features.

    The gp field is reserved for the feature of multi-protection areas. The MCU does not return the value of this field.

    The module sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC1
    Data length 2 1+N
    Data 1 Subcommand: 0x04
    Depends on data
    • Example: {
      “type”:x,
      “sub_id”:“xxx”,
      “dp_inf”:“xxx”,
      “gp”:“xxxx”
      }
    • Parameter description
      • type: the device type that triggers an alarm.
        • 0: Non-environmental sensing devices
        • 1: Environmental sensing devices
      • sub_id: the ID of the sub-device.
      • dpinf: the information of the DP that triggers an alarm, in cJSON format.
      • gp: reserved for the feature of multi-protection areas.
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    The MCU returns the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC1
    Data length 2 1
    Data Subcommand 0x04
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    Sync the alarm status (new)

    This is a new command used to sync alarm status. It works with the enabled bit0 of the A field in the 0x01 command.

    The module sends the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC1
    Data length 2 2
    Data 1 Subcommand: 0x05
    Data
    • 0: Cancel alarming.
    • 1: The system is alarming.
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

    The MCU returns the following data.

    Field Length (byte) Description
    Header 2 0x55aa
    Version 1 0x00
    Command 1 0xC1
    Data length 2 1
    Data 1 Subcommand: 0x05
    Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.