feat: complete assembly mesh relay control path
- synchronize STM8 application and external flash layout updates\n- add assembly bootloader and assembly application test projects\n- add UART1 interrupt receive ring buffer\n- parse JDY-28M Mesh outer frames and source addresses\n- add CRC-16/MODBUS validation\n- implement relay control command 0x01 and response 0x81\n- support unicast and broadcast relay control frames\n- update host protocol, OTA documents, and serial tools
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
* @file business_protocol.h
|
||||
* @brief STM8 业务帧协议接口。
|
||||
*
|
||||
* 业务帧格式:SRC_H SRC_L | CMD | LEN | DATA | CRC16_H CRC16_L。
|
||||
* SRC 为发送方的 Mesh 短地址;CRC 使用 CRC-16/MODBUS,计算范围为
|
||||
* SRC、CMD、LEN 和 DATA,线上高字节在前。
|
||||
* 业务帧格式:CMD | LEN | DATA | CRC16_H CRC16_L。
|
||||
* 发送方和接收方短地址由JDY-28M外层提供;CRC计算范围为CMD、LEN和DATA。
|
||||
*/
|
||||
#ifndef BUSINESS_PROTOCOL_H
|
||||
#define BUSINESS_PROTOCOL_H
|
||||
@@ -14,9 +13,6 @@
|
||||
/** 业务帧最大 DATA 长度,需为 JDY-28M 外层 20 字节限制预留空间。 */
|
||||
#define BUSINESS_MAX_DATA_LENGTH 4u
|
||||
|
||||
/** 发送方短地址字段长度。 */
|
||||
#define BUSINESS_SOURCE_ADDRESS_LENGTH 2u
|
||||
|
||||
/** 业务命令:继电器控制。 */
|
||||
#define CMD_RELAY_CONTROL 0x01u
|
||||
|
||||
@@ -89,7 +85,7 @@ void BusinessProtocol_QueueDelayedResponse(uint16_t address,
|
||||
* 向解析器输入一个字节。
|
||||
*
|
||||
* 该接口只负责解析内层业务帧,不执行继电器动作,也不负责 JDY-28M
|
||||
* 外层 Mesh 封装。外层模块应在确认 `F1 DD 09 00 0A ... 0D 0A` 后,
|
||||
* 外层 Mesh 封装。外层模块应在确认 `F1 DD 09 SRC DST ... 0A` 后,
|
||||
* 将其中的业务数据逐字节送入本接口。
|
||||
*
|
||||
* @param value 输入字节。
|
||||
@@ -97,19 +93,13 @@ void BusinessProtocol_QueueDelayedResponse(uint16_t address,
|
||||
*/
|
||||
uint8_t BusinessProtocol_InputByte(uint8_t value);
|
||||
|
||||
/** 读取最近一帧合法业务帧的命令字。 */
|
||||
uint8_t BusinessProtocol_GetCommand(void);
|
||||
|
||||
/** 读取最近一帧合法业务帧的数据长度。 */
|
||||
uint8_t BusinessProtocol_GetDataLength(void);
|
||||
|
||||
/** 读取最近一帧合法业务帧携带的发送方 Mesh 短地址。 */
|
||||
uint16_t BusinessProtocol_GetSourceAddress(void);
|
||||
/** 设置当前外层接收帧携带的发送方地址,供业务应答使用。 */
|
||||
void BusinessProtocol_SetSourceAddress(uint16_t address);
|
||||
|
||||
/** 执行最近一帧已经通过校验的业务命令,并向源地址返回应答。 */
|
||||
void BusinessProtocol_HandleFrame(void);
|
||||
|
||||
/** CRC-16/MODBUS 计算函数,输入范围包含发送方地址字段。 */
|
||||
/** CRC-16/MODBUS计算函数,输入范围为CMD、LEN和DATA。 */
|
||||
uint16_t BusinessProtocol_Crc16Modbus(const uint8_t *data, uint16_t length);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user