#include "includes.h" void saveInfoNow(USER_STOR_INFO *info); void cmdSetting(char *msg){ char info[100],buf[50],ipAddr[40]; char needSendAt=0; char needFeedSms=0; char needSaveSys=0; int len,port; unsigned long psn; //if(sutApp.gtMode==0) return;//为了测试,可以写号 if(sutApp.gtTMode!=0){ msgAtSends(msg, strlen(msg)); return; } if(msgCmp(msg, "GT+TM")){ snprintf(info, sizeof(info), "TM Mode:OK\r\n"); needFeedSms=1; sutApp.gtTMode=1; }else if(msgCmp(msg, "GT+PWM=")){ // if(msg[7]>='0' && msg[7]<='9') beepStart(atoi(msg+7)); }else if(msgCmp(msg, "GT+SNET")){ //GT+SNET:TNET=4;GT+SNET:TNET=5; len=GetParaFromStr(msg, "TNET", buf); if(len!=1){ TNET_ERR: snprintf(info, sizeof(info),"GT+SNET:FAIL[PSN Invalid]\r\n"); needFeedSms=1; goto SETTING_END; } psn=atoi(buf); if(psn!=4&&psn!=5) goto TNET_ERR; MSG_INFO(1,"psn=====%d",psn); if(psn!=sutApp.UserInfo.tnet){ sutApp.UserInfo.tnet=psn; saveInfoNow(&sutApp.UserInfo); } snprintf(info,sizeof(info),"GT+SNET:TNET=%d\r\n",psn); needFeedSms=1; }else if(msgCmp(msg, "GT+RNET")){ snprintf(info, sizeof(info),"GT+RNET:TNET=%d;\r\n",sutApp.UserInfo.tnet); needFeedSms=1; }else if(msgCmp(msg, "GT+SZZD")){ len=GetParaFromStr(msg,"ID",buf); if(len<1 || len>15){ snprintf(info, sizeof(info),"GT+SZZD:FAIL[ID Invalid]\r\n"); needFeedSms=1; goto SETTING_END; } strcpy(sutApp.UserInfo.OtherId,buf); if(len<1 || len>19){ snprintf(info, sizeof(info),"GT+SZZD:FAIL[PWD Invalid]\r\n"); needFeedSms=1; goto SETTING_END; } len=GetParaFromStr(msg,"PWD",buf); strcpy(sutApp.UserInfo.OtherPassWord,buf); snprintf(info, sizeof(info),"GT+SZZD:ID=%s;PWD=%s;\r\n",sutApp.UserInfo.OtherId,sutApp.UserInfo.OtherPassWord); needFeedSms=1; saveInfoNow(&sutApp.UserInfo); } else if(msgCmp(msg, "GT+RZZD")){ snprintf(info, sizeof(info),"GT+RZZD:Id=%s;Pwd=%s;\r\n",sutApp.UserInfo.OtherId,sutApp.UserInfo.OtherPassWord); needFeedSms=1; goto SETTING_END; } //unsigned char platform[20]; //unsigned char pFormatMark[20]; else if(msgCmp(msg, "GT+SDOMAIN")){ len=GetParaFromStr(msg,"PLAT",buf); if(len<1 || len>15){ snprintf(info, sizeof(info),"GT+SDOMAIN:FAIL[ID Invalid]\r\n"); needFeedSms=1; goto SETTING_END; } strcpy(sutApp.UserInfo.platform,buf); if(len<1 || len>19){ snprintf(info, sizeof(info),"GT+SDOMAIN:FAIL[PWD Invalid]\r\n"); needFeedSms=1; goto SETTING_END; } len=GetParaFromStr(msg,"MARK",buf); strcpy(sutApp.UserInfo.pFormatMark,buf); snprintf(info, sizeof(info),"GT+SDOMAIN:PLAT=%s;MARK=%s;\r\n",sutApp.UserInfo.platform,sutApp.UserInfo.pFormatMark); needFeedSms=1; saveInfoNow(&sutApp.UserInfo); } else if(msgCmp(msg, "GT+RDOMAIN")){ snprintf(info, sizeof(info),"GT+RDOMAIN:PLAT=%s;MARK=%s;\r\n",sutApp.UserInfo.platform,sutApp.UserInfo.pFormatMark); needFeedSms=1; goto SETTING_END; } SETTING_END: if(needSendAt!=0) msgAtSends(info, strlen(info)); if(needFeedSms!=0) usbOutPut(info, strlen(info)); } //sysini文件处理 #define SYSINI_FILE "sys.ini" SYSINI_HS191X_DEF newPara; char menu_key[6]="502800";//如果资源文件中没有定义服务器菜单密码,则默认使用此密码 char *getMenuKey(void){return menu_key;} static void ttsToBEStr(char *tts, int len){ int i; char tmp[2]; if(len % 4) return; for(i=0;iMAX_SPK_VOL){ newPara.spkVol=6; needsave=1; } if(newPara.gpsEnable!=0){//GPS使能,必需打开布标 MSG_WARN(1, "gpsEnable, force bubiaoEnable"); newPara.bubiaoEnable=1; needsave=1; } if(needsave!=0){ LSAPI_FS_Seek(fd, 0L, LSAPI_FS_SEEK_SET); LSAPI_FS_Write(fd, (unsigned char *)&newPara, sizeof(SYSINI_HS191X_DEF)); //nwy_sdk_fsync(fd); } LSAPI_FS_Close(fd); } //保存PSN文件处理 #define PSN_FILE "m5700_f2" void saveInfoNow(USER_STOR_INFO *info){ int fd; MSG_INFO(1,"%s save start:",PSN_FILE); fd=LSAPI_FS_Open(PSN_FILE, LSAPI_FS_O_RDWR |LSAPI_FS_O_CREAT,0x0); if(fd<0){ MSG_ERR(1,"%s open failed",PSN_FILE); return; } if(info->tnet!=4&&info->tnet!=5){ info->tnet=4; } //淇濆瓨 LSAPI_FS_Seek(fd, 0L, LSAPI_FS_SEEK_SET); LSAPI_FS_Write(fd, (unsigned char *)&sutApp.UserInfo, sizeof(USER_STOR_INFO)); //nwy_sdk_fsync(fd); LSAPI_FS_Close(fd); MSG_INFO(1,"%s save done", PSN_FILE); } void readInfoNow(void){ int fd; fd=LSAPI_FS_Open(PSN_FILE, LSAPI_FS_O_RDONLY,0); if(fd<0){ MSG_ERR(1,"%s open read failed", PSN_FILE); return; } LSAPI_FS_Seek(fd, 0L, LSAPI_FS_SEEK_SET); LSAPI_FS_Read(fd, (unsigned char *)&sutApp.UserInfo, sizeof(USER_STOR_INFO)); LSAPI_FS_Close(fd); MSG_INFO(1, "%s get info:%s,%s",PSN_FILE, sutApp.UserInfo.OtherId, sutApp.UserInfo.OtherPassWord); } void setFactoryParam(void){ // sutApp.account.psn=newPara.defaultPsn; // saveInfoNow(sutApp.account); // MSG_INFO(1, "set factory psn:%d", sutApp.account.psn); } void setPocPara(){ unsigned char Databuf[120]={0}; unsigned char len; char *Addr="0.0.0.0"; snprintf(&Databuf[16], sizeof(Databuf)-16, "addr:%s&user:%s&pass:%s", Addr,sutApp.UserInfo.OtherId,sutApp.UserInfo.OtherPassWord); len=strlen(Databuf+16); snprintf(Databuf, sizeof(Databuf), "AT+POC=setinfo%02x%s",len, Databuf+16); msgAtSend(Databuf); MSG_INFO(1,Databuf); } char showPIP[40]; char showGIP[40];