123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730 |
- #include "includes.h"
- POC_DEF sutPocStatus;
- void pocDataInit(void){
- memset((unsigned char *)&sutPocStatus, 0, sizeof(POC_DEF));
- }
- /*鎺у埗鏌ヨ�POC璁剧疆鐘舵€?
- dly:鎺ュ彛琚�皟鐢ㄧ殑棰戠巼锛屽崟浣峬s*/
- void pocProCtl(int dly){
- static unsigned short cnt=0;
- //3绉掓煡璇�竴娆?
- if(sutApp.gtMode!=0) return;//GT妯″紡鍚庝笉鍐嶆煡璇?
- if(++cnt<(5*1000/dly)) return;
- cnt=0;
- //if(getAppObjStatus(ASLEEP_POC)==0) return;//POC浼戠湢鏃讹紝涓嶅彂鎸囦护
- //if(getAppObjStatus(ASLEEP_LCD)==0) return;
-
- //鐢ㄤ簬妫€娴嬪苟璁剧疆POC鍙傛暟
- msgAtSend("AT+COPS?\r\n");
- msgAtSend("AT+CTEC?\r\n");//鏌ヨ�褰撳墠缃戠粶鍒跺紡
- msgAtSend("AT+CSQ\r\n");//鏌ヨ�淇″彿寮哄害
- #ifndef USE_BND_POC
- if(sutApp.pocParaDone==0) msgAtSend("AT+POC=020000\r\n");
- msgAtSend("AT+UDP?\r\n");//鏌ヨ�鍔熻€楃姸鎬?
- msgAtSend("AT+GPIP?\r\nAT+GGIP?\r\n");//鏌ヨ�PIP,GIP
- #endif
- }
- static void micPro(int mic);
- static void spkPro(int spk);
- static void pocStartMsg(void);
- static void pro80Msg(char *msg);
- static void pro81Msg(char *msg);
- static void pro82Msg(char *msg);
- static void pro83Msg(char *msg);
- static void pro84Msg(char *msg);
- static void pro86Msg(char *msg);
- static void pro3dMsg(char *msg);
- static void pro3eMsg(char *msg);
- static void pro0eMsg(char *msg);
- static void pro1eMsg(char *msg);
- static void pro1dMsg(char *msg);
- static void pocGetVer(char *msg);
- static void pocGetPpp(char *msg);
- static void proGauthMsg(char *msg);
- static void proNoteMsg(char *msg);
- static void proNetMode(char *msg);
- static void proSimMode(char *msg);
- static void proPwrMode(char *msg);
- static void proFotaMsg(char *msg);
- static void proGmrMsg(char *msg);
- static void proSmsMsg(char *msg);
- static void proAlarmMsg(void);
- static void proPendMsg(void);
- static void proToneMsg(char *msg);
- static void proGPIPMsg(char *msg);
- static void proGGIPMsg(char *msg);
- static void proCsqMsg(char *msg);
- static void proMicSpk(int mic, int spk);
- static void proCopsMsg(char *msg);
- static void proHeadSet(char *msg);
- static void ProGetMicLV(char *msg,int len);
- void cmdsProcess(char *msg, int len){//宸插幓鎺夊洖杞︽崲琛?
- int i,j;
- char buf[10];
- if(sutApp.pocInitStatus==0) sutApp.pocInitStatus=1;
- if(sutApp.gtMode==0){
- //appSleepCtl(ASLEEP_POC, 1);
- tryWakeupApp();
- MSG_INFO(1,"POC:%s",msg);
-
- if(msgCmp(msg, "+POC:WAKEUP")){//POC鍞ら啋浜?
- }else if(msgCmp(msg, "+POC:8B")){
- buf[0]=msg[7];buf[1]=msg[8];buf[2]=0;
- i=atoi(buf);
- buf[0]=msg[9];buf[1]=msg[10];buf[2]=0;
- j=atoi(buf);
- proMicSpk(i, j);
- }else if(msgCmp(msg, "+LSHTTS: END")){
- sutPocStatus.TTS=0;
- }else if(msgCmp(msg, "+HTTS: START")){
- paControl(true);
- sutPocStatus.TTS=1;
- }
- else if(msgCmp(msg, "+CTEC:")) proNetMode(msg+7);
- else if(msgCmp(msg, "+CSQ: ")) proCsqMsg(msg+6);
- else if(msgCmp(msg, "+COPS:")) proCopsMsg(msg);
- else if(msgCmp(msg, "+CPIN: READY")) sutApp.cardStatus=1;
- else if(msgCmp(msg, "+SIMCROSS"))proSimMode(msg+10);
- else if(msgCmp(msg, "SV")) strcpy(sutApp.modemVer, msg);
- else if(msgCmp(msg,"+CACCP:"))ProGetMicLV(msg,len);
- else MSG_INFO(1, "skip:%d,%s", len,msg);
-
- }
- }
- //澶勭悊POC妯″潡淇℃伅
- void pocCmdHandler(unsigned char *msg, int len){
- //鏈夋秷鎭�繘鏉ワ紝濡傛灉涓嶆槸+POC:SLEEP锛孭OC閮藉敜閱掍簡
- static char tmp[300],ch;
- static int k=0;
- unsigned int j;
- if(sutApp.authReady==0) return;
- if(sutApp.gtMode !=0 && sutApp.gtTMode != 0){
- //MSG_INFO(1,"stop USBsend");
- usbOutPut(msg, len);//TM TRACE
- return;
- }
- for(j=0;j<len;j++){//杩囨护
- if(k>=sizeof(tmp)) k=0;
- tmp[k++]=msg[j];
- if(ch=='\r' && msg[j]=='\n'){
- if(k!=2){
- //澶勭悊
- k -=2;tmp[k]=0;//鍘绘帀鍥炶溅鎹㈣�
- cmdsProcess(tmp,k);
- }
- k=0;
- }
- ch=msg[j];
- }
- }
- static void proMicSpk(int mic, int spk){
- if(mic==0 && spk==0){//0000
- if(newPara.KeySound!=0) pttBeepStart(false);
- sutPocStatus.spk=0;
- sutPocStatus.mic=0;
- sutPocStatus.TONE=0;
- }else if(mic==1 && spk==0){//0100
- if(newPara.KeySound!=0) pttBeepStart(false);
- sutPocStatus.mic=1;
- }else if(mic==0 && spk==1){//0001
- if(newPara.KeySound!=0) paControl(true);//pttBeepStart(false);
- else paControl(true);//鍏抽棴鎻愮ず闊虫椂锛屼篃瑕佹墦寮€鍠囧彮
- sutPocStatus.spk=1;
- sutPocStatus.mic=0;
- }else if(mic==0 && spk==13){//0013
- if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
- }else if(mic==0 && spk==2){
- paControl(true);
- sutPocStatus.TONE=1;
- }
- }
- static void micPro(int mic){
- switch(mic){
- case 0://鍏抽棴mic
- sutPocStatus.mic=0;
- break;
- case 1://鎵撳紑mic
- if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
- sutPocStatus.mic=1;
- //sutPocStatus.spk=0;
- break;
- }
- }
- static void spkPro(int spk){
- switch(spk){
- case 0://tone闊冲悗鍏抽棴spk
- if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
- sutPocStatus.spk=0;
- break;
- case 1://tone闊冲悗淇濇寔spk鎵撳紑
- if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
- paControl(true);
- sutPocStatus.spk=1;
- sutPocStatus.mic=0;
- break;
- case 2://鎾�斁TTS
- paControl(true);
- sutPocStatus.TTS=1;
- break;
- case 13://鎶㈤害澶辫触锛屽彲浠�one鐗规畩闊?
- if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
- break;
- }
- }
- /*POC宸插惎鍔ㄦ垚鍔?*/
- static void pocStartMsg(void){
- sutApp.pocInitStatus=1;
- }
- /*褰撳墠璐﹀彿鎵€灞炵兢缁勫垪琛ㄤ俊鎭?涓€娆℃€ц幏鍙栨墍鏈?
- 涓嶅悓搴旂敤閲囩敤涓嶅悓闇€姹傛寚浠?
- 浠庝笉鍦ㄧ嚎鍒扮櫥褰曚細涓诲姩涓婃姤涓€娆″垪琛?
- 鍙慉T+POC=0D0000涔熶細涓婃姤涓€娆″垪琛?
- msg:000000,iiii(缁勫垪琛ㄧ储寮?,dddddddd(缁処D),nnnn(缁勬垚鍛樻暟),mmmmmm(缁勫悕绉?*/
- static void pro80Msg(char *msg){
-
- }
- /*鎵€鍦ㄧ粍鎴愬憳淇℃伅鍒楄〃
- 鍙慉T+POC=0E0000xxxxxxxx鏌ヨ�
- msg:010000,iiii(鎴愬憳鍒楄〃绱㈠紩),dddddddd(鎴愬憳ID),mmmmmmmm(鎴愬憳鍚嶇О)*/
- static void pro81Msg(char *msg){
-
- }
- /*鐧诲綍鐘舵€佷俊鎭?
- msg:ss(00鏈�櫥褰?02宸茬櫥褰?,dddddddd(鎴愬憳id),mmmmmmmm(鐘舵€佷俊鎭�唴瀹?
- 00 CEDECDF8C2E7C1ACBDD3 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鏃犵綉缁滆繛鎺?鎷ㄥ彿娌?鎴愬姛)
- 00 CEDEB7A8C1ACBDD3 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鏃犳硶杩炴帴(IP 涓嶅�鎴栧畾 鍚戝崱)
- 00 C3BBD3D0B7FECEF1 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?娌℃湁鏈嶅姟(娌℃敞鍐?
- 00 B5C7C2BDCAA7B0DC 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鐧婚檰澶辫触(璐﹀彿閿欒�)
- 00 0D5CBBAC5D0C5CFA2B4EDCEF3 璐﹀彿淇℃伅閿欒�
- 02 0001A750 B2E2CAD431BAC5(娴嬭瘯 1 鍙?,*/
- static void pro82Msg(char *msg){
- char buf[3],*pName;
- int type,len;
- char Username[POC_GROUP_USER_NAME_LEN*2];
- buf[0]=msg[0];buf[1]=msg[1];buf[2]=0;
- type=atoi(buf);
- switch(type){
- case 0:
- sutPocStatus.logined=0;
- if(0==memcmp(msg+10, "CEDECDF8C2E7C1ACBDD3",20)) sutPocStatus.PocLineOffReason=1;
- else if(0==memcmp(msg+10, "CEDEB7A8C1ACBDD3",16)) sutPocStatus.PocLineOffReason=2;
- else if(0==memcmp(msg+10, "C3BBD3D0B7FECEF1",16)) sutPocStatus.PocLineOffReason=3;
- else if(0==memcmp(msg+10, "B5C7C2BDCAA7B0DC",16)) sutPocStatus.PocLineOffReason=4;
- break;
- case 2:
- sutPocStatus.PocLineOffReason=0;
- len=strlen(msg+10);
- if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
- memcpy(Username, msg+10,len);
- Username[len]=0;
- StrAsciiToHex(Username, sutPocStatus.LocalUser.name);
- msg[10]=0;
- sutPocStatus.LocalUser.ID=strtol(&msg[2], &pName, 16);
- MSG_INFO(1, "Login ok");
- sutPocStatus.loginResult=3;
- break;
- }
- }
- /*鏈変汉璇磋瘽
- msg:00,dddddddd(鎴愬憳id),nnnnnnnn(鎴愬憳鍚嶇О)*/
- static void pro83Msg(char *msg){
- int len;
- char callerName[POC_GROUP_USER_NAME_LEN*2];
- backLightReset();//閺€璺哄煂閺堝�姹夌拠纾嬬樈
- len=strlen(msg+10);
- if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
- memcpy(callerName, msg+10,len);
- callerName[len]=0;
- if(0!=memcmp(callerName, sutPocStatus.CallName,len)) StrAsciiToHex(callerName, sutPocStatus.CallName);
- }
- /*鍗曞懠鍝嶅簲淇℃伅
- msg:00,mmmmmmmmmm(鍗曞懠缁撴灉淇℃伅)
- BAF4BDD0B3C9B9A6 琛ㄧず 鍛煎彨鎴愬姛
- BAF4BDD0CAA7B0DC 琛ㄧず 鍛煎彨澶辫触
- CDCBB3F6C1D9CAB1BAF4BDD0 琛ㄧず 閫€鍑轰复鏃跺懠鍙?
- C1D9CAB1BAF4BDD031BAC5BBFA 琛ㄧず 涓存椂鍛煎彨 1 鍙锋満*/
- static void pro84Msg(char *msg){
- //unsigned char danhureport[POC_GROUP_USER_NAME_LEN+1];
- //StrAsciiToHex(msg+2, danhureport);
- ttsPlay(ENCODE_USER_GBK, msg+2);
- if(0==memcmp(msg+2, "C1D9CAB1", 8)) sutPocStatus.danHuStatus=1;
- else if(0==memcmp(msg+2, "CDCBB3F6", 8)) sutPocStatus.danHuStatus=0;
- else if(0==memcmp(msg+2, "BAF4BDD0B3C9B9A6", 16)) sutPocStatus.danHuStatus=1;
- }
- /*鍒囨崲缇ょ粍瀹屾垚鎸囦护(琛ㄧず宸茬櫥褰?
- msg:00,dddddddd(缁刬d),nnnnnnnn(缁勫悕绉?*/
- static void pro86Msg(char *msg){
- char buf[POC_GROUP_USER_NAME_LEN*4+40],*pName;
- int len,i;
- char GroupName[POC_GROUP_USER_NAME_LEN*2];
- char tmp[POC_GROUP_USER_NAME_LEN*2+20];
- char needTTs=0;
-
- sutPocStatus.logined=1;
- len=strlen(msg+10);
- if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
- memcpy(GroupName, msg+10,len);
- GroupName[len]=0;
- msg[10]=0;
- sutPocStatus.LocalGroup.ID=strtol(msg+2, &pName,16);
- StrAsciiToHex(GroupName, sutPocStatus.LocalGroup.name);
- if(sutPocStatus.firstLogin==0){
- snprintf(tmp, sizeof(tmp), "%s,已登录,%s", sutPocStatus.LocalUser.name,sutPocStatus.LocalGroup.name);
- backLightReset();//绗�竴娆$櫥褰曟椂锛屼繚鎸佸睆浜�捣鏉?
- needTTs=1;
- }else{
- snprintf(tmp, sizeof(tmp), "进入,%s",sutPocStatus.LocalGroup.name);
- if(sutApp.groupTTSEnable!=0){
- needTTs=1;
- sutApp.groupTTSEnable=0;
- }
- }
- if(needTTs!=0){
- memset(buf, 0, sizeof(buf));
- for(i=0;i<strlen(tmp);i++){
- snprintf(GroupName, sizeof(GroupName), "%02x", tmp[i]);
- strcat(buf, GroupName);
- }
- ttsPlay(ENCODE_USER_GBK, buf);
- }
- sutPocStatus.danHuStatus=0;
- sutPocStatus.firstLogin=1;
- }
- /*鏌ヨ�鎵€灞炵兢缁勬€绘暟鐨勫搷搴?
- 鍙慉T+POC=3D0000鑾峰緱
- msg:000000,nnnn(鎵€灞炲�灏戜釜缇ょ粍)*/
- static void pro3dMsg(char *msg){
- char *pName;
- sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
- sutPocStatus.ListUpdate=1;
- MSG_INFO(1, "groupNum:%d", sutPocStatus.ListCurOnlineNum);
- }
- /*鏌ヨ�鎵€灞炲湪绾挎垚鍛樻€绘暟鐨勫搷搴?
- 鍙慉T+POC=3E0000鑾峰緱
- msg:000000,nnnn(鎵€灞炲�灏戜釜鍦ㄧ嚎鎴愬憳)*/
- static void pro3eMsg(char *msg){
- char *pName;
- sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
- sutPocStatus.ListUpdate=1;
- MSG_INFO(1, "userNum:%d", sutPocStatus.ListCurOnlineNum);
- }
- /*鏌ヨ�鎵€鍦ㄧ粍鎴愬憳淇℃伅鏃惰繑鍥烇紝寰楀埌鍦ㄧ嚎鎴愬憳鎬绘暟
- msg:000000,nnnn(鍦ㄧ嚎鎴愬憳鎬绘暟)*/
- static void pro0eMsg(char *msg){
-
- }
- /*瀹氶噺鏌ヨ�鎵€鍦ㄧ兢缁勪腑鐨勫湪绾挎垚鍛樹俊鎭�搷搴?
- 鍙慉T+POC=1E0000xxxxx鑾峰緱
- msg:010000,iiii(鎴愬憳鍒楄〃绱㈠紩),dddddddd(鎴愬憳ID),mmmmmmmm(鎴愬憳鍚嶇О)*/
- static void pro1eMsg(char *msg){
- char name[POC_GROUP_USER_NAME_LEN*2+1];
- int len;
- unsigned long id;
- char *pTemp;
-
- if(!uiAssist.status)return 1;
- len = strlen(&msg[18]);
- if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
- memcpy(name, &msg[18], len);
- name[len]=0;
- msg[18]=0;
- id=strtol(&msg[10],&pTemp,16);
- sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
- if(name[0]==0){
- sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
- sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
- }else StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
- sutPocStatus.ListFillIndex++;
- if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
- sutPocStatus.ListGetOneFlag=1;
- sutPocStatus.ListDetailValid=1;
- }
- }
- /*瀹氭椂鏌ヨ�鎵€灞炵粍淇℃伅
- 鍙慉T+POC=1D0000xxxxx鑾峰緱
- msg:000000,iiii(缁勫垪琛ㄧ储寮?,dddddddd(缁処D),nnnn(鎴愬憳涓�暟),mmmmmmmmm(鍚嶇О)*/
- static void pro1dMsg(char *msg){
- unsigned short num;
- char name[POC_GROUP_USER_NAME_LEN*2+1];
- unsigned long id;
- unsigned short index;
- char *pTemp;
- int len;
- if(!uiAssist.status)return ;
- len = strlen(&msg[22]);//宸插幓鎺夊洖杞︽崲琛?
- if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
- memcpy(name, &msg[22], len);
- name[len]=0;
- msg[22]=0;
- num=strtol(&msg[18],&pTemp,16);
- msg[18]=0;
- id=strtol(&msg[10],&pTemp,16);
-
- sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=id;
- sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].usernum=num;
- if(name[0]==0){
- sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
- sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[1]=0;
- }else
- StrAsciiToHex(name, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
- sutPocStatus.ListFillIndex++;
- if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
- sutPocStatus.ListGetOneFlag=1;
- sutPocStatus.ListDetailValid=1;
- }
- }
- /*
- +POC_VER:01027
- msg=01027
- */
- static void pocGetVer(char *msg){
- snprintf(sutApp.pocVersion, sizeof(sutApp.pocVersion), "%s",msg);
- }
- static void pocGetPpp(char *msg){
- if(msg[0]=='1') sutApp.pocPpp=1;
- else sutApp.pocPpp=0;
- }
- /*
- +GAUTH:AD86EBCCECC4
- msg=AD86EBCCECC4+鍥炶溅
- */
- static void proGauthMsg(char *msg){
- unsigned char newAuthTable[10]={0x50,0x28,0xaf,0x6d,0x08,0x9c,0x1b,0xe4,0x23,0x77};
- unsigned char randBuf[100];
-
- char buf[3];
- int len,i,j;
- len=0;
- for(i=0;i<strlen(msg);i++){
- if(msg[i]=='\r' || msg[i]=='\n' || msg[i]=='\0') goto MSG_DONE;
- randBuf[len++]=msg[i];
- }
- MSG_DONE:
- //鑾峰彇涓插苟杞�崲鎴?6杩涘埗鍔犲瘑涓?
- if(len%2 || 0!=restoreDataFormatByHex(randBuf,len)){
- MSG_WARN(1, "auth get error");
- return;
- }
- len /= 2;//寰楀埌鍔犲瘑淇℃伅:闀垮害涓簂en鐨剅andBuf
- extCodeBuffer(randBuf, len,newAuthTable, sizeof(newAuthTable));
- snprintf(randBuf, sizeof(randBuf), "AT+SAUTH=");
- //灏嗛暱搴︿负i鐨則mp鍐呭瓨浠ュ崄鍏�繘鍒朵覆鎵撳寘鍙戦€?
- for(j=0;j<sizeof(newAuthTable);j++){
- snprintf(buf, sizeof(buf),"%02x",newAuthTable[j]);
- strcat(randBuf, buf);
- }
- strcat(randBuf, "\r\n");
- msgAtSend(randBuf);
- MSG_INFO(0, randBuf);
- }
- /*
- +NOTE:0,1
- msg=0,1+鍥炶溅
- */
- static void proNoteMsg(char *msg){
- MSG_INFO(1,"authAck:%s",msg);
- }
- /*
- +CTEC: 0,0
- msg=0,0
- */
- static void proNetMode(char *msg){
- unsigned char netModeValue;
- char cmd[30];
- if(msg[0]<'0' || msg[0]>'9') return;
- netModeValue=atoi(msg);
- ctecCurrentSet=netModeValue;
- if(ctecCurrentSet != newPara.netMode){
- snprintf(cmd, sizeof(cmd),"AT+CTEC=%d,%d\r\n", ctecCurrentSet, newPara.netMode);
- msgAtSend(cmd);
- }
- }
- /*
- +COPS: 0,2,"46000",7
- msg=+COPS: 0,2,"46000",7
- */
- static void proCopsMsg(char *msg){
- int i,j=0,codeType;
- char w=0;
- unsigned char netModeValue;
-
- MSG_INFO(1,"enter PORCOPS");
- for(i=0;i<strlen(msg);i++){
- if(msg[i]==','){
- if(++j==3){
- codeType=msg[i+1]-0x30;
- if(codeType==7) codeType=4;
- if(netshowvalue!=codeType) netshowvalue=codeType;
- return;
- }
- }else if(msg[i]=='"'){
- if(++w==1){
- codeType=atoi(msg+i+1);
- if(codeType>0 && codeType != sutApp.copstype) sutApp.copstype=codeType;
- }
- }
- }
-
- }
- /*
- +SIMCROSS:0
- msg=0/1
- */
- static void proSimMode(char *msg){
- unsigned char tmpSim;
-
- tmpSim=msg[0]-0x30;
- if(tmpSim!=0 && tmpSim!=1) return;
- if(tmpSim==1)sutApp.simSel=0;
- else if(tmpSim==0)sutApp.simSel=1;
- }
- /*
- +UDP:0,5,30
- msg=0,5,30
- */
- static void proPwrMode(char *msg){
- int seg1,seg2;
- short i;
- char buf[15];
-
- for(i=2;i<strlen(msg);i++){
- if(msg[i]==','){
- seg1=atoi(msg+2);
- seg2=atoi(msg+i+1);
- pwrModeAckHandler(seg1,seg2);
- }
- }
- }
- /*
- +FOTA:1,0
- +FOTA:1,XXX
- +FOTA:0
- +FOTA:1
- +FOTA:2
- msg=1,xxxx
- */
- static void proFotaMsg(char *msg){
- if(msg[1]==','){
- if(msg[2]=='0' && msg[3]==0){
- fotaStepSet(6);
- }else{
- strcpy(sutApp.fotaVersion, msg+2);
- fotaStepSet(9);
- }
- }else if(msg[1]==0){
- if(msg[0]=='0'){
- fotaStepSet(7);
- }else if(msg[0]=='1') showLoading();
- else if(msg[0]=='2'){
- fotaStepSet(8);
- }
- }
- }
- /*
- SV63302_T02
- msg=SV63302_T02
- */
- static void proGmrMsg(char *msg){
- snprintf(sutApp.modemVer, sizeof(sutApp.modemVer), "%s", msg);
- }
- /*
- +SMS:1,B2E2CAD4313233
- msg=1,B2E2CAD4313233
- */
- static void proSmsMsg(char *msg){
- unsigned char smsType=msg[0]-0x30;
- unsigned len=strlen(msg+2);
- if(len%2 || 0!=restoreDataFormatByHex(msg+2,len)){
- MSG_WARN(1, "sms data error");
- return;
- }
- len /= 2;
- sutMess.codeType=smsType;
- sutSms.smsUpdate=1;
- memcpy(sutMess.GBKMess1+4, msg+2, len);
- }
- /*鏈嶅姟鍣ㄦ姤涓嬪彂鎶ヨ�TTS锛孭OC宸叉挱鎶ワ紝鏈�俊鎭�彧鎻愮ず*/
- static void proAlarmMsg(void){
- }
- static void proPendMsg(void){
- MSG_INFO(1, "active auth now");
- msgAtSend("AT+GAUTH\r\n");//鐢ㄤ簬鎺堟潈妫€娴?
- }
- static void proToneMsg(char *msg){
- #ifndef ENABLE_PWM_BEEP
- if(msg[0]=='1'){
- sutPocStatus.TONE=1;
- paControl(true);
- }else if(msg[0]=='0'){
- sutPocStatus.TONE=0;
- }
- #endif
- }
- /*
- +GPIP:183.131.13.10
- msg=183.131.13.10
- */
- static void proGPIPMsg(char *msg){
- if(strlen(msg)<7) return;
- if(strcmp(showPIP, msg)==0) return;
- snprintf(showPIP, sizeof(showPIP), "%s",msg);
- MSG_INFO(1, "updatePIP:%s", showPIP);
- }
- /*
- +GGIP:183.131.13.6
- msg=183.131.13.6
- */
- static void proGGIPMsg(char *msg){
- if(strlen(msg)<7) return;
- if(strcmp(showGIP, msg)==0) return;
- snprintf(showGIP, sizeof(showGIP), "%s",msg);
- MSG_INFO(1, "updateGIP:%s", showGIP);
- }
- /*
- +CSQ: 14,99
- msg=14,99
- */
- static void proCsqMsg(char *msg){
- int csq=atoi(msg);
- if(csq != sutApp.g_iCSQ) sutApp.g_iCSQ=csq;
- }
- /*
- +HEADSET:1
- msg=1
- */
- static void proHeadSet(char *msg){
- switch(msg[0]){
- case '0'://HEADSET CONNECT
- sutApp.earLev=1;
- msgAtSend("AT+AUDCH=1,3\r\n");
- sutApp.pcant=2;
- break;//HEADSET DISCONNECTED
- case '1':
- sutApp.earLev=0;
- msgAtSend("AT+AUDCH=0,0\r\n");
- sutApp.pcant=4;
- break;//HEADSET BTN PRESS
- case '2':
- micPttHandler(1);
- break;//HEADSET BTN RELEASED
- case '3':
- micPttHandler(0);
- break;
- }
- }
- static void ProGetATIMsg(char *msg){strcpy(sutApp.modemVer, msg);}
- static void ProGetMicLV(char *msg,int len){
- char buf[30];
- char NeedSet=0;
- if(len<=8) return;//忽虐掉+CACCP: 指令,否则会无限循环,因为AT+CACCP=0,0,0,.....指令设置后也是返回+CACCP: 指令
- msg[11]=0;
- msg[15]=0;
- if(newPara.VolMicLvCu!=htoi(&msg[9]))NeedSet=1;
- if(newPara.VolMicLvXi!=htoi(&msg[13]))NeedSet=1;
- if(NeedSet==0){
- sutApp.Get_MicLv=1;
- return;
- }
- snprintf(buf, sizeof(buf),"AT+CACCP=0,0,0,\"%02x00%02x00\"\r\n",newPara.VolMicLvCu,newPara.VolMicLvXi);
- msgAtSend(buf);
- MSG_INFO(0,buf);
- }
- char *ohpocGetICCID(void){
- return NULL;
- }
- char *ohpocGetIMEI(void){
- static char imei[16]={0};
- if(imei[0]==0){
- if(LSAPI_SIM_GetIMEI(imei)==0){
- return imei;
- }
- }
- return NULL;
- }
- void ohpocGetClock(MY_CLOCK *myclock){
- current_zone_time(myclock);
- }
- unsigned long htoi(char s[])
- {
- int i = 0;
- unsigned long long n = 0;
- if (s[0] == '0' && (s[1]=='x' || s[1]=='X')) i = 2;
- else i = 0;
- for (; (s[i] >= '0' && s[i] <= '9') || (s[i] >= 'a' && s[i] <= 'z') || (s[i] >='A' && s[i] <= 'Z');++i){
- if (tolower(s[i]) > '9') n = 16 * n + (10 + tolower(s[i]) - 'a');
- else n = 16 * n + (tolower(s[i]) - '0');
- }
- return n;
- }
|