123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- #include "includes.h"
- void cmdSetting(char *msg){
- char info[100],buf[50],ipAddr[40];
- char needSendAt=0;
- char needFeedSms=0;
- int len,port;
- unsigned long psn;
- if(sutApp.gtMode==0) return;
- if(sutApp.gtTMode!=0){
- if(msgCmp(msg, "AT+POC=poccmd1")){
- msgAtSends("AT+POC=poccmd1", strlen("AT+POC=poccmd1"));
- }else msgAtSends(msg, strlen(msg));
- return;
- }
- else 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;i<len/4;i++){
- tmp[0]=tts[4*i];tmp[1]=tts[4*i+1];
- tts[4*i]=tts[4*i+2];
- tts[4*i+1]=tts[4*i+3];
- tts[4*i+2]=tmp[0];
- tts[4*i+3]=tmp[1];
- }
- }
- void sysIniSave(void){
- int fd;
- MSG_INFO(1,"%s save start",SYSINI_FILE);
- fd=LSAPI_FS_Open(SYSINI_FILE, LSAPI_FS_O_RDWR,0x0);
- if(fd<0){
- MSG_ERR(1,"%s open failed",SYSINI_FILE);
- return;
- }
-
- //淇濆瓨
- 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);
- MSG_INFO(1,"%s save done", SYSINI_FILE);
- }
- void sysIniRead(void){
- int fd;
- char needsave=0;
- fd=LSAPI_FS_Open(SYSINI_FILE, LSAPI_FS_O_RDWR,0);
- if(fd<0){
- MSG_ERR(1,"%s open read failed", SYSINI_FILE);
- return;
- }
- LSAPI_FS_Seek(fd, 0L, LSAPI_FS_SEEK_SET);
- LSAPI_FS_Read(fd, (unsigned char *)&newPara, sizeof(SYSINI_HS191X_DEF));
-
- if(newPara.ConfigFlag==0){
- MSG_INFO(1, "First run");
- newPara.ConfigFlag=1;
- needsave=1;
- //妫€娴婽TS鏄�惁鏄疷NICODE锛屾槸鍒欏皢鍏朵粠BE杞�崲涓篖E锛屽悗闈㈠氨鍙�互鐩存帴鎾�斁浜?
- if(newPara.ttsMessage[0]!=0 && newPara.ttsCodeType==0) ttsToBEStr(newPara.ttsMessage, strlen(newPara.ttsMessage));
- newPara.spkVol=6;
- newPara.VolMicLvCu=4;
- newPara.VolMicLvXi=10;
- newPara.pwrMode=1;//智能模式
- newPara.voiceSel=0;//标准音质
-
- }
- if(newPara.serverMenuPass!=NULL) memcpy(menu_key, newPara.serverMenuPass,6);
- //娴嬭瘯寮€濮?
- //newPara.gpsEnable=0;
- //newPara.bubiaoEnable=0;
- //newPara.KeySound=1;
- //娴嬭瘯缁撴潫
-
- if(newPara.spkVol>MAX_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 setPocPara(char *pocPara, int len){
- int k;
- char buf[40];
- char buf1[100];
- char idFlag=0,domainFlag=0,ipFlag=0;
- char gapFlag=0,gportFlag=0;
- char enableChangeIp=1;
- //msgAtSend("AT+POC=0100007077643D3131313131313B00\r\n");
- if(0!=restoreDataFormatByHex(pocPara,len)){
- MSG_ERR(1, "setPocPara get error");
- return;
- }
- k=len/2;
- pocPara[k]=0;
- GetParaFromStr(pocPara, "id", buf);
- if(0!=strcmp(sutApp.UserInfo.OtherId, buf)) idFlag=1;
- if(idFlag==0 && ipFlag==0 && domainFlag==0 && gapFlag==0 && gportFlag==0){
- MSG_INFO(1, "POC still");
- sutApp.pocParaDone=1;
- return;
- }
- idFlag=1;
- if(idFlag!=0){
- snprintf(buf1, sizeof(buf1), "AT+POC=010000");
- snprintf(buf, sizeof(buf), "id=%s;pwd=%s",sutApp.UserInfo.OtherId,sutApp.UserInfo.OtherPassWord);
- AscStrTurnHexStr(buf, buf1+strlen(buf1));
- strcat(buf1, "00\r\n");
- msgAtSend(buf1);
- MSG_INFO(1, "POC reset");
- sutApp.pocParaDone=1;
- }
-
- return;
-
- msgAtSend("AT+POC=010000");
- MSG_INFO(1, "POC reset");
- sutApp.pocParaDone=1;
- }
- char showPIP[40];
- char showGIP[40];
- const char invalidIp[]="1.1.1.1";
- char *getPIPAddr(void){
- char *retAddr=NULL;
- switch(newPara.serList.defaultuse){
- case SERVER_HZ: retAddr=newPara.serList.zh.pip;break;
- case SERVER_SD: retAddr=newPara.serList.sd.pip;break;
- case SERVER_FENFA:retAddr=(char *)invalidIp;break;
- case SERVER_JIQUN:retAddr=(char *)invalidIp;break;
- case SERVER_UR: retAddr=newPara.serList.ur.pip;break;
- }
- memset(showPIP, 0, sizeof(showPIP));
- strcpy(showPIP, retAddr);
- return retAddr;
- }
- char *getGIPAddr(void){
- char *retAddr=NULL;
- switch(newPara.serList.defaultuse){
- case SERVER_HZ: retAddr=newPara.serList.zh.gip;break;
- case SERVER_SD: retAddr=newPara.serList.sd.gip;break;
- case SERVER_FENFA: break;
- case SERVER_JIQUN: break;
- case SERVER_UR: 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 SERVER_HZ:break;
- case SERVER_SD:break;
- case SERVER_FENFA:retAddr=newPara.serList.ipFenFa;break;
- case SERVER_JIQUN:retAddr=newPara.serList.jiqun;break;
- case SERVER_UR:break;
- }
- return retAddr;
- }
|