feat: 心跳包新增固件版本号字段,更新协议文档
This commit is contained in:
@ -388,21 +388,35 @@ int main(void)
|
||||
#if USE_IO_MONITOR
|
||||
if (HAL_GetTick() - g_last_hb_tick >= 30000) {
|
||||
g_last_hb_tick = HAL_GetTick();
|
||||
uint8_t hb_payload[5]; // 扩充为 5 字节
|
||||
hb_payload[0] = IO_Monitor_GetAllStates();
|
||||
hb_payload[1] = (uint8_t)(g_hb_seq >> 8);
|
||||
hb_payload[2] = (uint8_t)(g_hb_seq & 0xFF);
|
||||
|
||||
uint16_t modbus_val = 0xFFFF; // 默认值
|
||||
uint8_t hb_payload[7];
|
||||
uint8_t io_state = IO_Monitor_GetAllStates();
|
||||
|
||||
#if USE_W5500
|
||||
modbus_val = ModbusTCP_Get_LastRegVal(); // 获取最新 Modbus 寄存器值
|
||||
uint8_t phy_link_status;
|
||||
ctlwizchip(CW_GET_PHYLINK, (void *)&phy_link_status);
|
||||
if (phy_link_status == PHY_LINK_ON) {
|
||||
io_state |= 0x80;
|
||||
}
|
||||
#endif
|
||||
hb_payload[3] = (uint8_t)(modbus_val >> 8);
|
||||
hb_payload[4] = (uint8_t)(modbus_val & 0xFF);
|
||||
|
||||
|
||||
hb_payload[0] = (uint8_t)(g_hb_seq >> 8);
|
||||
hb_payload[1] = (uint8_t)(g_hb_seq & 0xFF);
|
||||
|
||||
hb_payload[2] = (uint8_t)(XTELL_FIRMWARE_CODE >> 8);
|
||||
hb_payload[3] = (uint8_t)(XTELL_FIRMWARE_CODE & 0xFF);
|
||||
|
||||
hb_payload[4] = io_state;
|
||||
|
||||
uint16_t modbus_val = 0xFFFF;
|
||||
#if USE_W5500
|
||||
modbus_val = ModbusTCP_Get_LastRegVal();
|
||||
#endif
|
||||
hb_payload[5] = (uint8_t)(modbus_val >> 8);
|
||||
hb_payload[6] = (uint8_t)(modbus_val & 0xFF);
|
||||
|
||||
g_hb_seq++;
|
||||
|
||||
RF433_SendPacket(PROTO_TYPE_HB, hb_payload, 5); // 发送 5 字节
|
||||
|
||||
RF433_SendPacket(PROTO_TYPE_HB, hb_payload, sizeof(hb_payload));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user