# YAT Protocol and Command

#1. Protocol

The serial protocol is divided into SLIP layer and IMC layer from bottom to top. The SLIP layer is responsible for the encapsulation and unpacking of raw data. The IMC layer is responsible for business logic processing.

#1.1. SLIP(Serial Line Internet Packet)Layer

...

START

PAYLOAD

END

...

START

PAYLOAD

END

...

1 Byte

2...1026 Byte

1 Byte

1 Byte

2...1026 Byte

1 Byte

START

Starting Symbol:marking the beginning of the data packet, defining hexadecimal: 0xC0

PAYLOAD

PayLoad Date,among

  • 0xC0 needs to be replaced with 0xDB 0xDC
  • 0xDB needs to be replaced with 0xDB 0xDD
  • 0xD0 needs to be replaced with 0xDB 0xDE

END

Ending Symbol:marking the end of the data packet, defining hexadecimal: 0xD

#1.2. IMC(inter MCU Communication)Lay

TYPE

PAYLOAD

CRC8

1 Byte

0...1024 Byte

1 Byte

Command Type

Paylode Data

CRC verification value of PAYLOAD

The CRC8 verification algorithm is attached.

The data transmission adopts a small end mode, such as timeout_ s=0x3C00 represents 60s.

#2. Serial Configuration

#2.1. Default Value

  • Band rate: 115200bps
  • Data bites: 8
  • Parity: None
  • Stop bites: 1

#2.2. Modification Method

The baud rate and pins of the serial port can be modified.

Method 1:

During the debugging phase, you can enter the cli command on the debug serial port,:

uart [bandrate] ,uart <rx_pin>|<tx_pin>&lt;pin num&gt;

  • Viewing Baud Rate:uart
  • Set the baud rate to 9600: uart 9600
  • Set the rx pin of uart: uart rx_pin 12
  • Set the tx pin of uart: uart rx_pin 11

Method 2:

When using BAT for mass production during the production phase, burning is done through configuration files. Select UCPP (one type, one secret) for the id type.

json file:📎uart_profile.json

{
    "yat.uart.baudrate": "9600",
  	"yat.uart.rx.pin": "12",
  	"yat.uart.tx.pin": "11"
}

#3. Command

#3.1. Basic Command

#3.1.1. 0x01 Test Command

The MCU terminal can verify whether the serial communication is normal through this Command.

MCU->WiFi

TYPE

PAYLOAD

Description

0x01

n Byte

echo.  value range of n: 1~1024

Wifi->MCU

TYPE

PAYLOAD

Description

0x01

n Byte

echo.  value range of n: 1~1024

#3.1.2. 0x02 Restart Command

MCU->WiFi

TYPE

PAYLOAD

Description

0x02

0x00

Reserved

WiFi->MCU

TYPE

PAYLOAD

Description

0x02

0x00

Successfully set

0x01

Setting error

Description:After replying to ACK with the restart command, restart the system after a delay of 500ms. The module restart time should be at least 1 second.

#3.1.3. 0x03 Restore Factory Settings

Restoring factory settings can only restore parameters set through commands.

MCU->WiFi

TYPE

PAYLOAD

Description

0x03

0x01

Clear distribution network parameters and restart devices (ssid pwd, etc.)

0x02

Clear distribution network parameters, clear distribution network type, distribution network timeout, and restart the device

WiFi->MCU

TYPE

PAYLOAD

Description

0x03

0x00

Successfully set

0x01

Setting error

#3.1.4. 0x04 Set cloud platform product configuration parameters

The platform product parameters can be set without instructions, and can be the default configuration of WiFi module firmware at the factory. If it defaults, please contact mxchip.

MCU->WiFi

TYPE

PAYLOAD

Description

Cloud code

CONFIG

0x04

1 Byte

n Byte

Cloud code: Cloud platform identification code

CONFIG: Cloud platform configuration, format see attachment

WiFi->MCU

TYPE

PAYLOAD

Description

0x04

0x00

Successfully set

0x01

Setting error

#3.1.5. 0x05 Query cloud platform product configuration parameters

Only platform product configuration parameters configured through instructions can be queried.

MCU->WiFi

TYPE

PAYLOAD

Description

0x05

 1 Byte

PAYLOAD is the cloud platform identification code

WiFi->MCU

TYPE

PAYLOAD

Description

Cloud Code

CONFIG

0x05

 1 Byte

n Byte

