fix:修改UDP通讯中,取电变化上报机制
1、问题点:当RCU网络状态异常的情况下,网络还处于协商状态下,还未进入正常通讯环节时,取电变化不会进行判断。这会导致取电变化上报与实际产生取电状态时间点对不上。 2、将BLV_C1F_Module代码上传至Gitea,之前代码修改记录请查看 .\BasicCode\Readme.txt
This commit is contained in:
998
BasicCode/Drive/NET_UPDATE/UDPServer_Internal_Protocol.c
Normal file
998
BasicCode/Drive/NET_UPDATE/UDPServer_Internal_Protocol.c
Normal file
@@ -0,0 +1,998 @@
|
||||
/*******************************************************************************
|
||||
* Function Name : UDPServer_Internal_Protocol -
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>
|
||||
*******************************************************************************/
|
||||
#include "includes.h"
|
||||
|
||||
UDP_SERVER_Information_t UDPServer_Info;
|
||||
|
||||
#define UDP_SERVER_Port 6125 //<2F><><EFBFBD><EFBFBD>ͨѶ<CDA8>˿<EFBFBD>
|
||||
|
||||
void UDP_Server_Info_Init(void)
|
||||
{
|
||||
memset(&UDPServer_Info,0,sizeof(UDP_SERVER_Information_t));
|
||||
UDPServer_Info.frame = 0x8000;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_Add_UUID
|
||||
* Description : <20><><EFBFBD><EFBFBD>UUID - 16Byte
|
||||
* Input :
|
||||
data :UUID<49><44><EFBFBD>ŵ<EFBFBD>ָ<EFBFBD><D6B8>
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void UDP_Server_Add_UUID(uint8_t *data)
|
||||
{
|
||||
for(uint8_t i=0;i<16;i++)
|
||||
{
|
||||
data[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_Data_To_Server
|
||||
* Description : UDP<44><50><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD>ط<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
* Input :
|
||||
data :<3A><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
data_len:<3A><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_Data_To_Server(uint8_t *data,uint16_t data_len)
|
||||
{
|
||||
uint8_t rev = 0;
|
||||
UINT32 send_len = data_len;
|
||||
|
||||
rev = CH57xNET_SocketUdpSendTo(net_info.SocketId[0], data, &send_len, server_info.udp_ip, UDP_SERVER_Port);
|
||||
|
||||
return rev;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_Data_To_Server
|
||||
* Description : UDP<44><50><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD>ط<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
* Input :
|
||||
data :<3A><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
data_len:<3A><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_Data_To_Server2(uint32_t data_addr,uint16_t data_len)
|
||||
{
|
||||
uint8_t rev = 0;
|
||||
UINT32 send_len = data_len;
|
||||
uint8_t data[send_len];
|
||||
memset(data,0,sizeof(data));
|
||||
|
||||
SRAM_Read_Buff(data,send_len,data_addr);
|
||||
|
||||
//Dbg_Print_Buff(DBG_BIT_Debug_STATUS_bit,"Data Buff:",data,send_len);
|
||||
rev = CH57xNET_SocketUdpSendTo(net_info.SocketId[0], data, &send_len, server_info.udp_ip, UDP_SERVER_Port);
|
||||
|
||||
return rev;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_Data_To_Server
|
||||
* Description : UDP<44><50><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD>ط<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
* Input :
|
||||
data :<3A><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
data_len:<3A><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_RetryData_To_Server(uint32_t data_addr,uint16_t data_len)
|
||||
{
|
||||
uint8_t rev = 0;
|
||||
uint16_t crc_val = 0;
|
||||
UINT32 send_len = data_len;
|
||||
uint8_t data[send_len];
|
||||
memset(data,0,sizeof(data));
|
||||
|
||||
SRAM_Read_Buff(data,send_len,data_addr);
|
||||
|
||||
UDPServer_Info.retry_num ++;
|
||||
data[US_Retry] = UDPServer_Info.retry_num;
|
||||
|
||||
crc_val = UDP_Data_Pack_CRC16(data,send_len);
|
||||
data[US_CRC_L] = crc_val & 0xFF;
|
||||
data[US_CRC_H] = (crc_val >> 8) & 0xFF;
|
||||
Dbg_Print_Buff(DBG_BIT_Debug_STATUS_bit,"Data Buff:",data,send_len);
|
||||
rev = CH57xNET_SocketUdpSendTo(net_info.SocketId[0], data, &send_len, server_info.udp_ip, UDP_SERVER_Port);
|
||||
|
||||
return rev;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Data_Put_In_SRAM_Buffer
|
||||
* Description : UDP<44><50><EFBFBD>ݷ<EFBFBD><DDB7>뵽SRAM<41>У<EFBFBD><D0A3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>(<28>ط<EFBFBD>ʹ<EFBFBD><CAB9>)
|
||||
* Input :
|
||||
data :<3A><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
data_len:<3A><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> - <20><><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ܳ<EFBFBD><DCB3><EFBFBD>550Byte
|
||||
* Return :
|
||||
0x00<30><30>д<EFBFBD><D0B4><EFBFBD>ɹ<EFBFBD>
|
||||
0x01<30><31>д<EFBFBD><D0B4>ʧ<EFBFBD><CAA7>
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Data_Put_In_SRAM_Buffer(uint8_t *data,uint16_t data_len)
|
||||
{
|
||||
if(data_len >= UDP_Server_DataLen_Max) return 0x01;
|
||||
uint32_t write_add = SRAM_Read_DW(SRAM_UDP_Server_WriteTXData_Addr);
|
||||
|
||||
if((write_add < SRAM_UDP_Server_TXDataBuff_Start_Address) || (write_add > SRAM_UDP_Server_TXDataBuff_End_Address)) {
|
||||
write_add = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
}
|
||||
|
||||
SRAM_Write_Word(data_len,write_add);
|
||||
SRAM_Write_Buff(data,data_len,write_add+2);
|
||||
|
||||
write_add += SRAM_UDP_Server_DataBuff_Size;
|
||||
if(write_add >= SRAM_UDP_Server_TXDataBuff_End_Address) write_add = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(write_add,SRAM_UDP_Server_WriteTXData_Addr);
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_NetServer_Data_Packing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵽<EFBFBD><EBB5BD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
data_cmd:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
data :<3A><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
data_len:<3A><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void UDP_NetServer_Data_Packing(uint16_t data_cmd,uint8_t *data,uint16_t data_len)
|
||||
{
|
||||
uint16_t crc_val = 0;
|
||||
uint16_t temp_len = data_len+US_Para;
|
||||
uint8_t temp_data[550];
|
||||
memset(temp_data,0,sizeof(temp_data));
|
||||
|
||||
if((UDPServer_Info.frame >= 0xFFFF) || (UDPServer_Info.frame < 0x8000)) UDPServer_Info.frame = 0x8000;
|
||||
|
||||
temp_data[US_Head_L] = UDP_Server_Head_L;
|
||||
temp_data[US_Head_H] = UDP_Server_Head_H;
|
||||
temp_data[US_Len_L] = temp_len & 0xFF;
|
||||
temp_data[US_Len_H] = (temp_len >> 8) & 0xFF;
|
||||
temp_data[US_Frame_L] = UDPServer_Info.frame & 0xFF;
|
||||
temp_data[US_Frame_H] = (UDPServer_Info.frame >> 8) & 0xFF;
|
||||
temp_data[US_Retry] = 0;
|
||||
temp_data[US_Encrption] = UDPServer_Info.encrption;
|
||||
temp_data[US_MACAddr_1] = MACAddr[0];
|
||||
temp_data[US_MACAddr_2] = MACAddr[1];
|
||||
temp_data[US_MACAddr_3] = MACAddr[2];
|
||||
temp_data[US_MACAddr_4] = MACAddr[3];
|
||||
temp_data[US_MACAddr_5] = MACAddr[4];
|
||||
temp_data[US_MACAddr_6] = MACAddr[5];
|
||||
temp_data[US_CMD_L] = data_cmd & 0xFF;
|
||||
temp_data[US_CMD_H] = (data_cmd >> 8) & 0xFF;
|
||||
|
||||
for(uint16_t i = 0;i<data_len;i++)
|
||||
{
|
||||
temp_data[US_Para + i] = data[i];
|
||||
}
|
||||
|
||||
//CRCУ<43><D0A3>
|
||||
crc_val = UDP_Data_Pack_CRC16(temp_data,temp_len);
|
||||
temp_data[US_CRC_L] = crc_val & 0xFF;
|
||||
temp_data[US_CRC_H] = (crc_val >> 8) & 0xFF;
|
||||
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"CRC:%04X,Frame:%04X,Len:%ld",crc_val,UDPServer_Info.frame,temp_len);
|
||||
Dbg_Print_Buff(DBG_BIT_Debug_STATUS_bit,"Data Buff:",temp_data,temp_len);
|
||||
UDPServer_Info.frame++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
UDP_Data_Put_In_SRAM_Buffer(temp_data,temp_len);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_NetServer_ReplyData_Packing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>У<EFBFBD><D0A3>CRC
|
||||
* Input :
|
||||
data_cmd:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
frame :<3A>ظ<EFBFBD>֡<EFBFBD><D6A1>
|
||||
data :<3A><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
data_len:<3A><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void UDP_NetServer_ReplyData_Packing(uint16_t data_cmd,uint16_t frame,uint8_t *data,uint16_t data_len)
|
||||
{
|
||||
uint16_t crc_val = 0;
|
||||
|
||||
data[US_Head_L] = UDP_Server_Head_L;
|
||||
data[US_Head_H] = UDP_Server_Head_H;
|
||||
data[US_Len_L] = data_len & 0xFF;
|
||||
data[US_Len_H] = (data_len >> 8) & 0xFF;
|
||||
data[US_Frame_L] = frame & 0xFF;
|
||||
data[US_Frame_H] = (frame >> 8) & 0xFF;
|
||||
data[US_Retry] = 0;
|
||||
data[US_Encrption] = UDPServer_Info.encrption;
|
||||
data[US_MACAddr_1] = MACAddr[0];
|
||||
data[US_MACAddr_2] = MACAddr[1];
|
||||
data[US_MACAddr_3] = MACAddr[2];
|
||||
data[US_MACAddr_4] = MACAddr[3];
|
||||
data[US_MACAddr_5] = MACAddr[4];
|
||||
data[US_MACAddr_6] = MACAddr[5];
|
||||
data[US_CMD_L] = data_cmd & 0xFF;
|
||||
data[US_CMD_H] = (data_cmd >> 8) & 0xFF;
|
||||
|
||||
//CRCУ<43><D0A3>
|
||||
crc_val = UDP_Data_Pack_CRC16(data,data_len);
|
||||
data[US_CRC_L] = crc_val & 0xFF;
|
||||
data[US_CRC_H] = (crc_val >> 8) & 0xFF;
|
||||
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"CRC:%04X,Frame:%04X",crc_val,frame,data_len);
|
||||
Dbg_Print_Buff(DBG_BIT_Debug_STATUS_bit,"Data Buff:",data,data_len);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_NetServer_Heartbeat_Packing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void UDP_NetServer_Heartbeat_Packing(void)
|
||||
{
|
||||
uint8_t buff[20];
|
||||
memset(buff,0,sizeof(buff));
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD>IP*/
|
||||
buff[0] = net_info.local_ip[0];
|
||||
buff[1] = net_info.local_ip[1];
|
||||
buff[2] = net_info.local_ip[2];
|
||||
buff[3] = net_info.local_ip[3];
|
||||
|
||||
/*UUID 16Byte*/
|
||||
for(uint8_t i=0;i<16;i++)
|
||||
{
|
||||
buff[4 + i] = i;
|
||||
}
|
||||
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
UDP_NetServer_Data_Packing(UDP_Server_CMD_Heartbeat,buff,20);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_NetServer_Task
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void UDP_NetServer_Task(void)
|
||||
{
|
||||
static uint32_t net_tick = 0;
|
||||
static uint32_t test_tick = 0;
|
||||
static uint32_t udptest_tick = 0;
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>н<EFBFBD><D0BD>յ<EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
if((UDPServer_Info.test_flag == 0x00) && (SysTick_1ms - test_tick > 20000))
|
||||
{
|
||||
test_tick = SysTick_1ms;
|
||||
UDP_NetServer_Heartbeat_Packing();
|
||||
}else if((UDPServer_Info.test_flag == 0x01) && (SysTick_1ms - udptest_tick > UDPServer_Info.test_time)){
|
||||
udptest_tick = SysTick_1ms;
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"UDP_NetServer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD> ");
|
||||
|
||||
}
|
||||
|
||||
switch(UDPServer_Info.send_state)
|
||||
{
|
||||
case USS_IDLE:
|
||||
if(SysTick_1ms - net_tick > 10)
|
||||
{
|
||||
net_tick = SysTick_1ms;
|
||||
|
||||
uint32_t w_addr = SRAM_Read_DW(SRAM_UDP_Server_WriteTXData_Addr);
|
||||
uint32_t r_addr = SRAM_Read_DW(SRAM_UDP_Server_ReadTXData_Addr);
|
||||
|
||||
if((w_addr < SRAM_UDP_Server_TXDataBuff_Start_Address) || (w_addr > SRAM_UDP_Server_TXDataBuff_End_Address)) {
|
||||
w_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(w_addr,SRAM_UDP_Server_WriteTXData_Addr);
|
||||
}
|
||||
if((r_addr < SRAM_UDP_Server_TXDataBuff_Start_Address) || (r_addr > SRAM_UDP_Server_TXDataBuff_End_Address)) {
|
||||
r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
}
|
||||
|
||||
if(w_addr != r_addr) //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>
|
||||
{
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"UDP_NetServer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>w:%08X r:%08X",w_addr,r_addr);
|
||||
UDPServer_Info.retry_num = 0;
|
||||
UDPServer_Info.send_state = USS_SEND;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case USS_SEND:
|
||||
{
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"UDP_NetServer <20><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD> ");
|
||||
uint32_t r_addr = SRAM_Read_DW(SRAM_UDP_Server_ReadTXData_Addr);
|
||||
uint16_t data_len = 0;
|
||||
if((r_addr < SRAM_UDP_Server_TXDataBuff_Start_Address) || (r_addr > SRAM_UDP_Server_TXDataBuff_End_Address))
|
||||
{
|
||||
r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
}
|
||||
|
||||
data_len = SRAM_Read_Word(r_addr);
|
||||
|
||||
if(data_len >= UDP_Server_DataLen_Max) //<2F><><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
|
||||
{
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"UDP_NetServer <20><><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>");
|
||||
UDPServer_Info.send_state = USS_IDLE;
|
||||
r_addr += SRAM_UDP_Server_DataBuff_Size;
|
||||
if(r_addr >= SRAM_UDP_Server_TXDataBuff_End_Address) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
break;
|
||||
}
|
||||
|
||||
UDP_Server_Data_To_Server2(r_addr+2,data_len);
|
||||
UDPServer_Info.send_tick = SysTick_1ms;
|
||||
|
||||
// /*<2A><><EFBFBD>ͳɹ<CDB3><C9B9><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ<EFBFBD><D6B7>Ϊ*/
|
||||
// r_addr += SRAM_UDP_Server_DataBuff_Size;
|
||||
// if(r_addr >= SRAM_UDP_Server_TXDataBuff_End_Address) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
// SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
|
||||
UDPServer_Info.send_state = USS_SENDWAIT;
|
||||
}
|
||||
break;
|
||||
case USS_SENDWAIT:
|
||||
if(SysTick_1ms - UDPServer_Info.send_tick > UDP_Server_DataSendWait_Max)
|
||||
{
|
||||
if(UDPServer_Info.retry_num >= UDP_Server_DataRetry_Max)
|
||||
{
|
||||
|
||||
/*<2A><><EFBFBD>ͳɹ<CDB3><C9B9><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ<EFBFBD><D6B7>Ϊ*/
|
||||
uint32_t r_addr = SRAM_Read_DW(SRAM_UDP_Server_ReadTXData_Addr);
|
||||
if((r_addr < SRAM_UDP_Server_TXDataBuff_Start_Address) || (r_addr > SRAM_UDP_Server_TXDataBuff_End_Address)) {
|
||||
r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
}
|
||||
|
||||
r_addr += SRAM_UDP_Server_DataBuff_Size;
|
||||
if(r_addr >= SRAM_UDP_Server_TXDataBuff_End_Address) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"UDP_NetServer <20><><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD> r_addr:%08X",r_addr);
|
||||
UDPServer_Info.send_state = USS_IDLE;
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"UDP_NetServer <20><><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD> %d",UDPServer_Info.retry_num);
|
||||
UDPServer_Info.send_state = USS_RETRY;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case USS_RETRY:
|
||||
{
|
||||
uint32_t r_addr = SRAM_Read_DW(SRAM_UDP_Server_ReadTXData_Addr);
|
||||
uint16_t data_len = SRAM_Read_Word(r_addr);
|
||||
if((r_addr < SRAM_UDP_Server_TXDataBuff_Start_Address) || (r_addr > SRAM_UDP_Server_TXDataBuff_End_Address))
|
||||
{
|
||||
r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
}
|
||||
if(data_len >= UDP_Server_DataLen_Max) //<2F><><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
|
||||
{
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"UDP_NetServer <20><><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>");
|
||||
UDPServer_Info.send_state = USS_IDLE;
|
||||
r_addr += SRAM_UDP_Server_DataBuff_Size;
|
||||
if(r_addr >= SRAM_UDP_Server_TXDataBuff_End_Address) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
break;
|
||||
}
|
||||
|
||||
UDP_Server_RetryData_To_Server(r_addr+2,data_len);
|
||||
UDPServer_Info.send_tick = SysTick_1ms;
|
||||
UDPServer_Info.send_state = USS_SENDWAIT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
UDPServer_Info.send_state = USS_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Data_Conver_To_Uint16
|
||||
* Description : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊuint16_t<5F><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint16_t Data_Conver_To_Uint16(uint8_t *data)
|
||||
{
|
||||
uint16_t temp_data = data[1];
|
||||
temp_data <<= 8;
|
||||
temp_data |= data[0];
|
||||
|
||||
return temp_data;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_NetServer_Data_CheckCRC
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>CRC
|
||||
* Input :
|
||||
* Return :
|
||||
0x00:CRC<52><43>ȷ
|
||||
0x01:CRC<52><43><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_NetServer_Data_CheckCRC(UINT8 *data, UINT32 len)
|
||||
{
|
||||
uint16_t data_crc = 0;
|
||||
uint16_t crc_val = 0;
|
||||
|
||||
data_crc = Data_Conver_To_Uint16(&data[US_CRC_L]);
|
||||
|
||||
crc_val = UDP_Data_Pack_CRC16(data,len);
|
||||
|
||||
if(crc_val == data_crc) return 0x00;
|
||||
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Search_Data_Processing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Search_Data_Processing(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
uint16_t cmd_frame = 0;
|
||||
|
||||
|
||||
uint16_t back_len = 449 + US_Para; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
uint8_t back_data[back_len + 2];
|
||||
|
||||
memset(back_data,0,sizeof(back_data));
|
||||
|
||||
cmd_frame = data[US_Frame_H];
|
||||
cmd_frame <<= 8;
|
||||
cmd_frame |= data[US_Frame_L];
|
||||
|
||||
if(cmd_frame >= 0x8000) {
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<>Ų<EFBFBD><C5B2><EFBFBD>\r\n");
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
if(cmd_frame == UDPServer_Info.rev_frame) {
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<><D6A1><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
|
||||
return 0x001;
|
||||
}
|
||||
|
||||
/*<2A>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
back_data[US_Para] = 0x00;
|
||||
memcpy(&back_data[US_Para + 1],MCU_TYPE,sizeof(MCU_TYPE)); //<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>
|
||||
memcpy(&back_data[US_Para + 17],net_info.local_ip,4); //IP<49><50>ַ
|
||||
memcpy(&back_data[US_Para + 21],server_info.dis_ip,4); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַ
|
||||
memcpy(&back_data[US_Para + 25],net_info.mask,4); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
memcpy(&back_data[US_Para + 29],net_info.gwip_addr,4); //<2F><><EFBFBD><EFBFBD>
|
||||
back_data[US_Para + 33] = (6000 + MACAddr[5]) & 0xFF;
|
||||
back_data[US_Para + 34] = ((6000 + MACAddr[5]) >> 8) & 0xFF;
|
||||
memcpy(&back_data[US_Para + 37],DNS_SERVER_IP,4); //DNS<4E><53>ַ
|
||||
UDP_ADD_SoftwareVer(&back_data[US_Para+41]); //<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>
|
||||
/*RTCʱ<43><CAB1>*/
|
||||
back_data[US_Para+61] = HEX_Conversion_To_DEC(RTC_Raw_Data.year);
|
||||
back_data[US_Para+62] = HEX_Conversion_To_DEC(RTC_Raw_Data.month);
|
||||
back_data[US_Para+63] = HEX_Conversion_To_DEC(RTC_Raw_Data.day);
|
||||
back_data[US_Para+64] = HEX_Conversion_To_DEC(RTC_Raw_Data.hour);
|
||||
back_data[US_Para+65] = HEX_Conversion_To_DEC(RTC_Raw_Data.minute);
|
||||
back_data[US_Para+66] = HEX_Conversion_To_DEC(RTC_Raw_Data.second);
|
||||
|
||||
/*Launcher<65>汾 ֻ<><D6BB>Launcher_C1F_V04 <20><><EFBFBD>ϰ汾<CFB0>ſ<EFBFBD><C5BF>Զ<EFBFBD>ȡ<EFBFBD><C8A1>Launcher<65>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD>°汾<C2B0>Ƕ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>*/
|
||||
MCU_Flash_Read((uint8_t *)&back_data[US_Para+67],20,Launcher_SoftwareVer_Addr);
|
||||
|
||||
UDP_Add_Mac(&back_data[US_Para+87]); //MAC<41><43>ַ
|
||||
SRAM_Read_Buff(&back_data[US_Para+93],4,SRAM_Register_Start_ADDRESS + Register_ProjectCode_OFFSET); //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
||||
SRAM_Read_Buff(&back_data[US_Para+97],4,SRAM_Register_Start_ADDRESS + Register_RoomNumber_OFFSET);
|
||||
SRAM_Read_Buff(&back_data[US_Para+101],4,SRAM_Register_Start_ADDRESS + Register_HouseType_OFFSET);
|
||||
SRAM_Read_Buff(&back_data[US_Para+105],4,SRAM_Register_Start_ADDRESS + Register_ConfigVersion_OFFSET);
|
||||
SRAM_Read_Buff(&back_data[US_Para+109],4,SRAM_Register_Start_ADDRESS + Register_RoomRent_OFFSET);
|
||||
SRAM_Read_Buff(&back_data[US_Para+113],4,SRAM_Register_Start_ADDRESS + Register_SeasonStatus_OFFSET);
|
||||
back_data[US_Para+117] = Get_Authorize_Lock_Status(); //<2F><>ȡ<EFBFBD><C8A1>Ȩ״̬
|
||||
SRAM_Read_Buff(&back_data[US_Para+121],4,SRAM_Register_Start_ADDRESS + Register_MandateUTC_OFFSET);
|
||||
SRAM_Read_Buff(&back_data[US_Para+125],4,SRAM_Register_Start_ADDRESS + Register_MandateExpiresTime_OFFSET);
|
||||
SRAM_Read_Buff(&back_data[US_Para+129],128,SRAM_Register_Start_ADDRESS + Register_RoomNumNote_OFFSET);
|
||||
Flash_Read(&back_data[US_Para+257],64,FLASH_MCU_Model_Revision_ADDRESS);
|
||||
Flash_Read(&back_data[US_Para+321],64,FLASH_MCU_Control_Revision_ADDRESS);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õľƵ<C4BE><C6B5><EFBFBD><EFBFBD>ƺͷ<C6BA><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2022-07-13
|
||||
Read_LogicFile_Information(0x04,(uint8_t *)&back_data[US_Para+385]); //<2F><>ѯLOGIC<49>ļ<EFBFBD><C4BC>еľƵ<C4BE><C6B5><EFBFBD><EFBFBD><EFBFBD> - 32Byte
|
||||
Read_LogicFile_Information(0x07,(uint8_t *)&back_data[US_Para+417]); //<2F><>ѯLOGIC<49>ļ<EFBFBD><C4BC>еķ<D0B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - 32Byte
|
||||
|
||||
|
||||
//<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>
|
||||
UDP_NetServer_ReplyData_Packing(UDP_Server_CMD_Search,cmd_frame,back_data,back_len);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
UDP_Server_Data_To_Server(back_data,back_len);
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Register_Data_Processing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6>(<28><><EFBFBD>ò<EFBFBD>Ʒ<EFBFBD><C6B7>Կ)
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Register_Data_Processing(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
uint8_t rev = 0;
|
||||
uint8_t temp_data = 0;
|
||||
uint16_t cmd_frame = 0;
|
||||
uint16_t back_len = 272 + US_Para;
|
||||
uint8_t back_data[back_len + 2];
|
||||
memset(back_data,0,sizeof(back_data));
|
||||
|
||||
cmd_frame = data[US_Frame_H];
|
||||
cmd_frame <<= 8;
|
||||
cmd_frame |= data[US_Frame_L];
|
||||
/*<2A>ж<EFBFBD>֡<EFBFBD><D6A1>*/
|
||||
if(cmd_frame >= 0x8000) {
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<>Ų<EFBFBD><C5B2><EFBFBD>\r\n");
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
if(cmd_frame == UDPServer_Info.rev_frame) {
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<><D6A1><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
|
||||
return 0x001;
|
||||
}
|
||||
|
||||
UDPServer_Info.rev_frame = cmd_frame;
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - MAC<41><43>ַ 4Byte + <20><>Ʒ<EFBFBD><C6B7>Կ 64Byte*/
|
||||
|
||||
/*<2A>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MAC<41><43>ַ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ*/
|
||||
for(temp_data=0;temp_data<6;temp_data++)
|
||||
{
|
||||
if(data[US_Para + temp_data] != MACAddr[temp_data]) break;
|
||||
}
|
||||
if(temp_data != 6) {
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MAC<41><43>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>\r\n");
|
||||
rev = 0x02;
|
||||
}else {
|
||||
rev = 0x01;
|
||||
}
|
||||
|
||||
/*<2A><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD> - <20><>У<EFBFBD><D0A3>MAC<41><43>ַ MACһ<43>£<EFBFBD><C2A3>㽫<EFBFBD><E3BDAB>Ʒ<EFBFBD><C6B7>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD> 64Byte*/
|
||||
if(rev == 0x01)
|
||||
{
|
||||
Flash_Write(&data[US_Para+6],64,FLASH_MCU_ProductKey_ADDRESS); //<2F><>Ʒ<EFBFBD><C6B7>Կ 64Byte
|
||||
}
|
||||
|
||||
/*<2A>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
back_data[US_Para] = rev;
|
||||
Flash_Read(&back_data[US_Para+1],64,FLASH_MCU_Model_Revision_ADDRESS);
|
||||
Flash_Read(&back_data[US_Para+65],64,FLASH_MCU_Control_Revision_ADDRESS);
|
||||
UDP_Add_Mac(&back_data[US_Para+129]); //MAC<41><43>ַ
|
||||
UDP_Server_Add_UUID(&back_data[US_Para+135]); //<2F><><EFBFBD><EFBFBD>UUID
|
||||
Flash_Read(&back_data[US_Para+151],64,FLASH_MCU_ProductKey_ADDRESS); //<2F><>Ʒ<EFBFBD><C6B7>Կ 64Byte
|
||||
|
||||
//<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>
|
||||
UDP_NetServer_ReplyData_Packing(UDP_Server_CMD_Search,cmd_frame,back_data,back_len);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
UDP_Server_Data_To_Server(back_data,back_len);
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Heartbeat_Data_Processing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Heartbeat_ReplyData_Processing(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
uint32_t test_temp = 0;
|
||||
S_RTC test_rtc;
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
uint32_t r_addr = SRAM_Read_DW(SRAM_UDP_Server_ReadTXData_Addr);
|
||||
if((r_addr < SRAM_UDP_Server_TXDataBuff_Start_Address) || (r_addr > SRAM_UDP_Server_TXDataBuff_End_Address))
|
||||
{
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>Χ<EFBFBD><CEA7>*/
|
||||
r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
}
|
||||
|
||||
if((data[US_Frame_L] == SRAM_Read_Byte(r_addr + 2 + US_Frame_L)) && (data[US_Frame_H] == SRAM_Read_Byte(r_addr + 2 + US_Frame_H)))
|
||||
{
|
||||
/*֡<><D6A1><EFBFBD><EFBFBD>ͬ*/
|
||||
r_addr += SRAM_UDP_Server_DataBuff_Size;
|
||||
if(r_addr >= SRAM_UDP_Server_TXDataBuff_End_Address) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
UDPServer_Info.send_state = USS_IDLE;
|
||||
|
||||
test_temp = SysTick_1ms - UDPServer_Info.send_tick;
|
||||
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> r_addr:%08X ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%dms",r_addr,test_temp);
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<>Ų<EFBFBD>ͬ%02X%02X - %02X%02X",data[US_Frame_H],data[US_Frame_L],SRAM_Read_Byte(r_addr + 2 + US_Frame_H),SRAM_Read_Byte(r_addr + 2 + US_Frame_L));
|
||||
}
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> UTC<54><43><EFBFBD><EFBFBD> 4Byte + TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP 4Byte*/
|
||||
test_temp = data[US_Para + 3];
|
||||
test_temp <<= 8;
|
||||
test_temp |= data[US_Para + 2];
|
||||
test_temp <<= 8;
|
||||
test_temp |= data[US_Para + 1];
|
||||
test_temp <<= 8;
|
||||
test_temp |= data[US_Para + 0];
|
||||
|
||||
Unix_Conversion_To_RTC(&test_rtc,test_temp);
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"UTCʱ<EFBFBD><EFBFBD>: %08X - 20%02X-%02X-%02X %02X:%02X:%02X %02X",test_temp,test_rtc.year,test_rtc.month,test_rtc.day,test_rtc.hour,test_rtc.minute,test_rtc.second,test_rtc.week);
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"TFTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP: %02X.%02X.%02X.%02X",data[US_Para + 4],data[US_Para + 5],data[US_Para + 6],data[US_Para + 7]);
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Change_Report_Data_Processing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - <20>ϱ<EFBFBD><CFB1>豸״̬<D7B4>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Change_Report_ReplyData_Processing(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20>仯<EFBFBD>ϱ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
uint32_t r_addr = SRAM_Read_DW(SRAM_UDP_Server_ReadTXData_Addr);
|
||||
if((r_addr < SRAM_UDP_Server_TXDataBuff_Start_Address) || (r_addr > SRAM_UDP_Server_TXDataBuff_End_Address)) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
|
||||
if((data[US_Frame_L] == SRAM_Read_Byte(r_addr + 2 + US_Frame_L)) && (data[US_Frame_H] == SRAM_Read_Byte(r_addr + 2 + US_Frame_H)))
|
||||
{
|
||||
/*֡<><D6A1><EFBFBD><EFBFBD>ͬ*/
|
||||
r_addr += SRAM_UDP_Server_DataBuff_Size;
|
||||
if(r_addr >= SRAM_UDP_Server_TXDataBuff_End_Address) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
UDPServer_Info.send_state = USS_IDLE;
|
||||
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> r_addr:%08X",r_addr);
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<>Ų<EFBFBD>ͬ%02X%02X - %02X%02X",data[US_Frame_H],data[US_Frame_L],SRAM_Read_Byte(r_addr + 2 + US_Frame_H),SRAM_Read_Byte(r_addr + 2 + US_Frame_L));
|
||||
}
|
||||
|
||||
/*<2A>ûظ<C3BB><D8B8><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>*/
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Control_Dev_Data_Processing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - <20>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Control_Dev_Data_Processing(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
uint8_t deal_flag = 0x01,retry_flag = 0x00;
|
||||
uint16_t cmd_frame = 0,data_len = len - US_Para;
|
||||
uint16_t back_len = 1 + US_Para;
|
||||
uint32_t read_addr = 0;
|
||||
uint8_t back_data[back_len + 2];
|
||||
memset(back_data,0,sizeof(back_data));
|
||||
|
||||
cmd_frame = data[US_Frame_H];
|
||||
cmd_frame <<= 8;
|
||||
cmd_frame |= data[US_Frame_L];
|
||||
/*<2A>ж<EFBFBD>֡<EFBFBD><D6A1>*/
|
||||
if(cmd_frame >= 0x8000) {
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<>Ų<EFBFBD><C5B2><EFBFBD>\r\n");
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
if(cmd_frame == UDPServer_Info.rev_frame) {
|
||||
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<><D6A1><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>:%d\r\n",data[US_Retry]);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> - <20><>6<EFBFBD><36><EFBFBD>ط<EFBFBD><D8B7>ٻظ<D9BB>
|
||||
if(data[US_Retry] == 0x06)
|
||||
{
|
||||
retry_flag = 0x01;
|
||||
}
|
||||
deal_flag = 0x00;
|
||||
}
|
||||
UDPServer_Info.rev_frame = cmd_frame;
|
||||
|
||||
if(deal_flag == 0x00)
|
||||
{
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>棬<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ݻὫ<DDBB>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>滻*/
|
||||
SRAM_Write_Byte(data[CMD_OFFSET + 7],SRAM_UDP_RecvData_ControlNum);
|
||||
SRAM_DMA_Write_Buff(&data[CMD_OFFSET + 8],data_len,SRAM_UDP_RecvData_Startaddr);
|
||||
read_addr = SRAM_UDP_RecvData_Startaddr + data_len;
|
||||
SRAM_Write_DW(read_addr,SRAM_UDP_RecvData_Writeaddr);
|
||||
}
|
||||
|
||||
/*<2A>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
back_data[US_Para] = 0x00;
|
||||
|
||||
if(retry_flag == 0x01)
|
||||
{
|
||||
//<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>
|
||||
UDP_NetServer_ReplyData_Packing(UDP_Server_CMD_Control_Dev,cmd_frame,back_data,back_len);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
UDP_Server_Data_To_Server(back_data,back_len);
|
||||
}
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Starter_Test_Data_Processing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - <20>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Starter_Test_Data_Processing(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
uint8_t deal_flag = 0x01;
|
||||
uint16_t cmd_frame = 0;
|
||||
uint16_t back_len = 1 + US_Para;
|
||||
|
||||
uint8_t back_data[back_len + 2];
|
||||
memset(back_data,0,sizeof(back_data));
|
||||
|
||||
cmd_frame = data[US_Frame_H];
|
||||
cmd_frame <<= 8;
|
||||
cmd_frame |= data[US_Frame_L];
|
||||
/*<2A>ж<EFBFBD>֡<EFBFBD><D6A1>*/
|
||||
if(cmd_frame >= 0x8000) {
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<>Ų<EFBFBD><C5B2><EFBFBD>\r\n");
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
if(cmd_frame == UDPServer_Info.rev_frame) {
|
||||
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<><D6A1><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>:%d\r\n",data[US_Retry]);
|
||||
|
||||
deal_flag = 0x00;
|
||||
}
|
||||
UDPServer_Info.rev_frame = cmd_frame;
|
||||
|
||||
if(deal_flag == 0x01)
|
||||
{
|
||||
/*<2A><><EFBFBD>ò<EFBFBD><C3B2>Ա<EFBFBD>־λ*/
|
||||
UDPServer_Info.test_flag = 0x01;
|
||||
UDPServer_Info.test_num = data[US_Para] + (data[US_Para + 1] << 8);
|
||||
UDPServer_Info.test_time = data[US_Para + 2];
|
||||
UDPServer_Info.test_sn = 0;
|
||||
}
|
||||
|
||||
/*<2A>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
back_data[US_Para] = 0x00;
|
||||
|
||||
//<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>
|
||||
UDP_NetServer_ReplyData_Packing(UDP_Server_CMD_Control_Dev,cmd_frame,back_data,back_len);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
UDP_Server_Data_To_Server(back_data,back_len);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Send_Test_Data_Packing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Send_Test_Data_Packing()
|
||||
{
|
||||
uint32_t temp_tick = 0;
|
||||
uint8_t buff[20];
|
||||
memset(buff,0,sizeof(buff));
|
||||
|
||||
UDPServer_Info.test_sn++;
|
||||
|
||||
if(UDPServer_Info.test_sn >= UDPServer_Info.test_num) UDPServer_Info.test_flag = 0;
|
||||
|
||||
buff[0] = (UDPServer_Info.test_num & 0xFF);
|
||||
buff[1] = (UDPServer_Info.test_num >> 8) & 0xFF;
|
||||
buff[2] = (UDPServer_Info.test_sn & 0xFF);
|
||||
buff[3] = (UDPServer_Info.test_sn >> 8) & 0xFF;
|
||||
|
||||
/*UTCʱ<43><CAB1> 4Byte*/
|
||||
temp_tick = RTC_Conversion_To_Unix(&RTC_Raw_Data);
|
||||
|
||||
buff[4] = temp_tick & 0xFF;
|
||||
buff[5] = (temp_tick >> 8) & 0xFF;
|
||||
buff[6] = (temp_tick >> 16) & 0xFF;
|
||||
buff[7] = (temp_tick >> 24) & 0xFF;
|
||||
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"%s",__func__);
|
||||
UDP_NetServer_Data_Packing(UDP_Server_CMD_Send_Test_Data,buff,8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Send_Test_Data_Processing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Send_Test_ReplyData_Processing(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>");
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
uint32_t r_addr = SRAM_Read_DW(SRAM_UDP_Server_ReadTXData_Addr);
|
||||
if((r_addr < SRAM_UDP_Server_TXDataBuff_Start_Address) || (r_addr > SRAM_UDP_Server_TXDataBuff_End_Address)) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
|
||||
if((data[US_Frame_L] == SRAM_Read_Byte(r_addr + 2 + US_Frame_L)) && (data[US_Frame_H] == SRAM_Read_Byte(r_addr + 2 + US_Frame_H)))
|
||||
{
|
||||
/*֡<><D6A1><EFBFBD><EFBFBD>ͬ*/
|
||||
r_addr += SRAM_UDP_Server_DataBuff_Size;
|
||||
if(r_addr >= SRAM_UDP_Server_TXDataBuff_End_Address) r_addr = SRAM_UDP_Server_TXDataBuff_Start_Address;
|
||||
SRAM_Write_DW(r_addr,SRAM_UDP_Server_ReadTXData_Addr);
|
||||
UDPServer_Info.send_state = USS_IDLE;
|
||||
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD> r_addr:%08X",r_addr);
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD> ֡<>Ų<EFBFBD>ͬ%02X%02X - %02X%02X",data[US_Frame_H],data[US_Frame_L],SRAM_Read_Byte(r_addr + 2 + US_Frame_H),SRAM_Read_Byte(r_addr + 2 + US_Frame_L));
|
||||
}
|
||||
|
||||
/*<2A>ûظ<C3BB><D8B8><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>*/
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Server_CMD_Read_RCU_Data_Processing
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6> - <20><>ȡRCU<43><55><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint8_t UDP_Server_CMD_Read_RCU_Data_Processing(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
uint8_t deal_flag = 0x01,read_flag = 0x00,result = 0x02;
|
||||
uint16_t cmd_frame = 0;
|
||||
uint16_t back_len = 530 + US_Para;
|
||||
|
||||
uint32_t read_addr = 0,read_len = 0;
|
||||
uint8_t back_data[back_len + 2];
|
||||
memset(back_data,0,sizeof(back_data));
|
||||
|
||||
cmd_frame = data[US_Frame_H];
|
||||
cmd_frame <<= 8;
|
||||
cmd_frame |= data[US_Frame_L];
|
||||
/*<2A>ж<EFBFBD>֡<EFBFBD><D6A1>*/
|
||||
if(cmd_frame >= 0x8000) {
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<>Ų<EFBFBD><C5B2><EFBFBD>\r\n");
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
if(cmd_frame == UDPServer_Info.rev_frame) {
|
||||
|
||||
Dbg_Print(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֡<><D6A1><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>:%d\r\n",data[US_Retry]);
|
||||
|
||||
deal_flag = 0x00;
|
||||
}
|
||||
UDPServer_Info.rev_frame = cmd_frame;
|
||||
|
||||
back_len = US_Para + 1;
|
||||
|
||||
if(deal_flag == 0x00)
|
||||
{
|
||||
/*<2A><>ȡRCU<43><55><EFBFBD><EFBFBD> - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> 4Byte*/
|
||||
read_flag = data[US_Para];
|
||||
|
||||
/*<2A><>ȡRCU<43><55><EFBFBD><EFBFBD> - <20><>ȡ<EFBFBD><C8A1>ַ 4Byte*/
|
||||
read_addr = data[US_Para + 4];
|
||||
read_addr <<= 8;
|
||||
read_addr |= data[US_Para + 3];
|
||||
read_addr <<= 8;
|
||||
read_addr |= data[US_Para + 2];
|
||||
read_addr <<= 8;
|
||||
read_addr |= data[US_Para + 1];
|
||||
|
||||
/*<2A><>ȡRCU<43><55><EFBFBD><EFBFBD> - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> 4Byte - Ŀǰ<C4BF><EFBFBD>Ķ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ϊ512Byte*/
|
||||
read_len = data[US_Para + 8];
|
||||
read_len <<= 8;
|
||||
read_len |= data[US_Para + 7];
|
||||
read_len <<= 8;
|
||||
read_len |= data[US_Para + 6];
|
||||
read_len <<= 8;
|
||||
read_len |= data[US_Para + 5];
|
||||
if(read_len >= 512) read_len = 512;
|
||||
|
||||
/*<2A><>ȡRCU*/
|
||||
switch(read_flag)
|
||||
{
|
||||
case 0x01: //SRAM
|
||||
if(read_addr >= SRAM_ADDRESS_MAX) {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>Χ");
|
||||
break;
|
||||
}
|
||||
SRAM_Read_Buff(&back_data[US_Para+1],read_len,read_addr);
|
||||
back_len += read_len;
|
||||
result = 0x01;
|
||||
break;
|
||||
case 0x02: //Flash
|
||||
if(read_addr >= Flash_ADDRESS_MAX) {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>Χ");
|
||||
break;
|
||||
}
|
||||
Flash_Read(&back_data[US_Para+1],read_len,read_addr);
|
||||
back_len += read_len;
|
||||
result = 0x01;
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*<2A>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
back_data[US_Para] = result;
|
||||
|
||||
//<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>
|
||||
UDP_NetServer_ReplyData_Packing(UDP_Server_CMD_Read_RCU_Data,cmd_frame,back_data,back_len);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
UDP_Server_Data_To_Server(back_data,back_len);
|
||||
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_NetServer_Data_Analysis
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void UDP_NetServer_Data_Analysis(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port)
|
||||
{
|
||||
if((data[US_Head_L] != UDP_Server_Head_L) || (data[US_Head_H] != UDP_Server_Head_H)) {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD><EFBFBD>UDP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
|
||||
if(Data_Conver_To_Uint16(&data[US_Len_L]) != len) {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD><EFBFBD>UDP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD> %04X - %04X",len,Data_Conver_To_Uint16(&data[US_Len_L]));
|
||||
return;
|
||||
}
|
||||
|
||||
if(UDP_NetServer_Data_CheckCRC(data,len)) {
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD><EFBFBD>UDP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - CRC<52><43><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ܡ<EFBFBD><DCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
|
||||
switch(Data_Conver_To_Uint16(&data[US_CMD_L]))
|
||||
{
|
||||
case UDP_Server_CMD_Search:
|
||||
UDP_Server_CMD_Search_Data_Processing(data,len,ip,port);
|
||||
break;
|
||||
case UDP_Server_CMD_Register:
|
||||
UDP_Server_CMD_Register_Data_Processing(data,len,ip,port);
|
||||
break;
|
||||
case UDP_Server_CMD_Heartbeat: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>ظ<EFBFBD>
|
||||
UDP_Server_CMD_Heartbeat_ReplyData_Processing(data,len,ip,port);
|
||||
break;
|
||||
case UDP_Server_CMD_Change_Report: //<2F><><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD>ϱ<EFBFBD><CFB1>ظ<EFBFBD>
|
||||
UDP_Server_CMD_Change_Report_ReplyData_Processing(data,len,ip,port);
|
||||
break;
|
||||
case UDP_Server_CMD_Control_Dev:
|
||||
UDP_Server_CMD_Control_Dev_Data_Processing(data,len,ip,port);
|
||||
break;
|
||||
case UDP_Server_CMD_Starter_Test:
|
||||
UDP_Server_CMD_Starter_Test_Data_Processing(data,len,ip,port);
|
||||
break;
|
||||
case UDP_Server_CMD_Send_Test_Data:
|
||||
UDP_Server_CMD_Send_Test_ReplyData_Processing(data,len,ip,port);
|
||||
break;
|
||||
case UDP_Server_CMD_Read_RCU_Data:
|
||||
|
||||
break;
|
||||
default:
|
||||
Dbg_Println(DBG_BIT_Debug_STATUS_bit,"<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - δ֪<CEB4><D6AA><EFBFBD><EFBFBD>:%04X",Data_Conver_To_Uint16(&data[US_CMD_L]));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
88
BasicCode/Drive/NET_UPDATE/UDPServer_Internal_Protocol.h
Normal file
88
BasicCode/Drive/NET_UPDATE/UDPServer_Internal_Protocol.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef _UDPSERVER_INTERNAL_PROTOCOL_H_
|
||||
#define _UDPSERVER_INTERNAL_PROTOCOL_H_
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/*UDP SERVER SRAM<41>ռ<EFBFBD><D5BC>滮*/
|
||||
#define SRAM_UDP_Server_Data_Start_Address 0x300000
|
||||
#define SRAM_UDP_Server_Data_End_Address 0x37FFFF
|
||||
#define SRAM_UDP_Server_Data_Size 0x080000
|
||||
|
||||
//Ԥ<><D4A4>256Byte,<2C><>ʱû<CAB1><C3BB>
|
||||
#define SRAM_UDP_Server_NowTXData_Addr 0x300100 //<2F><>ǰ<EFBFBD><C7B0><EFBFBD>ݵ<EFBFBD>ַ
|
||||
#define SRAM_UDP_Server_ReadTXData_Addr 0x300104 //<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ݵ<EFBFBD>ַ
|
||||
#define SRAM_UDP_Server_WriteTXData_Addr 0x300108 //д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
||||
/*<2A><><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>ַ*/
|
||||
#define SRAM_UDP_Server_DataBuff_Size 0x280 //640Byte - 249<34><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define SRAM_UDP_Server_TXDataBuff_Start_Address 0x301000
|
||||
#define SRAM_UDP_Server_TXDataBuff_End_Address 0x328000
|
||||
|
||||
#define UDP_Server_DataLen_Max 550 //<2F><><EFBFBD><EFBFBD><EFBFBD>550Byte
|
||||
#define UDP_Server_DataRetry_Max 10 //<2F>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define UDP_Server_DataSendWait_Max 1000 //<2F><><EFBFBD>͵ȴ<CDB5>Ӧ<EFBFBD><D3A6>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC>λ<EFBFBD><CEBB>ms
|
||||
|
||||
#define UDP_Server_Head_L 0xAA
|
||||
#define UDP_Server_Head_H 0x66
|
||||
|
||||
#define UDP_Server_CMD_Search 0x0001 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define UDP_Server_CMD_Register 0x0002 //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define UDP_Server_CMD_Heartbeat 0x0003 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define UDP_Server_CMD_Change_Report 0x0004 //<2F>仯<EFBFBD>ϱ<EFBFBD>
|
||||
#define UDP_Server_CMD_Control_Dev 0x0005 //<2F>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define UDP_Server_CMD_Starter_Test 0x0006 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define UDP_Server_CMD_Send_Test_Data 0x0007 //<2F><><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define UDP_Server_CMD_Read_RCU_Data 0x0008 //<2F><>ȡRCU<43><55><EFBFBD><EFBFBD>
|
||||
|
||||
typedef enum{
|
||||
US_Head_L = 0, //<2F><>ͷ
|
||||
US_Head_H,
|
||||
US_Len_L, //<2F><><EFBFBD><EFBFBD>
|
||||
US_Len_H,
|
||||
US_CRC_L, //CRC16У<36><D0A3>
|
||||
US_CRC_H,
|
||||
US_Frame_L, //֡<><D6A1>
|
||||
US_Frame_H,
|
||||
US_Retry, //<2F>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
US_Encrption, //<2F><><EFBFBD>ܱ<EFBFBD>־
|
||||
US_MACAddr_1, //<2F><><EFBFBD><EFBFBD>MAC<41><43>ַ
|
||||
US_MACAddr_2,
|
||||
US_MACAddr_3,
|
||||
US_MACAddr_4,
|
||||
US_MACAddr_5,
|
||||
US_MACAddr_6,
|
||||
US_CMD_L, //<2F><><EFBFBD><EFBFBD>
|
||||
US_CMD_H,
|
||||
US_Para,
|
||||
}UDPSERVER_Format;
|
||||
|
||||
typedef enum{
|
||||
USS_IDLE,
|
||||
USS_SEND,
|
||||
USS_SENDWAIT,
|
||||
USS_RETRY,
|
||||
|
||||
}UDPSERVER_SEND;
|
||||
|
||||
typedef struct{
|
||||
uint8_t send_state; //״̬
|
||||
uint8_t retry_num; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t encrption; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD>ܱ<EFBFBD>־
|
||||
|
||||
uint8_t test_flag; //<2F><><EFBFBD>Ա<EFBFBD>־λ
|
||||
uint16_t test_num; //<2F><><EFBFBD>Է<EFBFBD><D4B7>ʹ<EFBFBD><CDB4><EFBFBD> - <20>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<EFBFBD><CDBE><EFBFBD>
|
||||
uint16_t test_sn; //<2F><><EFBFBD>Ե<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
||||
uint32_t test_time; //
|
||||
|
||||
uint16_t frame; //֡<><D6A1> - <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
uint16_t rev_frame; //<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>
|
||||
uint32_t send_tick; //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
}__attribute__ ((packed)) UDP_SERVER_Information_t;
|
||||
|
||||
void UDP_Server_Info_Init(void);
|
||||
void UDP_NetServer_Task(void);
|
||||
void UDP_NetServer_Data_Analysis(UINT8 *data, UINT32 len, uint8_t* ip, uint16_t port);
|
||||
|
||||
uint16_t Data_Conver_To_Uint16(uint8_t *data);
|
||||
|
||||
|
||||
#endif
|
||||
1600
BasicCode/Drive/NET_UPDATE/Udp_Internal_Protocol.c
Normal file
1600
BasicCode/Drive/NET_UPDATE/Udp_Internal_Protocol.c
Normal file
File diff suppressed because it is too large
Load Diff
43
BasicCode/Drive/NET_UPDATE/Udp_Internal_Protocol.h
Normal file
43
BasicCode/Drive/NET_UPDATE/Udp_Internal_Protocol.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef _UDP_INTERNAL_PROTOCOL_H_
|
||||
#define _UDP_INTERNAL_PROTOCOL_H_
|
||||
|
||||
#include "net.h"
|
||||
|
||||
|
||||
void Addtion_Regular_Service_State(uint8_t *data,uint8_t type,uint8_t addr,uint16_t loop,uint16_t start);
|
||||
|
||||
void Udp_Internal_GetTime_CMD(void);
|
||||
uint8_t Udp_Internal_GetTime_Process(uint8_t *data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
|
||||
void Udp_Internal_GetRoomRent_CMD(void);
|
||||
uint8_t Udp_Internal_GetRoomRent_Process(uint8_t *data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
|
||||
void Udp_Internal_Reboot_Reason_Report_CMD(void);
|
||||
uint8_t Udp_Internal_Reboot_Reason_Report_Process(uint8_t *data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
|
||||
void Udp_Internal_Power_Change_Report_CMD(void);
|
||||
uint8_t Udp_Internal_Power_Change_Report_Process(uint8_t *data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
|
||||
void Udp_Internal_Periodic_Report_PackSend(void);
|
||||
uint8_t Udp_Internal_Periodic_Report_Process(uint8_t *data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
|
||||
void Udp_Addtion_Roomstate(uint8_t type,uint8_t addr,uint16_t loop,uint16_t start);
|
||||
void Udp_Scan_Roomstate(void);
|
||||
void Udp_Internal_RoomState(void);
|
||||
uint8_t Udp_Internal_RoomState_Process(uint8_t *data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
|
||||
uint8_t Udp_Internal_Read_MCU_System_SendAck(uint8_t *ip,uint16_t port,uint16_t frame_id);
|
||||
uint8_t Udp_Internal_Read_MCU_System_Process(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
uint8_t Udp_Internal_Device_Control_Process(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
uint8_t Udp_Internal_SingleTempCtrl_dis(uint8_t *dat, uint16_t len, uint8_t *ip,uint16_t port);
|
||||
uint8_t Udp_Internal_sys_key(uint8_t *dat, uint16_t len, uint8_t *ip,uint16_t port);
|
||||
uint8_t Udp_Internal_ReadRegister_Process(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
uint8_t Udp_Internal_WriteRegister_Process(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
uint8_t Udp_Internal_BLVPCTest_Process(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
void Udp_Internal_Dev_Control_Processing(void);
|
||||
uint8_t Udp_Internal_RoomRent_Process(uint8_t* data, uint16_t DataLen, uint8_t *ip,uint16_t port);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user