更改了本地删除设备

This commit is contained in:
haifeng.wang 2025-05-30 12:38:36 +08:00
parent ea04ecf547
commit f5cd347fdd
4 changed files with 149 additions and 100 deletions

View File

@ -130,8 +130,8 @@ void DWIN_ParseFrame(uint8_t c)
printf("\n");
// 触摸按键返回
if(readData.Addr == 0x5000 || readData.Addr == 0x5012 || readData.Addr == 0x5030
|| readData.Addr == 0x5022 || readData.Addr == 0x502C || readData.Addr == 0x502E
if(readData.Addr == 0x5000 || readData.Addr == 0x5012 || readData.Addr == 0x5030|| readData.Addr == 0x9100
|| readData.Addr == 0x5022 || readData.Addr == 0x502C || readData.Addr == 0x502E|| readData.Addr == 0x5038
|| readData.Addr == 0x5032|| readData.Addr == 0x5034|| readData.Addr == 0x5036|| readData.Addr == 0x6F00)
{
LoopBuff_PutItem(&Form_KeyM, (uint8_t *) &readData);
@ -359,19 +359,19 @@ void Form_RefreshGrid2(form_grid2_t *grid)
// 加入队列
LoopBuff_PutItem(&Form_DataM, (uint8_t *) &formData);
}
//boxCnt.count=12;
formData.oper = DWIN_OPER_WRITE;
formData.Addr = 0x9002;
formData.count = 2;
formData.word[0] = htons((boxCnt.count/30)+1);
LoopBuff_PutItem(&Form_DataM, (uint8_t *) &formData);
//boxCnt.count=12;
formData.oper = DWIN_OPER_WRITE;
formData.Addr = 0x9000;
formData.count = 2;
formData.word[0] = htons((topPtr/30)+1);
LoopBuff_PutItem(&Form_DataM, (uint8_t *) &formData);
formData.Addr = 0x9002;
formData.count = 2;
formData.word[0] = htons((boxCnt.count/30)+1);
LoopBuff_PutItem(&Form_DataM, (uint8_t *) &formData);
formData.oper = DWIN_OPER_WRITE;
formData.Addr = 0x9000;
formData.count = 2;
formData.word[0] = htons((topPtr/30)+1);
LoopBuff_PutItem(&Form_DataM, (uint8_t *) &formData);
// 再将备份缓冲作为显示缓冲
for(i = 0; i < 30; i++)
{
@ -687,7 +687,7 @@ void Form_Task(void *p_arg)
"BOX ", "PSN "," BOX ", "PSN "," BOX ", "PSN ");
data.count = strlen(data.str);
DWIN_Refresh(&data);
// data.oper = DWIN_OPER_WRITE;
// data.Addr = gridBox.hdrAddr+0x1000;
// sprintf(data.str, "%6s",
@ -700,7 +700,7 @@ void Form_Task(void *p_arg)
data.oper = DWIN_OPER_WRITE;
data.Addr = 0x6580;
if(dcBuff.configDisplay.ch_en)
strcpy(data.str, " Level-%");
strcpy(data.str, "Level-%");
else
strcpy(data.str, " 液位-%");
data.count = strlen(data.str);
@ -719,7 +719,7 @@ void Form_Task(void *p_arg)
data.oper = DWIN_OPER_WRITE;
data.Addr = 0x6590;
if(dcBuff.configDisplay.ch_en)
strcpy(data.str, "pressure-%");
strcpy(data.str, "pres-MPa");
else
strcpy(data.str, "压力-MPa");
data.count = strlen(data.str);
@ -738,7 +738,7 @@ void Form_Task(void *p_arg)
data.oper = DWIN_OPER_WRITE;
data.Addr = 0x65A0;
if(dcBuff.configDisplay.ch_en)
strcpy(data.str, "Temperature-%");
strcpy(data.str, "Temp-%");
else
strcpy(data.str, "温度-℃");
data.count = strlen(data.str);
@ -1257,8 +1257,8 @@ void Form_RestoreParam()
formData.count = 4;
formData.dword[0] = htonl(dcBuff.configBottle.offlineSeconds);
LoopBuff_PutItem(&Form_DataM, (uint8_t *) &formData);
formData.Addr = 0x5038;
formData.Addr = 0x5038;
formData.count = 2;
formData.dword[0] = htons(dcBuff.configBottle.lora_freq);
LoopBuff_PutItem(&Form_DataM, (uint8_t *) &formData);
@ -1292,9 +1292,9 @@ uint8_t Form_SaveParam()
return 0;
if(!Form_ReadUInt32(0x5020, &offlineSeconds))
return 0;
if(!Form_ReadUInt16(0x5038, &lora_freq))
if(!Form_ReadUInt16(0x5038, &lora_freq))
return 0;
if(emptyPct * 100 != dcBuff.configBottle.emptyPct)
{
dcBuff.configBottle.emptyPct = emptyPct * 100;
@ -1677,8 +1677,8 @@ uint8_t Form_PreQuery()
if(formQuery.func == 1)
{
if(dcBuff.configDisplay.ch_en)
sprintf(formData.str, " %4s %11s %6s %9s %8s %4s %4s %4s %13s %5s %5s %7s",
"Num", " Box_number ", "Percentage", "Press(MPa)", "Temp(¡æ)", "Alarm", "Err", "Offline", " PSN ", "Date", "Time", "Vol(v)");
sprintf(formData.str, " %4s %11s %6s %10s %5s %6s %4s%8s %12s %5s %5s %7s",
"Num", "Box_number", "Per.", "Press(MPa)", "Temp", "Alarm", "Err", "Offline", "PSN ", "Date", "Time", "Vol(v)");
else
sprintf(formData.str, " %4s %11s %6s %9s %8s %4s %4s %4s %13s %5s %5s %7s",
@ -1687,8 +1687,8 @@ uint8_t Form_PreQuery()
else if(formQuery.func == 2)
{
if(dcBuff.configDisplay.ch_en)
sprintf(formData.str, " %5s %5s %11s %10s %8s %6s %9s %8s %4s %4s %13s",
"Data", "Time", " Box_number ", "Level(mmWC)", "m(kg)", "Percent", "Press(MPa)", "Temp(¡æ)", "Alarm", "Err", " PSN ");
sprintf(formData.str, " %5s %5s %10s %7s %6s %8s %11s %5s %6s %4s %13s",
"Data", "Time", "Box_number", "Level", "m(kg)", "Percent", "Press(MPa)", "Temp", "Alarm", "Err", " PSN ");
else
sprintf(formData.str, " %5s %5s %11s %10s %8s %6s %9s %8s %4s %4s %13s",
@ -1719,7 +1719,10 @@ uint8_t Form_PreQuery()
// 切换页面
Form_ClearGrid(&gridQuery);
Form_SwitchPage(17 + (formQuery.func - 1));
if(dcBuff.configDisplay.ch_en)
Form_SwitchPage(67 + (formQuery.func - 1));
else
Form_SwitchPage(17 + (formQuery.func - 1));
// 用于翻页的序号
gridQuery.topPtr = -1;
@ -2524,10 +2527,10 @@ void Form_BOX_PSN()
gridBox.rowCount=boxCnt.count;//
rowCount=gridBox.rowCount;
if(rowCount>30)
{
rowCount=30;
gridBox.rowCount=30;
}
{
rowCount=30;
gridBox.rowCount=30;
}
for(i=0; i<rowCount; i++)
{
sprintf(gridBox.rowStr[row++], "%s 20%02d%02d%02d%02d%03d",
@ -2571,7 +2574,7 @@ void Form_BOX_PSN_D0WN()
}
void Form_BOX_PSN_UP()
{
int i=0;
int16_t rowCount=0;
uint8_t row = 0;
@ -2586,8 +2589,8 @@ void Form_BOX_PSN_UP()
}
Form_RefreshGrid2(&gridBox);
}
@ -2648,7 +2651,7 @@ void Key_Task(void *p_arg)
Form_En_About(); // 显示关于信息
Config_SaveConfig();
}
else if(val == 0x06) // chu¹Þ
else if((val == 0x06)||(val == 0x16)) // chu罐
{
Form_BOX_PSN();
}
@ -2663,6 +2666,11 @@ void Key_Task(void *p_arg)
{
Form_BOX_PSN_D0WN();
}
else if(key.Addr == 0x5038) // chu罐
{
Form_DispMessage("请输入密码!", DWIN_COLOR_GREEN);
DWIN_Touch(1265, 105);
}
else if(key.Addr == 0x5012) // 设置
{
if(val == 1) // 保存参数
@ -2793,6 +2801,43 @@ void Key_Task(void *p_arg)
}
}
}
else if(key.Addr == 0x9100) // PSN输入
{
// if(!Form_ModifyPSN(&key, msg))
// Form_DispMessage(msg, DWIN_COLOR_RED);
// else
if(ntohs(key.dword[0]) == atoi(dcBuff.configDisplay.pwd1))
{
bottleCnt.count = 0;
FRAM_SaveInfo(0, 0, FRAM_SIZE);
if(dcBuff.configDisplay.ch_en)
{
Form_DispMessage("Successfully deleted.", DWIN_COLOR_GREEN);
}
else
{
Form_DispMessage("删除成功!", DWIN_COLOR_GREEN);
}
osDelay(1000);
HAL_NVIC_SystemReset();
}
else
{
if(dcBuff.configDisplay.ch_en)
{
Form_DispMessage("password error!", DWIN_COLOR_GREEN);
}
else
{
Form_DispMessage("密码错误!", DWIN_COLOR_GREEN);
}
}
}
}
}
}