Cloud Code: Cloud platform identification code

CONFIG: Cloud platform configuration, format see attachment

#3.1.6. 0x06 Set Product Attribute Configuration Table

The attribute configuration table can be set through command or factory default settings in the firmware.

If the cloud platform supports transparent transmission, it is strongly recommended to use transparent transmission, as attribute configuration tables are not required in the module.

The attribute configuration table is generated by mxchip. If the configuration file is greater than 512 bytes, it needs to be sharded for transmission.

MCU->WiFi

TYPE

PAYLOAD

Description

File length

Start Addr

End Addr

0x06

2 Byte

2 Byte

2 Byte

File length : length of attibute configuration table

Start Addr : File Start Address

End Addr : File End Address

WiFi->MCU

TYPE

PAYLOAD

Description

0x06

0x00

Successfully set

0x01

Setting error

For example:

The length of the configuration file is 606 bytes, and the file is larger than 512 bytes, which requires subcontracting transmission. The first packet sends 512 bytes of data, and the second packet sends 94 bytes of data.

1. MCU>WiFi: 06 5E 02 00 00 00 02<Omit 512 Bytes>CRC8

2. WiFi ->MCU: 06 00 00

3. MCU>WiFi: 06 5E 02 00 02 5E 02<Omit 512 Bytes>CRC8

4. WiFi ->MCU: 06 00 00

Note:

  • The configuration file can be burned by MXCHIP or by the customer themselves.
  • When the configuration file is less than 4K, the configuration file and firmware are burned separately, and the configuration file is burned in KV.
  • When the configuration file is greater than 4k, it is burned together with the firmware, and the configuration file and firmware are combined to form a new firmware, which belongs to customized firmware.

#3.1.7. 0x07 Query module software version

MCU->WiFi

TYPE

PAYLOAD

Description

0x07

0x00

Reserved

WiFi->MCU

TYPE

PAYLOAD

Description

0x07

n Byte

Obtain the module software version number, which is string type.

#3.1.8. 0x0A LOTA Configure MCU information

This command is mainly used during the production phase, where product information is transmitted to the MCU through wireless tools through modules (such as product serial numbers and other information).

Instruction timeout time is 1 second.

WiFi->MCU

TYPE

PAYLOAD

Description

Method

Data

0x0A

0x01

1-512 byte

Write configuration

0x02

Read configuration

  • When Method is 0x01,

MCU->WiFi

TYPE

PAYLOAD

Description

Method

Res

0x0A

0x01

0x00

Configuration write successfully

0x01

Configuration write failed

  • When Method is 0x02,

MCU->WiFi

TYPE

PAYLOAD

Description

Method

Data

0x0A

0x02

1-512 byte

Query Configuration Results

#3.1.8.1. Write Format of LOTA Configure

# Json format that lota configured
{
  "method": "mcu_set",
  "mcu_set": {
    "sn": "1234567",
    "cmei": "asdfgh"
  }
}

# Json format that mcu received
{
  "sn": "1234567",
  "cmei": "asdfgh"
}

# The return value of lota 0: Success 1: Failure
{
  "method":"mcu_res",
  "mcu_res": 0,
}

#3.1.8.2. Query Format of LOTA Configure

# Json format that lota configured
{
  "method": "mcu_get",
  "mcu_get": [
    "sn",
    "cmei"
  ]
}

# Json format that mcu received
[
  "sn",
  "cmei"
]

#3.1.8.3. LOTA Configuration Query Report Format

#  Format that mcu report
{
  "sn": "1234567",
  "cmei": "asdfgh"
}

# Json format that lota received
{
  "method": "mcu_reply",
  "mcu_reply":{
    "sn": "1234567",
    "cmei": "asdfgh"
  }
}

#3.2. Network Command

#3.2.1. 0x11 Active transmission of WiFi module network status

When the network state of the module changes, the module actively sends the state to the MCU.

WiFi->MCU

TYPE

PAYLOAD

Description

0x11

0x00

Router connection disconnected

0x01

Router successfully connected

0x02

In the distribution network state, the module receives the ssid sent by the phone and starts connecting to the router

MCU->WiFi

None

#3.2.2. 0x12 Query the network status of WiFi modules

MCU->WiFi

TYPE

PAYLOAD

Description

0x12

0x00

Reserved

WiFi->MCU

TYPE

PAYLOAD

Description

WiFi Status

RSSI

0x12

0x00

1 Byte

Initial State

