Serial Communication Protocol - Tuya Developer Platform - Tuya Developer Platform
Serial Communication Protocol - Tuya Developer Platform - Tuya Developer Platform
Version: 20240613
Online Version
Contents
Contents
1 Serial communication 2
2 Terms 3
3 Packet structure 5
4 DP format 6
4.1 Firmware types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Generic protocol 8
5.1 Detect heartbeat (0x00) . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.2 Get MCU information (0x01) . . . . . . . . . . . . . . . . . . . . . . . 9
5.3 Request working mode (0x02) . . . . . . . . . . . . . . . . . . . . . . 14
5.4 Send module’s status (0x03) . . . . . . . . . . . . . . . . . . . . . . 15
5.5 Reset the module (0x04) . . . . . . . . . . . . . . . . . . . . . . . . 17
5.6 Reset the module (New) (0x05) . . . . . . . . . . . . . . . . . . . . . 18
5.7 Send commands (0x06) . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.8 Report status (0x07) . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.9 Query status (0x08) . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.10Unbind the module (0x09) . . . . . . . . . . . . . . . . . . . . . . . . 23
5.11Query module’s connection status (0x0A) . . . . . . . . . . . . . . . 25
5.12Report record-type data (0xE0) . . . . . . . . . . . . . . . . . . . . . 26
5.13Get the current time (0xE1) . . . . . . . . . . . . . . . . . . . . . . . 29
5.14Notify a factory reset (0xA1) . . . . . . . . . . . . . . . . . . . . . . . 33
5.15Query module’s version number (0xA0) . . . . . . . . . . . . . . . . 34
I
Contents
7 Production test 51
7.1 Radio frequency (RF) (0x0E) . . . . . . . . . . . . . . . . . . . . . . . 51
9 Extended features 64
9.1 Flag-based status reporting (0xA4) . . . . . . . . . . . . . . . . . . . 64
9.2 Bulk data storage (0xB5) . . . . . . . . . . . . . . . . . . . . . . . . 66
9.3 Get weather data (0xB6) . . . . . . . . . . . . . . . . . . . . . . . . 70
9.4 Triggered pairing mode (0xBC) . . . . . . . . . . . . . . . . . . . . . 73
9.5 Bluetooth remote control configuration (0xC100) . . . . . . . . . . . . 76
9.6 Bluetooth remote control data notification (0xC101) . . . . . . . . . . 78
9.7 Bluetooth remote control binding notification (0xC102) . . . . . . . . . 79
12 Bluetooth-specific protocol 90
12.1Disconnect Bluetooth proactively (0xE7) . . . . . . . . . . . . . . . . 90
12.2Advertising enablement (0xA3) . . . . . . . . . . . . . . . . . . . . . 91
12.3Request getting online (0xA5) . . . . . . . . . . . . . . . . . . . . . . 93
12.4Modify advertising interval in low power mode (0xE2) . . . . . . . . . 96
12.5Set the connection interval (0xB1) . . . . . . . . . . . . . . . . . . . 98
12.6Human interface device (HID) (0xBA) . . . . . . . . . . . . . . . . . . 102
12.7Set advertising name (0xBB) . . . . . . . . . . . . . . . . . . . . . . 105
12.8Adjust Bluetooth transmitter power (0xBD) . . . . . . . . . . . . . . . 108
12.9Query module’s MAC address (0xBE) . . . . . . . . . . . . . . . . . 110
II
Contents
III
Contents
This topic describes the serial protocol that is used to implement serial communica-
tion between Tuya’s Bluetooth module and the third-party MCU, as shown in the
following diagram.
1 / 149
1 Serial communication
1 Serial communication
• Data bit: 8
• Stop bit: 1
If the module receives the correct response from the MCU, it will stop baud rate
detection and write the current serial port configuration to the flash memory.
Some legacy firmware versions do not support automatic baud rate detection.
2 / 149
2 Terms
2 Terms
Term Description
3 / 149
2 Terms
Term Description
4 / 149
3 Packet structure
3 Packet structure
0 2 Header 0x55
1 0xAA
2 1 Version number The protocol
version.
3 1 Command (CMD) The frame type.
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
5 / 149
4 DP format
4 DP format
6 / 149
4 DP format
• Typically, all the generic firmware supports the generic protocol. The support
for other protocols depends on the firmware for use.
Basis
Locks
Shared devices
Sensors
Note that the generic firmware support for specific protocols depends on product
categories and models. If you have any questions about protocols, submit a service
ticket.
7 / 149
5 Generic protocol
5 Generic protocol
• After power on, the module will send a heartbeat packet to the MCU every 3
seconds. If the MCU correctly responds to a heartbeat, it indicates the MCU
works properly. After the first-time heartbeat communication, the module will
send the MCU a command to get product information.
• The MCU can determine whether the module works properly by the regular
heartbeat check. If the MCU does not receive a heartbeat packet as expected,
it can use the reset pin to reset the module.
• After getting the MCU information, the module checks the heartbeat every 10
seconds in standard power mode. In low power mode, there is no heartbeat
check.
:::important
The Telink Bluetooth modules do not perform heartbeat checks both in low
power mode and after getting the MCU information in standard power mode.
They cannot detect whether the MCU has been restarted.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x00
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
8 / 149
5 Generic protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x00
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: The MCU returns this value on the first-time heartbeat communication
after a restart. The module uses this value to determine whether the MCU
restarts during operation.
• 0x01: The MCU returns this value except for the first response after a restart.
Product information consists of the product ID (PID) and the MCU software version
number.
9 / 149
5 Generic protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x01
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x01
4 2 Data length. 0x00
5 0x0d
6 to 18+n 13+n Data See the following
table.
19+n 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
10 / 149
5 Generic protocol
Data format
1 to 8 9 to 13 14 to 14+n
• Reserved field: populated with the MCU version number as the placeholder
by default. The module does not parse this field. The MCU reports its version
number using the command 0xE8 or 0xE9.
• TLD: used to configure the features and capabilities for the generic firmware.
TLD refers to a custom data format:
You can set one or multiple TLDs. If you use the default configuration, you can
leave this field as is. Otherwise, populate it with the desired content.
The values of T and L are fixed. The module can get the value of D by parsing
the T and L. There is no order requirement for multiple TLDs.
The following table lists the TLD data format. The number refers to
the sequence number of the byte.
1 2 3
11 / 149
5 Generic protocol
beacon enabled, the device in bound but not connected can report status
to the gateway or app by using broadcasting. For more information, see
Status reporting (0x07).
∗ 0x00: Disable
∗ 0x01: Enable
∗ Others: reserved
Example: 55 AA 00 01 00 10 6D 6E 75 78 64 38 30 75 31 2E 30 2E
30 07 01 01 0F
1 2 3
online_flag: the flag of device online policy. The policy depends on the
Bluetooth gateway for use instead of the mobile app.
Example: 55 AA 00 01 00 13 6D 6E 75 78 64 38 30 75 31 2E 30 2E 30
07 01 01 03 01 01 17
1 2 3
12 / 149
5 Generic protocol
∗ Others: reserved
Example: 55 AA 00 01 00 10 34 6B 78 36 68 6C 61 78 31 2E 30 2E 30
BA 01 01 B3
1 2 3
Example: 55 AA 00 01 00 10 34 6B 78 36 68 6C 61 78 31 2E 30 2E 30
01 01 01 FA
1 2 3
Example: 55 AA 00 01 00 10 34 6B 78 36 68 6C 61 78 31 2E 30 2E 30
C2 01 01 BB
13 / 149
5 Generic protocol
:::info
The MCU information and configuration are stored in the flash memory. If
you do not set the optional information, the module will use the default
configuration or the previous configuration if any.
:::
• The working mode indicates how the network status is indicated and the way
to trigger module reset. Theoretically, the module can work in the following
two modes:
– The MCU works with the module to process network events: The module
sends its current work status to the MCU through serial communication.
The MCU controls the LED to indicate status accordingly. When the MCU de-
tects a request to reset the module, it directs the module to reset through
serial communication.
– The module processes network events itself: Not supported.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x02
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
14 / 149
5 Generic protocol
Example: 55 aa 00 02 00 00 01
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x02
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Example: 55 AA 00 02 00 00 01
– 0x00: Unbound
– 0x01: Bound but not connected
– 0x02: Bound and connected
• The module will send its current status to the MCU after responding to the
command 0x02.
• The module will send its current status to the MCU if the status changes.
15 / 149
5 Generic protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x03
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
16 / 149
5 Generic protocol
• The MCU sends this command to direct the Bluetooth module to be discon-
nected and unbound. The module’s virtual ID and cache data will be cleared.
• For Bluetooth modules using Telink chips, resetting the module with the com-
mand 0x04 will not clear the virtual ID.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x04
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Example: 55 aa 00 04 00 00 03
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x04
4 2 Data length. 0x00
5 0x00
17 / 149
5 Generic protocol
Example: 55 AA 00 04 00 00 03
• The MCU sends this command to direct the Bluetooth module to be discon-
nected and unbound. The module’s virtual ID and cache data will be cleared.
• This command works the same way as the 0x04. The only difference is that
using this command to reset a Telink-based module will clear its virtual ID.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x05
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
18 / 149
5 Generic protocol
Example: 55 aa 00 05 00 00 04
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x05
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Example: 55 AA 00 05 00 00 04
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x06
19 / 149
5 Generic protocol
DP format:
n+3
5 and n+1 to and
1 2 3 to 4 greater ⋯ n n+1 n+2 greater
Example: 55 aa 00 06 00 05 03 01 00 01 01 10
None
– 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.
20 / 149
5 Generic protocol
– When the MCU receives the DP status query, it sends the status of all DPs
to the module.
• If you enable the beacon capability, the module in bound but not connected
can report status using advertising. The maximum dp_len in each packet is
four bytes. For more information about the beacon capability, see Get MCU
information.
• The maximum length of DP data that can be sent varies on the firmware of
different chip platforms. Currently, the Telink platform, BK3431Q and BK3432
platforms support a maximum length of 220 bytes, while PHY6222 and FR8016
support a maximum length of 512 bytes.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x07
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len DP See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
DP format:
21 / 149
5 Generic protocol
n+3
5 and n+1 to and
1 2 3 to 4 greater ⋯ n n+1 n+2 greater
Example: 55 aa 00 07 00 05 03 01 00 01 01 11
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x07
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: Success
• Other values: Failure
• The module asynchronously queries the status of all object DPs. When the
MCU receives queries, it sends the status of DPs to the module through the
command 0x07.
22 / 149
5 Generic protocol
• The module sends a status query when the following two events occur.
– For a bound and connected module, it detects that the MCU is restarted
based on the heartbeat check.
:::info
The Telink generic firmware does not support detecting MCU restart.
:::
– A bound module is reconnected after it goes offline.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x08
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Example: 55 aa 00 08 00 00 07
None
• After the MCU sends this command, the Bluetooth module will be disconnected
and unbound from the mobile app. Its virtual ID and cache data will not be
cleared.
:::info
23 / 149
5 Generic protocol
This command does not apply to the generic firmware for the shared devices.
:::
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x09
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x09
4 2 Data length. 0x00
5 0x01
6 1 State Return value
24 / 149
5 Generic protocol
Return value
• 0x00: Success
• Other values: Failure
• The MCU proactively queries the current connection status of the module. The
module returns its status through the command 0x03.
• The module’s status:
– 0x00: Unbound
– 0x01: Bound but not connected
– 0x02: Bound and connected
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x0A
4 2 Data length. 0x00
5 0x00
25 / 149
5 Generic protocol
• If the module is offline when receiving reported data from the MCU, it will save
the data to its flash memory and send the stranded data after going online.
After the last piece of stranded data is sent to the cloud, the module will release
the cache.
• The module can cache up to N pieces of DP data. When the limit is reached,
the newest record will overwrite the oldest one.
• The time drift of the module’s internal clock is less than one minute in 24 hours.
The module will sync its clock with the server time each time it is connected to
the cloud. If you require highly accurate time, you can report data using the
MCU’s timestamp.
:::important
To ensure reliable data transmission, we recommend you use this command to
report record-type data no matter what connection status the module is in.
:::
26 / 149
5 Generic protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE0
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
TYPE Time_Str
dp1_id dp1_type ⋯
dp1_lendp1_data dpN_id dpN_type
dpN_lendpN_data
27 / 149
5 Generic protocol
0x00 Report data both to the cloud and the app panel.
0x01 Report data to the cloud but not to the app panel.
0x02 Report data to the app panel but not to the cloud.
TYPE_bit7_bit6: Reserved
– 0x01: Report data both to the cloud and the app panel with the time data
from the module.
– 0x03: Report data both to the cloud and the app panel with the time data
from the MCU.
– 0x11: Report data to the cloud only with the time data from the module.
– 0x13: Report data to the cloud only with the time data from the MCU.
– 0x21: Report data to the app panel only with the time data from the mod-
ule.
– 0x23: Report data to the app panel only with the time data from the MCU.
Example:
• Format 1: Report status with the time data from the Bluetooth module.
1 55 AA 00 E0 00 17 01 66 02 00 04 00 00 00 01 67 03 00 05 72 77 72
77 77 68 04 00 01 00 89
• Format 3: Report status with the time data from the MCU
1 55 AA 00 E0 00 28 03 31 35 38 39 31 36 38 33 32 37 30 30 30 66 02
00 04 00 00 00 01 67 03 00 09 72 77 72 77 77 61 66 61 66 68 04
00 01 00 D0
28 / 149
5 Generic protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE0
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: Success
• Other values: Failure
After the module is online, it will proactively sync the server time with the MCU.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE1
4 2 Data length. 0x00
5 0x01
29 / 149
5 Generic protocol
Time_type:
It is recommended to use the format 0x02 to request year, month, and day.
Time_Type_bit7_bit6: Reserved
30 / 149
5 Generic protocol
• 0x00: Request the server time in format 0 through the mobile app.
• 0x01: Request the server time in format 1 through the mobile app.
• 0x02: Request the server time in format 2 through the mobile app.
:::info
Request for custom time data in format 0 might cause compatibility issues
across different chipset platforms. This format will be deprecated in the future.
We recommend you use the date and time format 0x02.
– The Telink based module does not support format 0. The module will return
time data in format 2 if it receives a request for time data in format 0.
– The value of the time zone is 100 times the actual time zone. For example,
800 represents GMT+8.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE1
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Time_Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
31 / 149
5 Generic protocol
• Time_Data format 0:
Time Day
for- of Time
Result mat Year Month Day Hour Minute Second week zone
1 2 3 4 5 6 7 8 9 10 to
11
Result Time_Type
2018+year
mon day hour min sec week time_zone
• Time_Data format 1:
1 2 3 to 15 16 to 17
Result Time_Type unix_time_string time_zone
• Time_Data format 2:
Time Day
for- of Time
Result mat Year Month Day Hour Minute Second week zone
1 2 3 4 5 6 7 8 9 10 to
11
Result Time_Type
2000+year
mon day hour min sec week time_zone
Example:
• Time_Data format 0:
• Time_Data format 1:
32 / 149
5 Generic protocol
• Time_Data format 2:
• After receiving a factory reset command from the app, the module will notify
the MCU to execute the command.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA1
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
None
33 / 149
5 Generic protocol
• The MCU can use this command to query the version number of the module.
If your MCU does not need the version number of the module, implementation
is not necessary.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA0
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA0
4 2 Data length. 0x00
5 0x06
6 to 11 6 DATA See the following
table.
34 / 149
5 Generic protocol
Data format
1 to 3 4 to 6
Soft_Ver Hard_ver
• Soft_Ver: The firmware version of the module. For example, 0x01 00 02 repre-
sents v1.0.2.
• Hard_ver: The hardware version of the module, the PCBA version number.
35 / 149
6 MCU firmware update via OTA
• The module uses this command to get the MCU version number while it queries
the MCU information.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE8
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE8
4 2 Data length. 0x00
5 0x06
36 / 149
6 MCU firmware update via OTA
Data format
1 to 3 4 to 6
Soft_Ver Hard_ver
• Soft_Ver: The firmware version of the MCU. For example, 0x01 00 02 represents
v1.0.2.
• Hard_ver: The hardware version of the MCU, the PCBA version number.
• The MCU proactively sends its version number to the module after startup (gen-
erally after the UART initialization). If the module does not respond, the MCU
will resend the message.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE9
37 / 149
6 MCU firmware update via OTA
Data format
1 to 3 4 to 6
Soft_Ver Hard_ver
• Soft_Ver: The firmware version of the MCU. For example, 0x01 00 02 represents
v1.0.2.
• Hard_ver: The hardware version of the MCU, the PCBA version number.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE9
4 2 Data length. 0x00
5 0x01
6 1 State Return value
38 / 149
6 MCU firmware update via OTA
Return value
• 0x00: Success
• Other values: Failure
39 / 149
6 MCU firmware update via OTA
40 / 149
6 MCU firmware update via OTA
41 / 149
6 MCU firmware update via OTA
• The module initiates an update request to get the maximum length of one
packet for serial transmission.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xEA
4 2 Data length. 0x00
5 0x02
6 to 7 2 The maximum See the
length of one information below.
packet Len1
8 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Len1: The size of the largest packet that can be transmitted over the serial port,
in the unit of bytes.
Example: 55 AA 00 EA 00 02 00 C8 B3
42 / 149
6 MCU firmware update via OTA
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xEA
4 2 Data length. 0x00
5 0x06
6 to 11 6 Data See the following
table.
12 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
1 2 to 4 5 to 6
• Flag: 0x00 indicates the update is accepted. 0x01 indicates the update is re-
jected.
• Version: The current firmware version. For example, 0x01 00 02 represents v1
.0.2.
• Len1: The module-specified maximum length of one packet.
• Len2: The MCU-specified maximum length of one packet. If len1 is less than
len2, len1 prevails. Otherwise, len2 prevails.
Example: 55 AA 00 EA 00 06 00 01 00 00 00 C8 B8
43 / 149
6 MCU firmware update via OTA
• The module sends the information about the firmware update to the MCU. The
MCU determines whether to accept the update accordingly.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xEB
4 2 Data length. 0x00
5 0x23
6 to 40 35 Data See the following
table.
41 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
44 / 149
6 MCU firmware update via OTA
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xEB
4 2 Data length. 0x00
5 0x19
6 to 30 25 Data See the following
table.
31 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
STATE:
- 0x00: The update is performed as expected.
- 0x01: The received PID does not match the one written to the device.
45 / 149
6 MCU firmware update via OTA
- 0x02: The update version is earlier than or equal to the current version.
- 0x03: The update size exceeds the upper limit.
• The device returns information of the update that has been downloaded to
continue downloading from where it was interrupted.
– After receiving the response message, the app will calculate the CRC32
checksum and compare it to the value received.
– If the two match exactly, the app will change the start offset to the
received data length in the following transmission request. Otherwise,
the start offset is 0, meaning downloading from scratch.
• The resumable transfer also follows the normal update process, starting
from initiating an update request. If the module operates in any state rather
than bound and connected, the MCU should reset the update status if any
to start the following update procedure.
For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xEC
4 2 Data length. 0x00
5 0x04
6 to 9 4 Offset See the following
table.
46 / 149
6 MCU firmware update via OTA
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xEC
4 2 Data length. 0x00
5 0x04
6 to 9 4 Offset See the following
table.
10 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
The start offset address specified by the MCU should take precedence over the
one provided by the app. The MCU-specified offset is usually less than the one
provided by the app.
47 / 149
6 MCU firmware update via OTA
For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xED
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
The packet ID starts from 0. The size of the current packet cannot exceed the spec-
ified maximum length of one packet.
48 / 149
6 MCU firmware update via OTA
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xED
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: Success
• 0x01: Packet ID error.
• 0x02: The data length does not match the expected one.
• 0x03: CRC check failed.
• 0x04: Other error codes.
For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xEE
49 / 149
6 MCU firmware update via OTA
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xEE
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: Success
• 0x01: The total data length error.
• 0x02: The data length does not match the expected one.
• 0x03: Other error codes.
50 / 149
7 Production test
7 Production test
• Perform the received signal strength indicator (RSSI) test on modules to mea-
sure the RF performance.
• Test tool:
• Test steps:
1. Put the beacon around 0.5 meters away from the module.
2. The MCU sends the RF test command to the module to initiate a test.
3. The module will search for the designated identifier and return the RSSI. If
the RSSI is greater than -70 dB, the RF performance is acceptable.
:::important
Some chip models such as BK3431Q and BK3432 do not support scanning for
a designated beacon. You need to perform an RF test with a dongle.
– Test tool: A Bluetooth dongle. Purpose: Connect to the device under test
and return the RSSI.
– Test steps:
1. Put the dongle around 0.5 meters away from the module.
2. The MCU sends the RF test command to the module to initiate a test.
3. The dongle will connect to the module and return the RSSI. If the RSSI
is greater than -70 dB, the RF performance is acceptable.
The module must be unbound and operate in the standard power
mode.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x0E
51 / 149
7 Production test
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0x0E
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
52 / 149
7 Production test
Data Description
53 / 149
8 Low power protocol
– Standard power mode: The advertising interval is about 100 ms, which is
not configurable currently. The two-way serial communication works.
– Low power mode: The advertising interval is set by the MCU, defaulting to
1 second. If the interval is 0, advertising is turned off. For serial communi-
cation, the module only sends data to but does not receive data from the
MCU.
:::info
After BK3432 enters low power mode, it will proactively disconnect from
Bluetooth and turn off advertising.
:::
• The MCU can pull down or up the low power pin on the module to make the mod-
ule enter or exit the low power mode. Lowpower_moudle_enable indicates whether
you need to use the command 0xE5 to enable low power mode, as shown in the
following table.
Chip (product
category) Lowpower_moudle_enable
Moudle_wakeup_pin
Wakeup_level Idle_level
After the module wakes up, a 100 ms time delay before serial communication
54 / 149
8 Low power protocol
is recommended. After waking up from deep sleep, Telink based modules need
one second for startup.
• To send data to the MCU, the module will wake up the MCU with the wakeup_level
and then wait for a specified time before starting serial transmission. After data
is sent, the wake-up pin will go back to the Idle_level, as shown in the following
table.
Chip (product
category) Lowpower_moudle_enable
Wakeup_mcu_pinWakeup_level Idle_level
For more information about the wake-up time, see Configure MCU wake-up
(0xB0).
• Each time the module is connected to the cloud, it will sync the internal clock
with the app time. The accuracy of the module’s internal clock depends on the
crystal oscillator. If your product requires accurate time, make sure to measure
the accuracy of the internal clock. If you have any questions about measuring
clock accuracy, submit a service ticket. The internal clock is reset after the
power is turned off.
• You can turn off the system timer in low power mode to reduce power consump-
tion.
• When the supply voltage is below the operating voltage, operations on the
flash memory of the module might cause errors in firmware or user data. You
can try the following methods to avoid this issue:
– When the MCU detects a low battery level, it powers off the module or
turns off advertising and makes the module enter sleep mode.
55 / 149
8 Low power protocol
– When the module detects a low battery level, it enters sleep mode.
:::important
The wake-up pin configuration varies depending on chipset platforms. Do
not leave the wake-up pin on the MCU floating.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE5
4 2 Data length. 0x00
5 0x01
6 1 Data See the following
table.
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
56 / 149
8 Low power protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE5
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: Success
• Other values: Failure
• To further reduce the power consumption in sleep mode, you can use this com-
mand to turn off the system timer. If your MCU does not need timekeeping, you
can also turn off the system timer. The configuration is stored in the nonvolatile
memory.
• For BK3431Q and TYBN1 modules, writing time data to flash memory is high
power consumption and is turned off in sleep mode by default. The timekeep-
ing function is still available because it uses less power. After you turn on the
system timer, the time will be saved to the flash memory every one minute,
57 / 149
8 Low power protocol
which can fix the issue of clock reset after the module is restarted. The system
timer is turned off by default.
:::info
With both the timer and advertising turned off, the Telink-based module can
enter deep sleep with the power consumption reduced to 3 μA. After waking
up, the module will restart.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE4
4 2 Data length. 0x00
5 0x01
6 1 Data See the following
table.
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
58 / 149
8 Low power protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE4
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: Success
• Other values: Failure
• You can use this command to set the custom pin to wake up the module from
sleep. You can invoke this command after the UART initialization to configure
the custom pin.
• For more information about the support for protocols, see Firmware types.
:::important
Since the module stops receiving serial data in the low power mode, the MCU
must send this command within one second after the module is powered on,
or before enabling the low power feature.
:::
59 / 149
8 Low power protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE3
4 2 Data length. 0x00
5 0x06
6 to 11 6 Payload data CFG See the following
table.
12 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
PIN_NUM is a reserved field in big-endian format. It is not parsed so you can set it
to 0xff or 0x00. If you have any questions about PIN_NUM, submit a service ticket.
Example:
• Set the P03 on BK3432 as the wake-up pin. The PIN_NUM for P03 is 0x03.
55 AA 00 E3 00 06 00 00 00 03 00 00 EB
• Set the P11 on BK3432 as the wake-up pin. The PIN_NUM for P11 is 0x11.
55 AA 00 E3 00 06 00 00 00 11 00 00 F9
60 / 149
8 Low power protocol
:::info
The configurable pins on BK3432 are P02, P03, P04, P05, P10, P11, P12, P13,
P34, P14, P35, P32. and P31. The PIN_NUM for Pxx on BK3432 is 0xxx.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE3
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: Success
• Other values: Failure
• You can use this command to set the time (t) used for waking up the MCU from
sleep.
The module pulls up or down the wake-up pin for a specified time (t) before
sending data to the MCU.
• After modification, you must verify whether the specified time works. If not,
you need to set a larger value.
61 / 149
8 Low power protocol
• You can invoke this command after the MCU receives the command 0x02. The
configuration is stored in the volatile memory so it will reset to default when
the module is turned off or restarted.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xB0
4 2 Data length. 0x00
5 0x01
6 1 interval See the
information below.
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
interval indicates the unit of the wake-up time. The value ranges from 1 to 20,
which means 10 ms to 200 ms.
Example:
- 55 aa 00 E2 00 01 00 E2, indicating advertising is turned off in low power mode.
- 55 aa 00 E2 00 01 06 E8, indicating the advertising interval is 600 ms in low power
mode.
62 / 149
8 Low power protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xB0
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
• 0x00: Success
• Other values: Failure
63 / 149
9 Extended features
9 Extended features
This section describes how to implement the extended features such as dynamic
data reporting, bulk data storage, file download, and weather services. You can
implement these features as needed.
• You can use flags to indicate whether to report specific real-time data to the
cloud or the app panel.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA4
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
64 / 149
9 Extended features
(Optional) 13
2 bytes 1 byte 1 byte bytes m byte(s)
• Sequence number (SN): two bytes in length, in big-endian (high byte first) for-
mat.
• Flag:
– 0x00: Report data both to the cloud and the app panel.
– 0x01: Report data to the cloud but not to the app panel.
– 0x02: Report data to the app panel but not to the cloud.
– 0x03: Not report data.
• Time_flag:
– 0x00: Report data with the time data from the module.
– 0x01: Report data with the time data from the MCU.
– 0x02: Report data without including the time data.
• Time_date: 13-digit Unix timestamp. This field is required when Time_flag is set
to 0x01.
For example, dynamic data is only reported to the app panel and without the
time data.
55 AA 00 A4 00 0B 00 FF 02 02 65 00 00 03 13 23 66 B5
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA4
4 2 Data length. 0x00
5 0x04
65 / 149
9 Extended features
Data format
• Sequence number (SN): This value is from the reported data from the MCU.
• Flag: This value is from the reported data from the MCU.
• State: 0x00 indicates success. All other values indicate failure.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xB5
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 1 SubCmd See the
information below.
66 / 149
9 Extended features
SubCmd (Subcommand):
The format of the Data field varies depending on subcommands. The module
parses data according to the SubCmd and the Data format.
Time_Str:
67 / 149
9 Extended features
:::info
When CFG is changed, the module will clear the bulk data storage.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xB5
4 2 Data length. 0x00
5 0x01
6 1 SubCmd See the following
table.
7 to 7+Len-1 Len Data See the
information below.
68 / 149
9 Extended features
SubCmd (Subcommand):
The format of the Data field varies depending on subcommands. The module
parses data according to the SubCmd and the Data format.
STATE (1 byte):
– 0x00: Success
– 0x01: Length error
– 0x02: Type error
– 0x03: Invalid DP data format
– 0x04: Storage error
– Other values: Failure
1 2 3 to 4
– STATE:
∗ 0x00: Success
∗ Other values: Failure
– MAX_SIZE: The maximum length of a piece of data.
– TOTAL_NUM: The total number of pieces of data that can be stored.
69 / 149
9 Extended features
Example:
• The MCU can use this command to request the specified weather data in a
specific location from the mobile app.
• For more information, see the Appendix.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xB6
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the
information below.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data description:
70 / 149
9 Extended features
• Location:
• Weather parameter
• Number of forecast days: Specifies the number of days for which the server
returns forecast data. The valid value ranges from 1 to 7 (1 indicates today).
For more information, see the Appendix.
71 / 149
9 Extended features
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xB6
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the
information below.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
• Status:
0x00: Success
• Weather_values: The value of weather, which is valid when status is 0x00. For
more information about the data format, see the following table.
72 / 149
9 Extended features
Weather parameter
Day (little-endian) Data type Data length Data ⋯
Data type:
• 0x00: Integer
• 0x01: String
Example:
55 AA 00 B6 00 06 01 00 00 00 0F 01 CC
55 AA 00 B6 00 2D 00 01 01 00 00 00 00 04 00 00 00 21 01 02 00 00 00 00 04 00 00 00 24
01 04 00 00 00 00 04 00 00 00 1C 01 08 00 00 00 00 04 00 00 00 44 AA
– If the device is not bound, it will not start Bluetooth advertising automati-
cally when powered on.
– If the device has been bound, it will not start Bluetooth advertising auto-
matically after unbinding.
73 / 149
9 Extended features
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBC
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the
description below.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data description:
• ENABLE:
– 0x00: Disable the triggered pairing mode, using the default pairing mode.
When you set this field to 0x00, the module does not parse the subsequent
fields.
– 0x01: Enable the triggered pairing mode.
• ON_OFF:
– 0x00: Exit pairing mode immediately. When you set this field to 0x00, the
module does not parse the subsequent fields.
– 0x01: Enter pairing mode immediately.
• TIME: Timeout for triggering pairing mode, in seconds, ranging from 10 to 600.
74 / 149
9 Extended features
75 / 149
9 Extended features
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBC
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Status See the
description below.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Status:
• 0x00: Success
• 0x01: Parameter error
• 0x02: Request failed
• 0x03: Status error (The device is not in the unbound state.)
This feature allows the user to control a device using a physical Bluetooth remote
control. It is disabled by default.
76 / 149
9 Extended features
• With the Bluetooth remote control enabled, the module will not enter the low
power mode. You need to call the command to disable Bluetooth remote control
before the module enters the low power mode and enable the feature after the
module exits the low power mode.
• The configuration is stored in the nonvolatile memory.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC1
4 2 Data length 0x00
5 0x02
6 1 Subcommand 0x00
78 2 Data
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC1
77 / 149
9 Extended features
• This feature applies when you enable the Bluetooth remote control.
• For more information about the control commands, see Appendix 3.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC1
4 2 Data length 0x00
5 0x06
6 1 Subcommand 0x01
Data
78 / 149
9 Extended features
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC1
4 2 Data length 0x00
5 0x01
6 1 Subcommand 0x01
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
This feature applies when you enable the Bluetooth remote control.
79 / 149
9 Extended features
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC1
4 2 Data length 0x00
5 0x03
6 1 Subcommand 0x02
7 2 Data
8
9 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
80 / 149
10 Combo module protocol
The following table lists the frame format for Bluetooth and network module combo
protocol.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC0
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 1 SubCmd The subcommand.
Len-1 Data The subcommand
data.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
The MCU can use this command to access the network module (such as the LTE Cat.1
module) as instructed in LTE Cat.1 Serial Port Protocol to get information, such as
positioning information.
Frame format:
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
81 / 149
10 Combo module protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC0
82 / 149
10 Combo module protocol
Data format:
1 byte 1 byte
op_type op_object
• op_type:
– 0x01: Notify. When the MCU bypasses the Bluetooth module and directly
controls the power on/off of the extended module, it notifies the Bluetooth
module to update the power status.
– 0x02: Control. The MCU controls the power on/off of the extended module
through the specific pin on the Bluetooth module.
– 0x03: Read. The MCU reads the power status of the extended module.
• op_object:
– bit0: The pin to control the power of the extended module 1 (cellular mod-
ule). 0 indicates power off and 1 indicates power on.
– bit1: The pin to control the power of the extended module 2 (GPS module).
0 indicates power off and 1 indicates power on.
– All other bits are reserved.
83 / 149
10 Combo module protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC0
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 1 SubCmd 0x01
Len-1 DATA See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format:
Status:
• 0x00: Success
• Other values: Failure
• When the cellular module is inserted or removed, the Bluetooth module noti-
fies the MCU of this event. Alternatively, the MCU can proactively request the
presence of the extended module.
84 / 149
10 Combo module protocol
• When the cellular module is removed, the MCU should power off the extended
module before entering low power mode to reduce power consumption.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC0
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 1 SubCmd 0x02
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC0
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 1 SubCmd 0x02
7 1 Status
85 / 149
10 Combo module protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC0
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 1 SubCmd 0x03
Configurations {“apn”:“xxx”}
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
86 / 149
10 Combo module protocol
Example:
55 AA 00 C0 00 10 03 7B 22 61 70 6E 22 3A 22 63 6E 69 6F 74 22 7D EB ({“apn”,“cniot”
}})
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC0
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 1 SubCmd 0x03
7 1 Status
8 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
87 / 149
11 Extended MCU protocol for accessories
This protocol extends the capabilities of the MCU to the non-smart accessories.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC2
4 2 Data length (Len) 0x00
5 0x02
6 to 6+Len-1 1 SubCmd 0x00
1 Status
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
88 / 149
11 Extended MCU protocol for accessories
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xC2
4 2 Data length (Len) 0x00
5 0x02
6 1 SubCmd 0x00
7 1 Status
8 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
89 / 149
12 Bluetooth-specific protocol
12 Bluetooth-specific protocol
The MCU sends this command to the module to disconnect the Bluetooth connection
and enter the advertising state.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE7
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE7
4 2 Data length. 0x00
5 0x01
6 1 State Return value
90 / 149
12 Bluetooth-specific protocol
Return value
• 0x00: Success
• Other values: Failure
• In standard power mode, the advertising interval is 100 ms. In low power
mode, the advertising interval can range from 0 to 2,000 ms and defaults to
1,000 ms. 0 means turning off advertising. The module will be paired when
the app receives the advertisement. This command allows the MCU to enable
or disable advertising so that the MCU can determine when to perform pairing.
• You need to invoke this command to set the advertising enablement after the
UART initialization. The enablement state is stored in the flash memory. The
MCU should enable advertising when performing pairing and disable it in other
cases.
• For more information about the support for protocols, see Firmware types.
:::info
This command works for both the standard and the low power mode. Modifica-
tion of advertising interval only works for the low power mode. Therefore, to
91 / 149
12 Bluetooth-specific protocol
modify the time for performing pairing, you must use the advertising enable-
ment command.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA3
4 2 Data length. 0x00
5 0x01
6 1 Data See the following
table.
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA3
4 2 Data length. 0x00
5 0x01
92 / 149
12 Bluetooth-specific protocol
Return value
• 0x00: Success
• Other values: Failure
1. The module will advertise for 30 seconds after the MCU invokes this com-
mand.
2. After receiving the flagged advertisement, the Bluetooth central device
will connect to the module.
3. After the module is online, the MCU can report the status to the module.
• Typically, the MCU uses the command 0xE0 to report record-type data. If the
module is bound but not connected, the MCU will use this command to request
to get the module online. Then, after getting online, the module will release
the stranded data reported through 0xE0.
• To report the real-time data, try the following two methods:
– The MCU invokes this command and waits for an online notification. The
module will notify the MCU of its status after getting online.
– The MCU can report real-time data in 0x02 format through the command
0xE0. After getting online, the module will send the stranded data to the
app. This method is not recommended.
• For more information about the support for protocols, see Firmware types.
93 / 149
12 Bluetooth-specific protocol
94 / 149
12 Bluetooth-specific protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA5
4 2 Data length. 0x00
5 0x00
6 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA5
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
95 / 149
12 Bluetooth-specific protocol
• 0x00: Success
• Other values: Failure
• This command does not apply to the BK3432 generic firmware for shared de-
vices.
• To further reduce the power consumption in sleep mode, you can use this com-
mand to modify the advertising interval. The configuration is stored in the
nonvolatile memory. If the interval is set to 0, advertising is turned off. The
configuration is stored in the nonvolatile memory.
:::info
The advertisement interval defaults to one second in the low power mode. A
long interval means taking more time to connect to a mobile phone. If the
phone has poor radio performance, the Bluetooth connection attempt might
fail.
:::
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE2
4 2 Data length. 0x00
5 0x01
6 1 Adv_interval See the following
table.
96 / 149
12 Bluetooth-specific protocol
Adv_interval: The valid values range from 0 to 20 in units of 100 ms. If the interval
is set to 0, advertising is turned off.
Example:
- 55 aa 00 E2 00 01 00 E2, indicating advertising is turned off in low power mode.
- 55 aa 00 E2 00 01 06 E8, indicating the advertising interval is 600 ms in low power
mode.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE2
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
97 / 149
12 Bluetooth-specific protocol
• 0x00: Success
• Other values: Failure
• If the module is in the bound and connected state when receiving this com-
mand, it will send a request for updating the connection parameters to the
central. Otherwise, it only saves the connection parameters for later connec-
tions. However, if the module is performing an OTA update, it will not request
to update the connection parameters to the central but save it.
• After getting online, the module will release the stranded data if any, and then
update the connection parameters.
• The configuration is stored in the nonvolatile memory.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xB1
4 2 Data length. 0x00
5 0x0B
6 to 16 11 CFG See the
information below.
17 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
CFG format:
98 / 149
12 Bluetooth-specific protocol
• mode:
– 0x00: Fast-speed mode. Provide fast interaction but use more battery.
This mode applies to products that prioritize fast response by compromis-
ing the power consumption.
– 0x01: Balanced mode. Provide moderate response time and power con-
sumption.
– 0x02: Low-speed mode. Provide slow response time but use less battery.
This mode applies to products that prioritize power consumption with less
interaction with the app, such as sensors.
• min_interval: The minimal connection interval, in the unit of 1.25 ms. For more
information, see the connection interval specified in the Generic Access Profile
(GAP).
• max_interval: The maximum connection interval, in the unit of 1.25 ms. For
more information, see the connection interval specified in the Generic Access
Profile (GAP).
• latency: Peripheral latency. This parameter gives the peripheral device the
option of skipping a number of connection events. For more information, see
the connection interval specified in the Generic Access Profile (GAP).
99 / 149
12 Bluetooth-specific protocol
:::info
The field greater than two bytes is transmitted in big-endian format. You can
set cfg_type and cfg_ack to 0x00 if these two parameters are not required for you.
:::
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xB1
4 2 Data length. 0x00
5 0x09
6 to 14 1 State Return value
15 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
State
result:
• 0x00: The module receives the new connection parameters and will request
a parameter update with the central. min_interval, max_interval, latency, and
100 / 149
12 Bluetooth-specific protocol
• 0x03: Illegal state. Generally, the module is not in the bound and connected
state.
:::info
If cfg_ack is set to 0x01, the module syncs the current connection parameters to
the MCU only after receiving the success ACK message. The result 0x01 or 0x02
can be returned only when cfg_ack is set to 0x01. Otherwise, the module will not
return the operation result to the MCU.
:::
Example:
101 / 149
12 Bluetooth-specific protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBA
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 1 SubCmd See the
information below.
7 to 7+Len-1 Len Data See the
information below.
7+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
SubCmd (Subcommand):
:::info
Dynamic configuration of SMP is not supported so the MCU should report the
SMP enablement when responding to the MCU information query 0x01. The
102 / 149
12 Bluetooth-specific protocol
SMP is disabled by default. After you enable or disable the SMP, the module
will restart and clear the pairing information for initialization. The configuration
can be retained after power off.
:::
Data
1 2 3
op num interval
– op: Operation. 0x00: Stop getting the RSSI value. 0x01: Start getting the
RSSI value.
∗ Example: Start getting 10 RSSI values of the HID pairing signal with
an interval of 200 ms.
∗ The MCU sends 55 AA 00 BA 00 04 02 01 0A 02 CC.
103 / 149
12 Bluetooth-specific protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBA
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 1 SubCmd See the following
table.
7 to 7+Len-1 Len Data See the
information below.
7+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
SubCmd (Subcommand):
:::info
The format of the Data field varies depending on subcommands. The MCU
parses data according to the SubCmd and the Data format.
:::
• When SubCmd is 0x00, the Data field is populated with a 1-byte status code.
Status:
104 / 149
12 Bluetooth-specific protocol
• When SubCmd is 0x01, the Data field is populated with a 1-byte status code.
Status:
1 2
Status rssi_raw
Status:
– 0x00: Success
– 0x02: Parameter error
– 0x03: Not in the HID pairing state.
– 0x04: HID pairing rejected.
• When SubCmd is 0x03, the Data field is populated with a 1-byte status code.
Status:
The MCU can set the advertising name when the module is not bound. Otherwise,
the module will reject the request.
105 / 149
12 Bluetooth-specific protocol
106 / 149
12 Bluetooth-specific protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBB
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the
information below.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
1 2–2+ADV_LOCAL_NAME_LEN-1
ADV_LOCAL_NAME_LEN ADV_LOCAL_NAME
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBB
107 / 149
12 Bluetooth-specific protocol
Return value
• 0x00: Success
• 0x01: Exceed the length limit.
• 0x02: Rejected.
• If the default transmitter power cannot meet your needs, you can use this
command to adjust it.
• Consult Tuya’s technical support to determine an appropriate transmitter
power.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBD
4 2 Data length 0x00
5 0x02
108 / 149
12 Bluetooth-specific protocol
6 1 OP See the
description below.
7 1 TX_POWER See the
description below.
8 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
OP:
• 0x00: Get.
• 0x01: Set.
TX_POWER:
• When OP is 0x01, set the transmitter power register. Consult Tuya’s technical
support to determine an appropriate value.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBD
4 2 Data length 0x00
5 0x02
6 1 OP See the
description below.
109 / 149
12 Bluetooth-specific protocol
OP:
• 0x00: Get.
• 0x01: Set.
Value:
The MCU can use this command to query the MAC address of the Bluetooth mod-
ule.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBE
4 2 Data length 0x00
5 0x00
110 / 149
12 Bluetooth-specific protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xBE
4 2 Data length 0x00
5 0x06
6 to 11 6 MAC See the following
table.
12 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
111 / 149
13 Smart lock specific protocol
This section describes the extended protocol specific to smart look generic firmware,
which does not apply to generic firmware for other categories.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE6
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
112 / 149
13 Smart lock specific protocol
The request parameter of the admin password is not supported. Set its length to
0.
Example: The MCU sends a packet that does not contain the admin password.
55 aa 00 E6 00 09 30 31 32 33 34 35 36 37 00 8a
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xE6
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Return value
113 / 149
13 Smart lock specific protocol
Example:
• The data of GMT is used to compute the current dynamic password. Therefore,
GMT must be provided to the module.
• This command works for the same purpose as the 0xE6 but has different param-
eters.
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA7
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
114 / 149
13 Smart lock specific protocol
N
1 byte 1 byte 1 byte 1 byte 1 byte 1 byte 1 byte 1 byte byte(s)
TimeSource
2000+Year
Mon Day Hour Min Sec Code_lenCode
– 0x00: Use the time data Year, Mon, Day, Hour, Min, and Sec uploaded by
the MCU.
– 0x01: Use the internal time of the module. The Year, Mon, Day, Hour, Min,
and Sec uploaded by the MCU are not parsed.
The MCU uploads the date and time in GMT. For example, [Link] on June
20, 2020 is represented by 0x14 0x06 0x14 0x04 0x00 0x00 in GMT.
Example:
55 AA 00 A7 00 10 00 14 0A 09 0D 33 2C 08 01 08 05 08 06 04 04 05 7A
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA7
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len State Return value
115 / 149
13 Smart lock specific protocol
Return value
Example:
- 55 AA 00 A7 00 01 01 A8, indicating password verification failed.
- 55 AA 00 A7 00 01 00 A7, indicating password verified.
• Offline dynamic passwords can be used to unlock the door if a device is discon-
nected for long periods of time.
• The time drift of the internal clock of the module is less than one minute in 24
hours. The internal clock is reset after power off. The module syncs its clock
with the server time each time it is connected to the cloud.
:::important
If your MCU is connected to an external clock, we recommend you choose 0x00
for the clock source to use the time data from the MCU. If you use the internal
clock of the module as the clock source, make sure to measure the accuracy.
:::
• For more information about the support for protocols, see Firmware types.
116 / 149
13 Smart lock specific protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA2
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
N
1 byte 1 byte 1 byte 1 byte 1 byte 1 byte 1 byte 1 byte byte(s)
TimeSource
2000+Year
Mon Day Hour Min Sec Code_lenCode
– 0x00: Use the time data Year, Mon, Day, Hour, Min, and Sec uploaded by
the MCU.
– 0x01: Use the internal time of the module. The Year, Mon, Day, Hour, Min,
and Sec uploaded by the MCU are not parsed.
The MCU uploads the date and time in GMT. For example, [Link] on June
20, 2020 is represented by 0x14 0x06 0x14 0x04 0x00 0x00 in GMT.
117 / 149
13 Smart lock specific protocol
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA2
4 2 Data length (Len) Upper 8 bits
5 Lower 8 bits
6 to 6+Len-1 Len Data See the following
table.
6+Len 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
Data format
• Result:
– 0x00: Correct
– Other values: Error. The return data is insignificant.
• Type:
118 / 149
13 Smart lock specific protocol
:::info
Type and code are used to report DP status. The DPs related to the offline pass-
word feature are DP ID 65, 66, and 67.
:::
For example, use the internal clock of the module and the password is 2279084005.
• MCU: 55 AA 00 A2 00 12 01 00 00 00 00 00 00 0A 02 02 07 09 00 08 04 00 00 05 E3
• Module: 55 AA 00 A2 00 13 00 00 10 F3 50 3C 8F FF 03 F5 E9 0D 54 99 2A 62 A1 DE
42 F9
• Apply to:
• Some features that require specific fields of the DP are turned off by default.
You can turn on them as needed. The configuration is stored in the nonvolatile
memory.
• You can use this command to configure:
• For more information about the support for protocols, see Firmware types.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA6
4 2 Data length. 0x00
5 0x04
6 to 9 4 DATA See the following
table.
119 / 149
13 Smart lock specific protocol
CFG format:
1 2 3 4
FLAG PWD_NUM PWD_BEGIN_NUM Reserved (0x00)
• FLAG:
– bit0: Enable the lock accessory. 0 is for disabling and 1 is for enabling. This
feature is disabled by default.
:::info
bit0 and bit1 are mutually exclusive. When you enable either of them, the
other is disabled automatically.
:::
– bit2: Reserved
– bit3: Reserved
– bit4: Reserved
– bit5: Reserved
– bit6: Reserved
– bit7: Reserved
120 / 149
13 Smart lock specific protocol
:::important
The valid values of PWD_NUM rang from 0x04 to 0x09. Invalid values will apply the
default setting of 10 digits.
:::
• PWD_BEGIN_NUM: the starting digit, which can be 0 or 1. If the keypad starts from
0, set it to 0x00. If the keypad starts from 1, set it to 0x01.
:::important
The valid values of PWD_BEGIN_NUM are 0x00 and 0x01. Invalid values will apply the
default 0x00.
:::
Example:
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA6
4 2 Data length. 0x00
5 0x01
6 1 State Return value
7 1 CRC8 Start from the
header, add up all
the bytes, and
then divide the
sum by 256 to get
the remainder.
121 / 149
13 Smart lock specific protocol
Return value
• 0x00: Success
• Other values: Failure
This interface is used to configure the DP-specific features. It applies to three fea-
tures:
- The lock accessory.
- Accessory-triggered locking and unlocking. These two features work for the Blue-
tooth lock accessory, one for the lock and the other for the accessory.
- Positional notation.
If the lock accessory features are not required for your product, you do not need to
configure them. They are disabled by default. To set these features, the MCU should
send the configuration to the module after the UART initialization. The configuration
is stored in the nonvolatile memory.
:::important
The valid values of PWD_NUM rang from 0x04 to 0x09. Invalid values will apply the
default setting of 10 digits.
:::
• PWD_BEGIN_NUM: the starting digit, which can be 0 or 1. If the keypad starts from
0, set it to 0x00. If the keypad starts from 1, set it to 0x01.
:::important
The valid values of PWD_BEGIN_NUM are 0x00 and 0x01. Invalid values will apply
the default 0x00.
:::
Example
• If the keypad has digits 1, 2, 3, 4, 5, and 6, set the PWD_NUM to 6 and PWD_BEGIN_NUM
to 1.
122 / 149
13 Smart lock specific protocol
Four DPs and one command 0xA6 together implement the lock accessory feature.
You do not need to take care of the Bluetooth pairing and reconnection, which has
been implemented in the generic firmware.
Double identity verification in the service layer is implemented to ensure the secu-
rity of the lock.
• The cloud assigns the central (app or accessory) a unique code that consists of
the central ID and a central random number to identify the central device. The
cloud assigns the peripheral (lock) a unique code that includes the peripheral
ID and a peripheral random number to identify the peripheral device.
• After the cloud sends the unique code of the app and the peripheral ID of the
lock to the lock, the lock is considered to be paired with the app. After the
cloud sends the unique code of the accessory to the lock and sends the unique
code of the accessory and the peripheral ID of the lock to the peripheral, the
lock is considered to be paired with the accessory.
• The lock stores: The unique code of the app The unique code of the accessory
The peripheral ID of the lock
• The accessory stores: The unique code of the peripheral The peripheral ID of
the lock
So far, the accessory can unlock the door. Before unlocking, it tells the lock the
unique code of itself and the peripheral ID of the lock for verification.
The implementation of the above feature is included in the generic firmware. This
feature is disabled by default because it requires the data of specific DP and the
generic firmware does not process DP data but transmits the raw data. To use this
feature, the MCU should use the command 0xA6 to enable it. The module just gets
and parses the central ID, peripheral ID, and random numbers without modifying
them.
If you do not enable this feature, the module will transmit the obtained raw DP data
to the MCU. This way, the MCU should process the data.
123 / 149
13 Smart lock specific protocol
The MCU enables the lock accessory feature through the command 0xA6. Then, the
module processes the DP ID 70 (configure random number) without transmitting the
raw DP data to the MCU.
For the DP ID 71 (unlock/lock) and 73 (set remote unlock), the module collects the
central ID, peripheral ID, and random number from the DP data for identity verifica-
tion.
• If the identity is verified, the module will send the raw DP data to the MCU for
processing the unlock/lock operation and remote unlock.
• If the identity is not verified, the module will return a failure without sending
the raw DP data to the MCU.
After the MCU enables the lock accessory feature, the module only verifies the ac-
cessory identity and determines whether to send the raw DP data to the MCU for
processing. The MCU does not need to process the fields of central ID, peripheral
ID, and random number but only adjusts the position of these fields. Take the DP ID
71 as an example:
Feature
Data
transmission
dp_id
(1 byte)
dp_type
(1 byte)
dp_da
ta_len
(1
byte)
dp_data_value
Locking
Unlocking
Cloud-to-device
71
124 / 149
13 Smart lock specific protocol
raw
len
Central ID
(2 bytes)
Peripheral ID
(2 bytes)
Random number
(8 bytes)
Operation
(1 byte)
Locking/unlocking
Timestamp
(4 bytes)
Locking/unlocking
Method
(1 byte)
Locking/unlocking
Info
(len-12 bytes)
0 to 10000
0 to 10000
0x00: Lock.
0x01: Unlock
Description
Description
Description
Device-to-cloud
71
raw
len
125 / 149
13 Smart lock specific protocol
Peripheral ID
(2 bytes)
Central ID
(2 bytes)
Random number
(8 bytes)
Operation
(1 byte)
Locking/unlocking
Timestamp
(4 bytes)
Locking/unlocking
Method
(1 byte)
Return value
(1 byte)
0 to 10000
0 to 10000
0x00: Lock.
0x01: Unlock
Description
Description
Value range
126 / 149
13 Smart lock specific protocol
After the MCU receives data of DP ID 71, it stores the central ID, peripheral ID, and
random number that will be used when the MCU reports the locking or unlocking
record.
Feature
Data
transmission
dp_id
(1 byte)
dp_type
(1 byte)
dp_da
ta_len
(1
byte)
dp_data_value
Locking
Unlocking
Record
Device-to-cloud
72
raw
len
Peripheral ID
(2 bytes)
Central ID
(2 bytes)
Random number
(8 bytes)
Operation
(1 byte)
127 / 149
13 Smart lock specific protocol
Locking/unlocking
Timestamp
(4 bytes)
Locking/unlocking
Method
(1 byte)
Locking/unlocking
Info
(len-12 bytes)
0 to 10000
0 to 10000
0x00: Lock.
0x01: Unlock
Description
Description
Description
The MCU enables the lock accessory feature through the command 0xA6.
After the module receives the unlock/lock command from the MCU, it will retrieve
the accessory information according to the central ID. If the accessory has been
added, it can unlock or lock the door. Then, the module will initiate a reconnection
request and forward the DP for unlock/lock to the lock for command execution.
Feature
Data
transmission
dp_id
(1 byte)
dp_type
(1 byte)
dp_da
ta_len
128 / 149
13 Smart lock specific protocol
(1
byte)
dp_data_value
Locking
Unlocking
Cloud-to-device
71
raw
len
Central ID
(2 bytes)
Peripheral ID
(2 bytes)
Random number
(8 bytes)
Operation
(1 byte)
Locking/unlocking
Timestamp
(4 bytes)
Locking/unlocking
Method
(1 byte)
Locking/unlocking
Info
(len-12 bytes)
0 to 10000
0 to 10000
0x00: Lock.
0x01: Unlock
129 / 149
13 Smart lock specific protocol
Description
Description
Description
Device-to-cloud
71
raw
len
Peripheral ID
(2 bytes)
Central ID
(2 bytes)
Random number
(8 bytes)
Operation
(1 byte)
Locking/unlocking
Timestamp
(4 bytes)
Locking/unlocking
Method
(1 byte)
Return value
(1 byte)
0 to 10000
0 to 10000
0x00: Lock.
0x01: Unlock
Description
Description
Value range
130 / 149
13 Smart lock specific protocol
When the accessory’s MCU reports DP data, it only needs to populate the periph-
eral ID. If the accessory’s module has stored the information, it can populate the
corresponding central ID and random number automatically.
The lock ID will be sent to the MCU when an unlocking method is added. For
more information, see the DP protocol specification.
• For data of other DPs, the module will not process it and directly send the raw
data to the MCU.
After connecting to the accessory, the lock’s module will forward the unlock-
/lock request to the MCU and start a 30s timer. If the MCU fails to return the
operation result after a timeout, the module will disconnect from the Bluetooth
accessory. If the MCU returns a result, the module also disconnects from the
Bluetooth accessory.
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
131 / 149
13 Smart lock specific protocol
CFG format:
1 2 3 to 4 4 to 5
operation config_type ibeacon_interval timeout
• operation:
• config_type:
• ibeacon_interval: The iBeacon advertising interval in low power mode in the unit
of 100 ms, ranging from 100 ms to 2,000 ms. The actual advertising interval
is ibeacon_interval × 100 ms. It is fixed to 100 ms in standard power mode.
132 / 149
13 Smart lock specific protocol
• timeout: iBeacon timeout in the unit of 5s. That is, iBeacon times out in 5 ×
timeout seconds. The valid values range from 5s to 2 min. This timeout only
works for the anti-lost feature.
Example:
• Anti-lost iBeacon: 55 AA 00 A8 00 06 01 00 00 00 00 00 AE
• Auto-unlocking iBeacon: 55 AA 00 A8 00 06 03 00 00 00 00 00 B0
0 2 Header 0x55
1 0xAA
2 1 Version number 0x00
3 1 Command (CMD) 0xA8
4 2 Data length. 0x00
5 0x01
6 1 State Return value
133 / 149
13 Smart lock specific protocol
Return value
• 0x00: Success
• Other values: Failure
134 / 149
14 Appendix 1: Weather parameters
[Link] (1 « 0) Temperature
Integer SupportedSupportedSupportedNot sup-
ported
[Link] (1 « 1) The Integer - - Not sup- Supported
highest ported
temper-
ature
[Link] (1 « 2) The Integer - - Not sup- Supported
lowest ported
temper-
ature
[Link](1 « 3) Humidity Integer SupportedSupportedSupported7-day
forecast
135 / 149
14 Appendix 1: Weather parameters
136 / 149
14 Appendix 1: Weather parameters
137 / 149
14 Appendix 1: Weather parameters
[Link]
(1 « 12) Wind String SupportedSupportedSupported7-day
speed (format forecast
exam-
ple:
0.9)
[Link] (1 « 13) Wind di- String SupportedNot sup- SupportedNot sup-
rection ported ported
[Link]
(1 « 14) Wind Integer SupportedNot sup- SupportedNot sup-
level ported ported
[Link] (1 « 15) Air Integer SupportedNot sup- SupportedNot sup-
quality ported ported
index
[Link] (1 « 16) Weather String - - SupportedNot sup-
tips ported
[Link]/[Link]
(1 « 17) AQI String SupportedNot sup- SupportedNot sup-
details (format ported ported
and exam-
national ple:
ranking 447/609)
w.pm10 (1 « 18) PM10 Integer SupportedNot sup- SupportedNot sup-
index ported ported
w.pm25 (1 « 19) PM2.5 Integer SupportedNot sup- SupportedNot sup-
index ported ported
w.o3 (1 « 20) Ozone Integer SupportedNot sup- SupportedNot sup-
index ported ported
w.no2 (1 « 21) Nitrogen Integer SupportedNot sup- SupportedNot sup-
dioxide ported ported
index
138 / 149
14 Appendix 1: Weather parameters
139 / 149
15 Appendix 2: Weather data in UTF-8 encoding
Chinese characters in
conditionNum Condition UTF-8 (Hexadecimal)
140 / 149
15 Appendix 2: Weather data in UTF-8 encoding
Chinese characters in
conditionNum Condition UTF-8 (Hexadecimal)
141 / 149
16 Appendix 3: Bluetooth remote control commands
Command
(1 byte)
Generic command
(1 byte)
1 <tr >
2 <th > Category ID </th >
Generic: 0xFF
Individual category
Fan: 0x05
Disinfector: 0x0A
142 / 149
16 Appendix 3: Bluetooth remote control commands
Switch: 0x0E
Byte 1: Button behavior (0 –Single press. 1 –Double press. 2 –Long press. 3 –Press
and hold. 4 –Press and release)
Byte 2: The key value.
Switch: 0x04
143 / 149
16 Appendix 3: Bluetooth remote control commands
144 / 149
16 Appendix 3: Bluetooth remote control commands
145 / 149
16 Appendix 3: Bluetooth remote control commands
Custom command
Parameter (3 bytes)
Lights: 0xFF
Byte 1: 0 –Change color to red. 1 –Change color to green. 2 –Change color to blue.
3 –Change color to yellow.
Fan: 0xFE
146 / 149
16 Appendix 3: Bluetooth remote control commands
Sleep: 0x01
147 / 149
17 Protocol version
17 Protocol version
148 / 149
17 Protocol version
149 / 149