View File

@ -143,16 +143,16 @@ void Modbus_Task(void *p_arg)
// RS485_SendDataByte(Heart_sendBuff, i);
}
if(LoopBuff_GetCount(&Modbus_SendM))
{
// // 取数据
memmove(&Gprs, LoopBuff_GetDataPtr(&Modbus_SendM, Modbus_SendM.info.rdPtr), sizeof(ext_data_t));
LoopBuff_RemoveItems(&Modbus_SendM, 1);
// i = pack_modbus_tran_data(&Gprs);
// if(LoopBuff_GetCount(&Modbus_SendM))
// {
//// // 取数据
// memmove(&Gprs, LoopBuff_GetDataPtr(&Modbus_SendM, Modbus_SendM.info.rdPtr), sizeof(ext_data_t));
// LoopBuff_RemoveItems(&Modbus_SendM, 1);
//// i = pack_modbus_tran_data(&Gprs);
// // TODO: 发送数据到上位机,不等待返回
// RS485_SendDataByte(Modbus_sendBuff, i);
}
//// // TODO: 发送数据到上位机,不等待返回
//// RS485_SendDataByte(Modbus_sendBuff, i);
// }
}
}
@ -163,16 +163,16 @@ void MODBUS_RTU_CMD(modbus_request_t *req)
uint8_t err = 0; // 错误代码
uint8_t len = 0; // 发送数据长度
ext_bottle_t bottleRec;
uint16_t count; // 通信地址
uint16_t count; // 通信地址
// uint16_t reg; // 数据地址
uint16_t cnt; // 数据个数
uint16_t crc;
ext_box_t boxRec;
ext_data_t Gprs;
uint8_t i;
char* psn;
ext_data_t Gprs;
uint8_t i;
char* psn;
// // 检查通信地址
// 添加记录
// 添加记录
// boxCnt.count = 5;
// for(i = 0; i < boxCnt.count; i++)
// {
@ -186,74 +186,70 @@ void MODBUS_RTU_CMD(modbus_request_t *req)
// boxRec.TGGU[8] = '0' + (0 + i) % 100 / 10;
// boxRec.TGGU[9] = '0' + (0 + i) % 10;
// FRAM_BufferWrite(FRAM_BOX_DATA_BASE + sizeof(ext_box_t) * i, (uint8_t *) &boxRec, sizeof(ext_box_t));
// }
// }
// FRAM_SaveInfo(FRAM_BOX_INFO_BASE, (uint8_t *) &boxCnt, sizeof(ext_count_t));
if(req->cmd == 0x02) // 读保持数据
{
cnt = req->index; // 参数个数
cnt = req->index; // 参数个数
memset(&boxRec, 0, sizeof(ext_box_t));
memset(&bottleRec, 0, sizeof(ext_bottle_t));
memset(&bottleRec, 0, sizeof(ext_bottle_t));
boxRec.PSN[0] = req->PSN[0];
boxRec.PSN[1] = req->PSN[1];
boxRec.PSN[2] = req->PSN[2];
boxRec.PSN[3] = req->PSN[3];
boxRec.PSN[4] = req->PSN[4];
boxRec.PSN[5] = req->PSN[5];
bottleRec.PSN[0] = req->PSN[0];
bottleRec.PSN[1] = req->PSN[1];
bottleRec.PSN[0] = req->PSN[0];
bottleRec.PSN[1] = req->PSN[1];
bottleRec.PSN[2] = req->PSN[2];
bottleRec.PSN[3] = req->PSN[3];
bottleRec.PSN[4] = req->PSN[4];
bottleRec.PSN[5] = req->PSN[5];
for(int i=0; i<11; i++)
boxRec.TGGU[i]=req->BOX[i];
boxRec.TGGU[11]=0;
boxRec.TGGU[11]=0;
if(req->index>0)count=req->index-1;
FRAM_BufferWrite(FRAM_BOX_DATA_BASE + sizeof(ext_box_t) * count, (uint8_t *) &boxRec, sizeof(ext_box_t));
FRAM_BufferWrite(FRAM_BOX_DATA_BASE + sizeof(ext_box_t) * count, (uint8_t *) &boxRec, sizeof(ext_box_t));
// // 更新索引信息
bottleRec.lastData = -1;
FRAM_BufferWrite(FRAM_BOTTLE_DATA_BASE + sizeof(ext_bottle_t) * count, (uint8_t *) &bottleRec, sizeof(ext_bottle_t));
bottleRec.lastData = -1;
FRAM_BufferWrite(FRAM_BOTTLE_DATA_BASE + sizeof(ext_bottle_t) * count, (uint8_t *) &bottleRec, sizeof(ext_bottle_t));
// strcpy(boxTGGU[count].TGGU, boxRec.TGGU);
// memmove(boxTGGU[count].PSN, boxRec.PSN, 6);
// boxTGGU[count].recNo = count;
// strcpy(boxPSN[count].TGGU, boxRec.TGGU);
// memmove(boxPSN[count].PSN, boxRec.PSN, 6);
// boxPSN[count].recNo = count;
memset(BUFF2, 0, sizeof(BUFF2));
BUFF2[len++]='L';
BUFF2[len++]='S';
BUFF2[len++] = dcBuff.configBottle.addr; // 从机地址
BUFF2[len++] = 2;//req->cmd; // 命令代码
BUFF2[len++] = 0;
BUFF2[len++] = 1; //LEN
BUFF2[len++] = 1;
if(req->index==req->all)
{
boxCnt.count=req->all;
bottleCnt.count = req->all;
// 计算CRC
crc = MODBUS_RTU_CRC16(BUFF2, len);
crc = htons(crc);
memmove(BUFF2 + len, &crc, 2);
len += 2;
RS485_SendDataByte(BUFF2, len);
if(req->index==req->all)
{
boxCnt.count=req->all;
bottleCnt.count = req->all;
FRAM_SaveInfo(FRAM_BOX_INFO_BASE, (uint8_t *) &boxCnt, sizeof(ext_count_t));
FRAM_SaveInfo(FRAM_BOTTLE_INFO_BASE, (uint8_t *) &bottleCnt, sizeof(ext_count_t));
}
memset(BUFF2, 0, sizeof(BUFF2));
BUFF2[len++]='L';
BUFF2[len++]='S';
BUFF2[len++] = dcBuff.configBottle.addr; // 从机地址
BUFF2[len++] = 2;//req->cmd; // 命令代码
BUFF2[len++] = 0;
BUFF2[len++] = 1; //LEN
BUFF2[len++] = 1;
FRAM_SaveInfo(FRAM_BOTTLE_INFO_BASE, (uint8_t *) &bottleCnt, sizeof(ext_count_t));
osDelay(500);
HAL_NVIC_SystemReset();
}
// 计算CRC
crc = MODBUS_RTU_CRC16(BUFF2, len);
crc = htons(crc);
memmove(BUFF2 + len, &crc, 2);
len += 2;
RS485_SendDataByte(BUFF2, len);
}
else if(req->cmd == 0x05)
{
if(LoopBuff_GetCount(&Modbus_SendM))
else if(req->cmd == 0x05)
{
if(LoopBuff_GetCount(&Modbus_SendM))
{
// 取数据
memmove(&Gprs, LoopBuff_GetDataPtr(&Modbus_SendM, Modbus_SendM.info.rdPtr), sizeof(ext_data_t));
@ -263,9 +259,9 @@ void MODBUS_RTU_CMD(modbus_request_t *req)
// TODO: 发送数据到上位机,不等待返回
RS485_SendDataByte(Modbus_sendBuff, i);
}
}
}
}
@ -318,6 +314,7 @@ void ReadModbus_Task(uint8_t c)
case 3:
BUFF[len]=c;
if(c==2) len++;
else if(c==5)len+=2;
else len=0;
break;
case 4:
@ -345,6 +342,7 @@ void ReadModbus_Task(uint8_t c)
break;
default:
len=0;
break;
}
if((len==0)&&(data_len2>1))
{
@ -355,4 +353,9 @@ void ReadModbus_Task(uint8_t c)
}
data_len2=0;
}
else if(BUFF[3]==5)
{
MODBUS_RTU_CMD((modbus_request_t *) BUFF);
data_len2=0;
}
}