0x01

1 Byte

Distribution network status

0x02

1 Byte

Connecting to router

0x03

1 Byte

Connected to router

  • When the module is not connected to the router, RSSI=0x00.
  • When the module is connected to the router, the RSSI value range is -100~0, int8_t type.

Status Description:

  • 0x00: factory state, or the state after restoring factory settings.
  • 0x01: represents the distribution network status, which is maintained until the router is connected.
  • 0x02: indicates the status of reconnecting the router. If the router has already been connected and disconnected, the module will attempt to reconnect to the router.
  • 0x03: indicates that the module is connected to the router.

#3.2.3. 0x13 Distribution Network Command

MCU->WiFi

TYPE

PAYLOAD

Description

Cloud Code

Type

TimeOut

0x13

0x00

0x00

2 Byte

Default distribution network method, no platform restrictions

1 Byte

0x01

2 Byte

one click distribution

0x02

2 Byte

Device AP distribution network

0x03

2 Byte

Bluetooth distribution network

0x04

2 Byte

MESH distribution network

0xFF

2 Byte

Stop distribution network

  • Cloud Code: Platform identification code.
  • TimeOut: The timeout time of the distribution network, in seconds. TimeOut=0, indicating no timeout.

The distribution network methods correspond to different platforms, as detailed in the attachment.

After receiving the distribution network command, the WiFi module restarts and enters the corresponding distribution network mode. Distribution network timeout or Type=0xFF (stop distribution network), if the module has been configured with WiFi, the module will attempt to connect back; If the module has not been configured with WiFi, the module will return to its initial state.

WiFi->MCU

TYPE

PAYLOAD

Description

0x13

0x00

Successfully set

0x01

Setting error

#3.2.4. 0x14 Scan AP Command

The timeout for AP scanning is 3 seconds.

MCU->WiFi

TYPE

PAYLOAD

Description

0x14

0x00

Scan AP information

n Bytes

Scan the AP information of the specified SSID, with a value range of n from 1 to 32,which is string type.

WiFI-MCU

TYPE

PAYLOAD

Description

ap_num

ap_list

0x14

1 Byte

ap_num * 33 Byte

Scanning results

ap_num:Number of AP, up to 20.

ap_list:Table of AP Information.

# ap_list struct

typedef struct _ap_list
{
    char ssid[32];
    int8_t rssi;
} ap_list_t;

#3.2.5. 0x15 Production Test Command

The module side scans the specified router, 'mxchip_qc_test', and the module judges the signal strength. If rssi<-70dbm, MCU failure is returned. If rssi>-70dbm, the MCU production test is successful.

MCU->WiFi

TYPE

PAYLOAD

Description

0x15

0x00

The production testing router that mxchip designated

n Bytes

The production testing router specified by the customer, with a range value of n from 1 to 32, which is string type

WiFi->MCU

TYPE

PAYLOAD

Description

0x15

0x00

Production test successful

0x01

Production test failure

  • Production testing flowchart:

#3.2.6. 0x16 WiFi Switch Command

MCU->WiFi

TYPE

PAYLOAD

Description

0x16

0x00

Close WiFi

0x01

Open WiFi

WiFi->MCU

TYPE

PAYLOAD

Description

0x16

0x00

Successfully set

0x01

Setting failured

Description:After the command is successfully sent, the WiFi module will restart.

1. If the module has been configured with WiFi and Cloud, after the MCU sends the 0x16 0x01 command, the module restarts and attempts to connect to the configured WiFi and Cloud.

2. If the MCU sends 0x16 0x00, the module first disconnects wifi and cloud, and then restarts the module; The module will not attempt to connect to WiFi and Cloud when restarted or powered on again.

#3.2.7. 0x17 WiFi Low Power Command

Setting Command

MCU->WiFi

TYPE

PAYLOAD

Description

Set

Status

0x17

0x00

0x00

Close WiFi Low Power function.

0x01

Open WiFi Low Power function.

WiFi->MCU

TYPE

PAYLOAD

Description

Set

Status

0x17

0x00

0x00

Successfully set

0x01

Setting failured

Get low power state

MCU->WiFi

TYPE

PAYLOAD

Description

Get

Status

0x17

0x01

0x00

Get low power state

WiFi->MCU

TYPE

PAYLOAD

Description

Get

Status

0x17

0x01

0x00

Close Low Power function.

0x01

Open Low Power function.

