#include "includes.h" const char invalidIp[]="1.1.1.1"; SYSINI_HS191X_DEF newPara; 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(lenSER_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.SoundMode>1){ // newPara.SoundMode=0; // needsave=1; // } if(newPara.QuickGroup>1){ newPara.QuickGroup=1; needsave=1; } if(newPara.ConfigFlag==0){ sutGpsCtl.reTryAuthTimes=1; sutGpsCtl.reTryPerSeconds=1; newPara.QuickGroup=1;//0--打开 1--关闭 memset((void*)newPara.QuickGroupId,0,sizeof(newPara.QuickGroupId)); newPara.ConfigFlag=1; 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) { // 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)); } void testing(void) { ShowDetail(); //tryToModifyData(); while(1){ IWDG_ReloadCounter(); DelayMs(500); printf("tick\r\n"); } } 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)); ///printf("defaultuse==%d,pip=%s,retAddr=%s\r\n",newPara.serList.defaultuse,newPara.serList.ur.pip,retAddr); strcpy(showPIP, retAddr); return retAddr; } 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:retAddr=(char *)invalidIp; break; //IP分发和集群情况时,GPS地址使用集群或IP分发解析后输出的,这里直接返回NULL case SER_JIQUN:retAddr=(char *)invalidIp;break;//IP分发和集群情况时,GPS地址使用集群或IP分发解析后输出的,这里直接返回NULL case SER_US:retAddr=newPara.serList.ur.gip;break; } if(retAddr==NULL) showGIP[0]=0; else strcpy(showGIP, retAddr); 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; }