View File

@ -194,7 +194,8 @@ void Ethernet_Config()
if(RF_APP == RF_APP_AJH)
{
// if(!Ethernet_ATCmd("AT+SOCKA1=TCPC,171.88.5.52,8061", "+OK", "+ERR")) // 公司路由器
if(!Ethernet_ATCmd("AT+SOCKA1=TCPC,extra.cd-ls.cn,8061", "+OK", "+ERR"))
// if(!Ethernet_ATCmd("AT+SOCKA1=TCPC,extra.cd-ls.cn,8061", "+OK", "+ERR"))
if(!Ethernet_ATCmd("AT+SOCKA1=TCPC,121.89.205.240,41001", "+OK", "+ERR"))
// if(!Ethernet_ATCmd("AT+SOCKA1=TCPC,data.ajhiot.com,8088", "+OK", "+ERR"))
// if(!Ethernet_ATCmd("AT+SOCKA1=TCPC,114.55.209.85,8088", "+OK", "+ERR")) // data.ajhiot.com
// if(!Ethernet_ATCmd("AT+SOCKA1=TCPC,192.168.0.2,8061", "+OK", "+ERR")) // 直连电脑

View File

@ -741,12 +741,12 @@ void RF_GatewayTask(void *p_arg)
if(RTC_offsetSeconds == 0)
{
printf("\nRTC_offsetSeconds = 0, ignored ...\n");
//apex continue;
// continue;//apex
}
// 处理帧
idx = Ext_Lookup_Bottle_PSN(RF_ProcFrame.srcPSN, bottleCnt.count);
if(idx == -1) continue;
if(idx == -1) continue;
// 是否需要回应ack
if(RF_ProcFrame.mac_ack_req)
{
@ -905,7 +905,7 @@ void RF_TranTask(void *p_arg)
Ethernet_Config();
}
// 掉电有效如果未获取到UTC时间不转发
// 掉电有效如果未获取到UTC时间不转发 //apex
if(RTC_offsetSeconds > 0 && LoopBuff_GetCount(&RF_TranM) > 0 && Ethernet_connected)
{
if(!SFlash_LoadInfo(LoopBuff_GetDataPos(&RF_TranM, RF_TranM.info.rdPtr), (uint8_t *) &Ext_Data_Rec1, sizeof(ext_data_t)))