#3.2.8. 0x18 Obtain WiFi information for the module

MCU->WiFi

TYPE

PAYLOAD

Description

0x18

0x00

Query WiFi information of the module

WiFi->MCU

TYPE

PAYLOAD

Description

0x18

n bytes

WiFi related information, JSON format will be expanded in the future.

{
	"mac": "C89346000001",
	"ssid": "mxchip-ae",
  "pwd": "emc3080",
	"ip": "192.168.1.1"
}

When a field does not exist, it is not returned. For example, when querying WiFi information in factory status, only the mac field is returned.

#3.3. Cloud Platform Command

#3.3.1. 0x21 Active Distribute of Server Status of WiFi Module

When the network state of the module changes, the module actively sends the state to the MCU.

WiFi->MCU

TYPE

PAYLOAD

Description

Cloud Code

Status

0x21

1 Byte

0x00

Server connection disconnected

0x01

Server connection successfully

0x02

Binding notification, determined by the platform

0x03

Unbinding notification, determined by the platform

MCU->WiFi

None

#3.3.2. 0x22 Unbinding Notification, determined by the platform

Query the server connection status of WiFi modules

MCU->WiFi

TYPE

PAYLOAD

Description

0x22

0x00

Connection status of all platforms

1 Byte

Cloud Code

WiFi->MCU

TYPE

PAYLOAD

Description

Cloud Code

Status

0x22

1 Byte

0x00

Not connected to server

0x01

Connected to server

#3.3.3. 0x23 Unbinding Command

Unbind the device from the mobile app.

MCU->WiFi

TYPE

PAYLOAD

Description

0x23

0x00

Unbind all platforms.

1 Byte

PAYLOAD is the cloud platform identification code, unbind the corresponding platform.

WiFi->MCU

TYPE

PAYLOAD

Description

0x23

0x00

Successfully set

0x01

Setting error

#3.3.4. 0x24 Query UTC time

MCU->WiFi

TYPE

PAYLOAD

Description

0x24

0x00

String

0x01

Hex

WiFi->MCU

TYPE

PAYLOAD

Description

0x24

n Byte

Obtain UTC time, String type

8 Byte

Corresponding MCU request 0x01

Byte 0: Obtain success flag, success is 1

Byte 1: represents the year, 0x00 represents the year 2000

Byte 2: is the month, 1-12

Byte 3: is the date, 1-31

Byte 4: Clock, 0-23

Byte 5: minutes, 0-59

Byte 6: in seconds, 0-59

Byte 7: Week, 1-7

#3.3.5. 0x25 Control Instruction - TLV Format

It is recommended that the module report all device statuses once every time it connects to the server.

#3.3.5.1. Device Attribute Reporting

MCU->WiFi

TYPE

PAYLOAD

Description

TYPE

LENTH

VALUE

0x25

1 Byte

1 Byte

n Byte

  • TYPE: Attribute index value
  • LENTH: Attribute length
  • Value: attribute value

WiFi->MCU

None

#3.3.5.2. Module Attribute Distribution

The distribution of module attribute is in TLV format, and whether the attribute of module distribution is multi attribute or not is determined by the platform.

WiFi->MCU

TYPE

PAYLOAD

Description

TYPE

LENTH

VALUE

0x25

1 Byte

1 Byte

n Byte

  • TYPE: Attribute index value
  • LENTH: Attribute length
  • Value: attribute value

MCU->WiFi

None

#3.3.6. 0x26 Control Instructions - Transparent Format

If the module and cloud platform interaction protocol choose transparent communication, and if the cloud script is provided by mxchip, the device reporting attributes must be in TLV format. Users can also customize data formats and develop their own cloud scripts.

MCU can report single attribute or multiple attributes.

It is recommended that the module report all device statuses once every time it connects to the server.

#3.3.6.1. Device Attribute Report

MCU->WiFi

TYPE

PAYLOAD

Description

TYPE

LENTH

VALUE

0x26

1 Byte

1 Byte

n Byte

  • TYPE: Attribute index value
  • LENTH: Attribute length
  • Value: attribute value

WiFi->MCU

None

#3.3.6.2. Module Attribute Distribution

WiFi->MCU

TYPE

PAYLOAD

Description

TYPE

LENTH

VALUE

0x26

1 Byte

1 Byte

n Byte

  • TYPE: Attribute index value
  • LENTH: Attribute length
  • Value: attribute value

WiFi->MCU

