?? de_encode.c
字號:
#include "config.h"
//將要更新的參數一起保存到tempbuff緩沖區中,并一起存入FLASH。
void update(SetupParam_Item * temp,uint8 * tempBuff)
{
uint8 * p=NULL;
INT16U len=0,moveAddr=0;
GetOmoveAddr(SETUP_PARAMS,SETUP_PARAMS_COUNT,temp->param_ID,&len,&moveAddr);
p=(uint8 *)malloc(len);
if(NULL==p) return;
memset(p,0xFF,len);
if(temp->paramValue_Len>len) temp->paramValue_Len=len;
memcpy(p,temp->pParam_Value,temp->paramValue_Len);
memcpy(tempBuff+moveAddr,p,len);
if(temp->param_ID==0x0402) //低電壓門限值及采樣次數時間
memcpy(Lmt_V_Time,temp->pParam_Value,sizeof(Lmt_V_Time));
else if(temp->param_ID==0x0301) //終端密碼值
memcpy(Password,temp->pParam_Value,sizeof(Password));
else if(temp->param_ID==0x0209) //終端上傳心跳包時間間隔
memcpy(&HeartSlot,temp->pParam_Value,sizeof(HeartSlot));
else if(temp->param_ID==0x0307) //安裝調度屏標志
memcpy(&schedLCD_BuildIn_OK,temp->pParam_Value,sizeof(schedLCD_BuildIn_OK));
else if(temp->param_ID==0x0309) //休眠時間
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
memcpy(buff,temp->pParam_Value,sizeof(buff));
powerdown_settime=(uint16)(buff[0]<<8)+(uint16)buff[1];
}
else if(temp->param_ID==0x030A) //關機時間
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
memcpy(buff,temp->pParam_Value,sizeof(buff));
poweroff_settime=(uint16)(buff[0]<<8)+(uint16)buff[1];
}
else if(temp->param_ID==0x030B) //是否短信提醒
memcpy(&G_RestMsg,temp->pParam_Value,sizeof(G_RestMsg));
else if(temp->param_ID==0x0212) ////當前設置的工作參數
{
uint8 i=0;
memset(cfg_WorkParam.cfg_WorkParamID,0,sizeof(cfg_WorkParam.cfg_WorkParamID));
cfg_WorkParam.cfg_WorkParamID_cou=0;
for(i=0;i<temp->paramValue_Len;i+=2)
{
cfg_WorkParam.cfg_WorkParamID[i/2]=(uint16)(((temp->pParam_Value)[i])<<8)+(uint16)(temp->pParam_Value)[i+1];
cfg_WorkParam.cfg_WorkParamID_cou++;
}
}
else if(temp->param_ID==0x0303) //設置ACC累計時間
{
memcpy(Last_ACC_Mileage+5,temp->pParam_Value,4);
Rst_ACC_Mileage=1;
}
else if(temp->param_ID==0x0304) //設置累計里程
{
memcpy(Last_ACC_Mileage,temp->pParam_Value,4);
Rst_ACC_Mileage=1;
}
else if(temp->param_ID==0x0211) //盲區補傳數據設置
{
uint8 i=0;
if(temp->paramValue_Len>8) temp->paramValue_Len=8;
BlindSection_Cfg=0;
for(i=0;i<temp->paramValue_Len;i++) //temp->paramValue_Len==8
BlindSection_Cfg+=(unsigned long long)(((temp->pParam_Value)[i])<<(8*(8-i-1)));
}
//主中心通訊參數被修改,則更改重連標志
if(temp->param_ID==0x0200||temp->param_ID==0x0201||temp->param_ID==0x0202||temp->param_ID==0x0205)
{
if(Reconn_Flag!=1&&First_Run_Flag==0)
{
T1MAT_Init(Fpclk*((uint32)120), 0, 1, 0, 0, 1); // 120秒鐘定時
Reconn_Flag=1;
}
}
FREE(p);
}
//恢復出廠值函數
uint8 Renew_Initializers(void)
{
uint8 * tempbuff=NULL;
OSMemQuery(IntBuffer_Big,&MemInfo);
if(MemInfo.OSNFree > (uint8)(SETUP_PARAMS_DATASIZE/BlockSize_Big))
{
const uint8 pageLen=0xff;
SetupParam_Item temp;
uint8 itemp=0;
tempbuff=(INT8U *)OSMemGet(IntBuffer_Big,&err);
W25X32_READ_Semphore(GetAddr(SETUP_PARAMS_SEC,0),SETUP_PARAMS_DATASIZE,tempbuff);
// 定位終端當前積分 占用兩個字節
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0000>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x0000;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//定位終端密碼 111111
temp.param_ID=0x0301; //定位終端密碼 111111
for(itemp=0;itemp<sizeof(Password);itemp++)
Password[itemp]=(uint8)(111111>>8*(sizeof(Password)-itemp-1));
temp.pParam_Value=Password;
temp.paramValue_Len=sizeof(Password);
update(&temp,tempbuff);
//APN CMNET
temp.param_ID=0x0200; //APN CMNET
#ifdef _TW_
temp.pParam_Value=(uint8 *)("INTERNET");
temp.paramValue_Len=strlen("INTERNET");
#else
temp.pParam_Value=(uint8 *)("CMNET");
temp.paramValue_Len=strlen("CMNET");
#endif
update(&temp,tempbuff);
//中心域名 v.cheguan.com
temp.param_ID=0x0202;
//temp.pParam_Value=(uint8 *)("v.cheguan.com");
//temp.paramValue_Len=strlen("v.cheguan.com");
temp.pParam_Value=(uint8 *)("www.gttgps.cn");
temp.paramValue_Len=strlen("www.gttgps.cn");
update(&temp,tempbuff);
//主中心IP 空
{
uint8 buff[4];
memset(buff,0,sizeof(buff));
temp.param_ID=0x0201;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//副中心IP 空
{
uint8 buff[4];
memset(buff,0,sizeof(buff));
temp.param_ID=0x0203;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//副中心域名
temp.param_ID=0x0204;
temp.pParam_Value=(uint8 *)("");
temp.paramValue_Len=strlen("");
update(&temp,tempbuff);
//端口號 2000
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(9987>>8*(sizeof(buff)-itemp-1)); //buff[itemp]=(uint8)(9987>>8*(sizeof(buff)-itemp-1));//
temp.param_ID=0x0205;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//車機ID 定位終端的出廠序列號
temp.param_ID=0x0702; //終端硬件序列號 使用ASCII碼表示,長度小于128個字節
temp.pParam_Value=(uint8 *)HardwareSN;
temp.paramValue_Len=strlen(HardwareSN);
update(&temp,tempbuff);
//中心下發心跳間隔 根據終端上傳的心跳間隔或數據間隔
SRV_HeartSlot=120;
temp.param_ID=0x0206; //中心下發心跳間隔 120秒
temp.pParam_Value=(uint8 *)&(SRV_HeartSlot);
temp.paramValue_Len=sizeof(SRV_HeartSlot);
update(&temp,tempbuff);
//定位終端心跳間隔 40秒
HeartSlot=40;
temp.param_ID=0x0209; //定位終端心跳間隔 40秒
temp.pParam_Value=(uint8 *)&HeartSlot;
temp.paramValue_Len=sizeof(HeartSlot);
update(&temp,tempbuff);
#ifdef _TW_
temp.param_ID=0x0103; //短信中心號碼 106380005668
temp.pParam_Value=(uint8 *)("+886987003204");
temp.paramValue_Len=strlen("+886987003204");
update(&temp,tempbuff);
temp.param_ID=0x0102; //短信息服務中心號 +8613800250500
temp.pParam_Value=(uint8 *)("+886987003204");
temp.paramValue_Len=strlen("+886987003204");
update(&temp,tempbuff);
temp.param_ID=0x0101; //電話復位號碼 02586306763
temp.pParam_Value=(uint8 *)("+886987003204");
temp.paramValue_Len=strlen("+886987003204");
update(&temp,tempbuff);
#else
//短信中心號碼 106380005668
temp.param_ID=0x0103; //短信中心號碼 106380005668
temp.pParam_Value=(uint8 *)("106380005668");
temp.paramValue_Len=strlen("106380005668");
update(&temp,tempbuff);
//短信息服務中心號 +8613800250500
temp.param_ID=0x0102; //短信息服務中心號 +8613800250500
temp.pParam_Value=(uint8 *)("+8613800250500");
temp.paramValue_Len=strlen("+8613800250500");
update(&temp,tempbuff);
//電話復位號碼 02586306763
temp.param_ID=0x0101; //電話復位號碼 02586306763
temp.pParam_Value=(uint8 *)("02586306763");
temp.paramValue_Len=strlen("02586306763");
update(&temp,tempbuff);
#endif // end of #ifdef _TW_
//IP方式和SMS方式切換間隔 //1200s
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(1200>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x020F;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//協議版本號 要求根據中心下發的主協議讀取協議版本號
//求助開關觸點方式 常開
//數據日志記錄設置 只根據工作參數上傳設置間隔存儲數據
{//0x02ull:只根據工作參數上傳設置間隔存儲數據
uint8 buff[8];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0x02ull>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x0210;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//盲區補傳數據設置 只根據壓縮數據存儲
/*
{
unsigned long long iii=18446744073709551615ull;
char buff[100];
sprintf(buff,"%llu",iii);
uartWrite(UART3,(uint8 *)buff,strlen(buff),NULL); //測試
}*/
{//0x08ull://3位=1表示:根據壓縮數據存儲
uint8 buff[8];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0x08ull>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x0211;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//上傳工作參數 默認只上傳油位電壓值工作參數(以壓縮方式上傳)
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0x0102>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x0212;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//休眠時間 0
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x0309;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//關機時間 0
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x030A;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//超速報警 255-255
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0xffff>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x0400;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//低速報警 255-255
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0xffff>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x0401;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//低壓報警 255-255
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
for(itemp=0;itemp<sizeof(buff);itemp++)
buff[itemp]=(uint8)(0xffff>>8*(sizeof(buff)-itemp-1));
temp.param_ID=0x0402;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//IP重發次數 2
{
uint8 tempValue=2;
temp.param_ID=0x020B;
temp.pParam_Value=&tempValue;
temp.paramValue_Len=sizeof(tempValue);
update(&temp,tempbuff);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -