123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- #include "includes.h"
- const char invalidIp[]="1.1.1.1";
- SYSINI_HS191X_DEF newPara;
- unsigned char UniToGBKIndex;
- char menu_key[6]="502800";//如果资源文件没有定义密码,则默认密码为此
- int newSysiniIndex=-1;
- void testing(void);
- void ShowDetail(void);
- void newSysIniRead(void)
- {
- int len;
- char needsave=0;
- newSysiniIndex=GetFileIndex(SYS_CONFIG);
- if(newSysiniIndex<0){
- printf("%s not found\r\n",SYS_CONFIG);
- return;
- }
- len=GetFileLen(newSysiniIndex);
- if(len<sizeof(SYSINI_HS191X_DEF)){
- printf("%s SYS_CONFIG len err\r\n",SYS_CONFIG);
- printf("len is %d\r\n",sizeof(SYSINI_HS191X_DEF));
- return;
- }
- ReadFileData(newSysiniIndex, 0, sizeof(SYSINI_HS191X_DEF), (unsigned char *)&newPara);
- #if 1
- //ShowDetail();
- validApnNum = 4;
- //要对应有有参数的合法性作判断
- if(newPara.serList.defaultuse>SER_US){
- newPara.serList.defaultuse=SER_HZ;
- needsave=1;
- }
-
- if(newPara.apnList.defaultuse>APN_APN4){
- newPara.apnList.defaultuse=APN_APN1;
- needsave=1;
- }
-
- if(newPara.lcdParaDefaultIndex>=5){
- newPara.lcdParaDefaultIndex=0;
- needsave=1;
- }
-
- if(newPara.gpsTimeIndex>=GPS_TABLE_NUM){
- newPara.gpsTimeIndex=0;
- needsave=1;
- }
-
- if(newPara.pwrMode>=PWR_MODE_NUM){
- newPara.pwrMode=0;
- needsave=1;
- }
-
- if(newPara.PF1Status>1){
- newPara.PF1Status=0;
- needsave=1;
- }
- if(newPara.ConfigFlag==0){//程序更新过了
- // sutGpsCtl.reTryAuthTimes=1;
- // sutGpsCtl.reTryPerSeconds=1;
- newPara.ConfigFlag=1;
- newPara.netMode=4;//强制默认为4G
- needsave=1;
- }else{
- // sutGpsCtl.reTryAuthTimes=3;
- // sutGpsCtl.reTryPerSeconds=15;
- }
-
- getGIPAddr();
- getPIPAddr();
-
- if(newPara.serverMenuPass!=NULL) memcpy(menu_key, newPara.serverMenuPass,6);
- if(needsave != 0) ModifyConfigureFile(0);
- #else
- testing();
- #endif
- }
- void ShowDetail(void)
- {
- char buf[30];
- int len;
- int i;
- printf("Len=%d,%d\r\n",len,sizeof(SYSINI_HS191X_DEF));
- printf("CFlag:%d,Mode:%d,ttsType:%d,ttsMess:%s\r\n",newPara.ConfigFlag,newPara.Mode,newPara.ttsCodeType,newPara.ttsMessage);
- memcpy(buf, newPara.serverMenuPass,6);buf[6]=0;
- printf("pass:%s,SmsFlag=%c,SmdAddr:%x,lcd:%d,%d,%d,%d,%d,useLcd=%d,auth:%d\r\n", buf, newPara.messageResetFlag,newPara.messageNewAddr,newPara.lcdParaList[0],newPara.lcdParaList[1],newPara.lcdParaList[2],newPara.lcdParaList[3],newPara.lcdParaList[4],newPara.lcdParaDefaultIndex,newPara.authType);
- printf("zh pip:%s,gip:%s\r\n", newPara.serList.zh.pip, newPara.serList.zh.gip);
- printf("sd pip:%s,gip:%s\r\n", newPara.serList.sd.pip, newPara.serList.sd.gip);
- printf("ur pip:%s,gip:%s\r\n", newPara.serList.ur.pip, newPara.serList.ur.gip);
- printf("ipfa:%s\r\n", newPara.serList.ipFenFa);
- printf("jiqun:%s\r\n", newPara.serList.jiqun);
- printf("server use:%d\r\n", newPara.serList.defaultuse);
-
- for(i=0;i<4;i++){
- printf("APN%d acc:%s, pass:%s\r\n", i,newPara.apnList.apnList[i].account, newPara.apnList.apnList[i].pass);
- }
- printf("APN def=%d, showflag=%d\r\n", newPara.apnList.defaultuse, newPara.apnList.apnShowFlag);
- printf("netMode:%d\r\n",newPara.netMode);
- }
- void tryToModifyData(void)
- {
- #if 1
- // newPara.lcdParaList[0]=77;
- // newPara.lcdParaList[1]=88;
- // newPara.lcdParaList[2]=99;
- // ModifyConfigureFile();
- SUT_FILE_PAGE_HEAD pageinfo;
-
- pageinfo.mark=FILE_HEAD_END;
- sFlash_Write((unsigned char *)&pageinfo, g_sutFilesList.FileInfo[g_sutFilesList.FileCount-1].FileAddr, sizeof(SUT_FILE_PAGE_HEAD));
- #endif
- }
- void testing(void)
- {
- #if 0
- ShowDetail();
- //tryToModifyData();
- while(1){
- IWDG_ReloadCounter();
- DelayMs(500);
- printf("tick\r\n");
- }
- #endif
- }
- char *getPIPAddr(void)
- {
- char *retAddr=NULL;
- switch(newPara.serList.defaultuse){
- case SER_HZ:retAddr=newPara.serList.zh.pip;break;
- case SER_SD:retAddr=newPara.serList.sd.pip;break;
- case SER_IP:retAddr=(char *)invalidIp;break;
- case SER_JIQUN:retAddr=(char *)invalidIp;break;
- case SER_US:retAddr=newPara.serList.ur.pip;break;
- }
- memset(showPIP, 0,sizeof(showPIP));
- strcpy(showPIP, retAddr);
- return retAddr;
- }
- char buBiaoAddrChange=0;
- char *getGIPAddr(void)
- {
- char *retAddr=NULL;
- switch(newPara.serList.defaultuse){
- case SER_HZ:retAddr=newPara.serList.zh.gip;break;
- case SER_SD:retAddr=newPara.serList.sd.gip;break;
- case SER_IP:break; //IP分发和集群情况时,GPS地址使用集群或IP分发解析后输出的,这里直接返回NULL
- case SER_JIQUN:break;//IP分发和集群情况时,GPS地址使用集群或IP分发解析后输出的,这里直接返回NULL
- case SER_US:retAddr=newPara.serList.ur.gip;break;
- }
- if(retAddr==NULL) showGIP[0]=0;
- else strcpy(showGIP, retAddr);
- buBiaoAddrChange=1;
- return retAddr;
- }
- char *getDOMAINAddr(void)
- {
- char *retAddr=NULL;
- switch(newPara.serList.defaultuse){
- case SER_HZ:break;
- case SER_SD:break;
- case SER_IP:retAddr=newPara.serList.ipFenFa;break;
- case SER_JIQUN:retAddr=newPara.serList.jiqun;break;
- case SER_US:break;
- }
- return retAddr;
- }
|