<span class="ne-text">None</span>

#3.3.7. Control instruction JSON format

If the module and cloud platform interaction protocol choose non transparent communication, the device can report attributes in JSON format, and the module does not need to set attribute configuration tables.

MCU can report single attribute or multiple attributes.

It is recommended that the module report all device statuses once every time it connects to the server.

#3.3.7.1. 1. Device Attribute Reporting

MCU->WiFi

TYPE

PAYLOAD

Description

0x27

n Byte

Report JSON format data with n values ranging from 1 to 1024.

WiFi->MCU

<span class="ne-text">None</span>

#3.3.7.2. Module Attribute Distribution

MCU->WiFi

TYPE

PAYLOAD

Description

0x27

n Byte

Distribution JSON format data with n values ranging from 1 to 1024.

WiFi->MCU

<span class="ne-text">None</span>

#3.3.8. 0x29 Control instruction for specifying platform ID - transparent format

#3.3.8.1. 1. Date Report

MCU->WiFi

TYPE

PAYLOAD

Description

Cloud Code

Data

0x29

1 byte

n Byte

Unlimited format n value range 1~1023

WiFi->MCU

None

#3.3.8.2. Data Distribute

MCU->WiFi

TYPE

PAYLOAD

Description

Cloud Code

Data

0x29

1 byte

n Byte

Unlimited format n value range 1~1023

WiFi->MCU

None

#3.4. 4. BT & BLE Mesh Command

#3.4.1. 0x51 BT Mode Switch Command

Note: Master mode is currently not supported

MCU->WiFi:

TYPE

PAYLOAD

Description

0x51

0x00

Close BT function

0x01

Open BT LE Slave mode

0x02

Opne BT MESH mode

WiFi->MCU:

TYPE

PAYLOAD

Description

0x51

0x00

Successfully set

0x01

Setting error

#3.4.2. 0x52 BT Mode Switch Status Query Command

MCU->WiFi:

TYPE

PAYLOAD

Description

0x52

0x00

Query BLE switch status

WiFi->MCU:

TYPE

PAYLOAD

Description

0x52

0x00

Bluetooth function is closed

0x01

BT LE Slave mode is open

0x02

BT MESH mode is open

#3.4.3. 0x53 Actively Distribution Command in BT Connection Status

WiFi->MCU:

TYPE

PAYLOAD

Description

0x53

0x00

When the BT mode is BLE Slave, it indicates disconnection;

When the BT mode is MESH, it indicates that there is no grid distribution

0x01

When the BT mode is BLE Slave, it indicates connection; When the BT mode is MESH, it indicates successful distribution network

#3.4.4. 0x54 BT Connection Status Query Command

MCU->WiFi:

TYPE

PAYLOAD

Description

0x54

0x00

Query BLE Slave SPP connection state

WiFi->MCU:

TYPE

PAYLOAD

Description

0x54

0x00

When the BT mode is BLE Slave, it indicates disconnection; When the BT mode is MESH, it indicates that there is no grid distribution

0x01

When the BT mode is BLE Slave, it indicates connection; When the BT mode is MESH, it indicates successful distribution network

#3.4.5. 0x55 BT Attribute Reporting and Distribution (only BT)

#3.4.5.1. Data Report-RAW

MCU->BLE:

TYPE

PAYLOAD

Description

0x55

n Bytes

Data Receive

BLE->MCU:

None

Note: Data is only transmitted on the BT channel

#3.4.5.2. Data Distribution-RAW

BLE->MCU:

TYPE

PAYLOAD

Description

0x55

n Bytes

Data Receive

MCU->BLE:

None

#3.4.6. 0x56 BT attribute reporting and distribution (BT&WiFi)

#3.4.6.1. a. Data Report - RAW

MCU->BT&WiFi:

TYPE

PAYLOAD

Description

0x56

n Bytes

Data Receive

BLE->MCU:

Data is transmitted simultaneously on BLE and WiFi channels.

#3.4.6.2. Data Distribution-RAW

Send BT data through command 0x55.

WiFi data distribution, refer to general Command.

#0x57 BT Attribute Query

BT->MCU

TYPE

PAYLOAD

Description

0x57

n Bytes

Attribute query

#4. Attachment

#4.1. Cloud platform identification code

E-commerce

Cloud Platform

identification code

Alibaba

Feiyan/Qimingxing

0x01

JD

Xiaojing Fish

0x02

Suning

Suning Intelligent

