|
|
@@ -3,7 +3,7 @@
|
|
|
#include "onechip_include_header.h"
|
|
|
|
|
|
|
|
|
-char DeviceNum[64] = "mini7 2312230001 v1.1, ";
|
|
|
+char DeviceNum[60] = "mini7 2312230001 v1.1, ";
|
|
|
uint8_t pc_send_wait = 0; //数据发送等待,0可以立即发送;>0正在发送请等待
|
|
|
uint8_t pc_send_cmd = 0; //当前发送cmd
|
|
|
|
|
|
@@ -94,6 +94,42 @@ int data_send_to_pc(pc_cmd_type cmd, char *data, unsigned short len)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+int data_send_to_pc_withindex(pc_cmd_type cmd, char *data, unsigned short len, unsigned char index)
|
|
|
+{
|
|
|
+ uint16_t check;
|
|
|
+ int ret = -1;
|
|
|
+ msg.head = 0x55aa;
|
|
|
+ msg.seq = index;
|
|
|
+ msg.cmd = cmd;
|
|
|
+ msg.tail = 0x5a;
|
|
|
+ msg.len = len;
|
|
|
+ msg.data = data;
|
|
|
+
|
|
|
+
|
|
|
+ check = checkSum((const unsigned char *)&msg.seq, 4);
|
|
|
+ check += checkSum((const unsigned char *)data, len);
|
|
|
+ msg.checksum = check & 0xFF;
|
|
|
+ msg.tail = (check >> 8);
|
|
|
+ if(check_to_pc_busy()){
|
|
|
+ memcpy(&wifi_tx_buf[0], (uint8_t*)&msg, MSG_CMDFRAME_LEN);
|
|
|
+ memcpy(&wifi_tx_buf[MSG_CMDFRAME_LEN], data, len);
|
|
|
+ memcpy(&wifi_tx_buf[MSG_CMDFRAME_LEN+len], (uint8_t*)&check, 2);
|
|
|
+ wifi_tx_len = MSG_CMDFRAME_LEN+len+2;
|
|
|
+ }else{
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ if((sysinf.pc_channel_recv == PC_CONNECT_TYPE_WIFI || cmd == PC_CMD_SETIP ) && PC_CMD_SETWIFI != cmd)
|
|
|
+ {
|
|
|
+ return WIFI_ReSend();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Van_Debug_UART_Send_DMA((unsigned char *)wifi_tx_buf, wifi_tx_len); //将收到的信息发送出
|
|
|
+ memset(wifi_tx_buf, 0, sizeof(wifi_tx_buf));
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
void PackDeviceNum(void){
|
|
|
int len = 0;
|
|
|
@@ -153,7 +189,14 @@ void send_Devinf_pc(void)
|
|
|
int handshake_action(unsigned char cmd, unsigned char *parg)
|
|
|
{
|
|
|
|
|
|
- sysinf.system_OnlineFlag = true;
|
|
|
+ sysinf.system_OnlineFlag = true;
|
|
|
+ unsigned int verAddr = FLASH_APP1_ADDR + FLASH_APP_VERSION_OFFSET;
|
|
|
+ PackDeviceNum();
|
|
|
+ if(*(uint32_t *)(verAddr) == 0xffffffff){
|
|
|
+ /*首次上电,跟新版本号*/
|
|
|
+ unsigned int len = strlen(DeviceNum);
|
|
|
+ Flash_WriteBuffer(verAddr, (uint8_t *)DeviceNum, len);
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -288,9 +331,8 @@ int default_pc_response(CmdMessage *pMsg, unsigned char result)
|
|
|
int handshake_response(CmdMessage *pMsg, unsigned char result)
|
|
|
{
|
|
|
unsigned short len = 0;
|
|
|
- PackDeviceNum();
|
|
|
len = strlen(DeviceNum);
|
|
|
- return data_send_to_pc((pc_cmd_type)pMsg->cmd, (char*)DeviceNum, len);
|
|
|
+ return data_send_to_pc_withindex((pc_cmd_type)pMsg->cmd, (char*)DeviceNum, len,pMsg->seq);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -460,6 +502,54 @@ int set_IP_action(uint8_t cmd, uint8_t *parg)
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
+int start_update_app_action(uint8_t cmd, uint8_t *parg)
|
|
|
+{
|
|
|
+
|
|
|
+ iap_load_app(FLASH_BOOTLOAD_ADDR);
|
|
|
+ return 0;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/********************************************************************
|
|
|
+ * uint16_t send_Devinf_pc(void)
|
|
|
+ *
|
|
|
+ *描述:发送设备信息到主机,便于主机下法TCP信息
|
|
|
+ *参数:无
|
|
|
+ *返回:无
|
|
|
+ *其他:无
|
|
|
+ *--------------------------------------------------------------------
|
|
|
+ *记录:
|
|
|
+ ********************************************************************/
|
|
|
+void start_update_app_response(CmdMessage *pMsg, uint8_t result)
|
|
|
+{
|
|
|
+
|
|
|
+ uint16_t len = 0;
|
|
|
+ len = strlen(DeviceNum);
|
|
|
+ data_send_to_pc(PC_CMD_STARTUPDATE,DeviceNum,len);
|
|
|
+
|
|
|
+}
|
|
|
+int updateInfo_action(uint8_t cmd, uint8_t *parg)
|
|
|
+{
|
|
|
+
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+int updateDate_action(uint8_t cmd, uint8_t *parg)
|
|
|
+{
|
|
|
+
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+int updateDate_response(CmdMessage *pMsg, unsigned char result)
|
|
|
+{
|
|
|
+
|
|
|
+ unsigned char *data = (unsigned char *)pMsg->data;
|
|
|
+ *(unsigned int *)(data+4) = *(unsigned int *)data;
|
|
|
+ *(unsigned int *)(data+8) = result;
|
|
|
+ return data_send_to_pc((pc_cmd_type)pMsg->cmd, pMsg->data, 12);
|
|
|
+}
|
|
|
+
|
|
|
int send_temp_parm(uint8_t cmd, uint8_t *parg)
|
|
|
{
|
|
|
/*设置温度*/
|
|
|
@@ -557,6 +647,27 @@ const struct PCActionPack mPCActionPack[] =
|
|
|
.datalen = 0xff,
|
|
|
},
|
|
|
|
|
|
+ {
|
|
|
+ .cmd = PC_CMD_STARTUPDATE,
|
|
|
+ .action = start_update_app_action,
|
|
|
+ .response = NULL,
|
|
|
+ .datalen = 0xff,
|
|
|
+ },
|
|
|
+
|
|
|
+ // {
|
|
|
+ // .cmd = PC_CMD_UPDATEINFO,
|
|
|
+ // .action = updateInfo_action,
|
|
|
+ // .response = set_response,
|
|
|
+ // .datalen = 0xff,
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // .cmd = PC_CMD_UPDATEDATA,
|
|
|
+ // .action = updateDate_action,
|
|
|
+ // .response = updateDate_response,
|
|
|
+ // .datalen = 0xff,
|
|
|
+ // },
|
|
|
+
|
|
|
+
|
|
|
};
|
|
|
|
|
|
void pc_resend_del(uint8_t seq){
|