0x03

Guomei

Guomei Intelligent

0x04

Huawei

Hilink/HormonyOS

0x05

Xiaomi

Mi Jia

0x06

Tencent

Tencent Lianlian

0x07

BT

BT LE Slave

0x08

BT

BT MESH

0x09

Hang Yan

And His Family

0x0A

#4.2. CRC8 Algorithm

#4.2.1. Method of Calculation

//CRC-8 x8+x2+x+1
unsigned char crc8(unsigned char *vptr, unsigned char len)
{
    const unsigned char *data = vptr;
    unsigned crc = 0;
    int i, j;
    for (j = len; j; j--, data++) {
        crc ^= (*data << 8);
        for (i = 8; i; i--) {
            if (crc & 0x8000)
                crc ^= (0x1070 << 3);
            crc <<= 1;
        }
    }
    return (unsigned char)(crc >> 8);
}

#4.2.2. Method of Look-Up Table

//CRC-8 x8+x2+x+1

unsigned char CRC8_Table[256] = {
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F,
0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79,
0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53,
0x5A, 0x5D, 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5,
0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, 0x90, 0x97,
0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1,
0xB4, 0xB3, 0xBA, 0xBD, 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC,
0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88,
0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A, 0x27, 0x20, 0x29, 0x2E,
0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04,
0x0D, 0x0A, 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42,
0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A, 0x89, 0x8E,
0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8,
0xAD, 0xAA, 0xA3, 0xA4, 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2,
0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56,
0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44, 0x19, 0x1E, 0x17, 0x10,
0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A,
0x33, 0x34, 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B,
0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63, 0x3E, 0x39,
0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F,
0x1A, 0x1D, 0x14, 0x13, 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5,
0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1,
0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3 };

unsigned char crc8(unsigned char *p, char counter)
{
    unsigned char crc = 0;

    for (; counter > 0; counter--) {
        crc = CRC8_Table[crc ^ *p]; //查表得到CRC码
        p++;
    }
    return crc;
}

#4.3. Introduction to TLV encoding

TLV refers to a structure composed of data type Tag, data length, and data value Value, which can describe almost any data type. The Value of TLV can also be a TLV structure, and it is precisely because of this nested nature that we can use to package protocol implementation.

T

L

V

Tag

Length

Value

Tag

Length

Value

Tag在本协议中表示属性ID。

# One TLV Object is shown as follow:
#
#          1Byte    1Byte    $Length Bytes
#		 +-------+----------+-------------+  			
#        |  Tag  |  Length  |    Value    |
#        +-------+----------+-------------+
#
# Serial TLV Objects can be connected like this:
#
#          1Byte    1Byte    $Length Bytes  1Byte    1Byte    $Length Bytes
#		 +-------+----------+-------------+-------+----------+-------------+			
#        |  Tag  |  Length  |    Value    |  Tag  |  Length  |    Value    |
#        +-------+----------+-------------+-------+----------+-------------+
#
# You can also put a TLV Object into another TLV Object, like this:
#
#          1Byte    1Byte   |---------$Length Bytes----------|
#                             1Byte    1Byte    $Length Bytes
#		 +-------+----------+-------+----------+-------------+			
#        |  Tag  |  Length  |  Tag  |  Length  |    Value    |
#        +-------+----------+-------+----------+-------------+
#

#4.3.1. Data Type

Data type of value:

Type

Identifier

Value

Boolean

bool

1 Byte

Enumeration

enum

1 Byte

Character

char

1 Byte

Short

short

2 Bytes

Integer

int

4 Bytes

Single precision floating-point

float

4 Bytes

Double precision floating-point

double

8 Bytes

Text

text

1-254 Bytes

Nested

struct

1-254 Bytes

#5. Update Record

Version

Description

Date

2.5

Update Document Format

Update Package Diagram

2022.12.6

2.4

Increase UTC time in Hex format

2021.8.24

2.3

Modify the distribution network command to adapt and stop the distribution network function

2021.6.4

2.2

Add WiFi low-power instructions

2021.2.3

2.1

1. Add WiFi switch command

2. The pins of uart can be configured through cli or BAT

2020.12.30

2.0

1. Add BT related instructions

2. Add MESH distribution network instructions

2020.12.11

1.1

Add serial port configuration file to support BAT burning and writing

2020.8.21

1.0

Initial release

2020.7.20


END.

Last Updated: 11/29/2023, 1:52:34 PM