poc(7106).c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. #include "includes.h"
  2. POC_DEF sutPocStatus;
  3. void pocDataInit(void){
  4. memset((unsigned char *)&sutPocStatus, 0, sizeof(POC_DEF));
  5. }
  6. /*�批��亥砭POC霈曄蔭�嗆�?
  7. dly:�亙藁鋡怨��函�憸𤑳�嚗��雿㤈s*/
  8. void pocProCtl(int dly){
  9. //3蝘埝䰻霂V�甈?
  10. static unsigned short cnt=0xfff;
  11. if(sutApp.gtMode!=0) return;//GT璅∪��𦒘��齿䰻霂?
  12. if(++cnt<(5*1000/dly)) return;
  13. cnt=0;
  14. if(getAppObjStatus(ASLEEP_LCD)==0) return;//POC隡𤑳��塚�銝滚���誘
  15. if(sutApp.pocParaDone<=1) msgAtSend("AT+POC=020000\r\n");//�其�璉�瘚见僎霈曄蔭POC��㺭
  16. msgAtSend("AT+COPS?\r\n");
  17. msgAtSend("AT+CTEC?\r\n");//�亥砭敶枏�蝵𤑳��嗅�
  18. msgAtSend("AT+UDP?\r\n");//�亥砭�蠘�㛖𠶖�?
  19. msgAtSend("AT+CSQ\r\n");//�亥砭靽∪噡撘箏漲
  20. msgAtSend("AT+GPIP?\r\nAT+GGIP?\r\n");//�亥砭PIP,GIP
  21. }
  22. char FindIndexBydouhao(char*data,char numb)
  23. {
  24. char i=0,j=0;
  25. while(*data){
  26. if(*data==','){
  27. i++;
  28. if(i==numb)return j;
  29. }
  30. data++;
  31. j++;
  32. }
  33. return 0;
  34. }
  35. static void micPro(int mic);
  36. static void spkPro(int spk);
  37. static void pocStartMsg(void);
  38. static void pro80Msg(char *msg);
  39. static void pro81Msg(char *msg);
  40. static void pro82Msg(char *msg);
  41. static void pro83Msg(char *msg);
  42. static void pro84Msg(char *msg);
  43. static void pro86Msg(char *msg);
  44. static void pro3dMsg(char *msg);
  45. static void pro3eMsg(char *msg);
  46. static void pro0eMsg(char *msg);
  47. static void pro1eMsg(char *msg);
  48. static void pro1dMsg(char *msg);
  49. static void pocGetVer(char *msg);
  50. static void pocGetPpp(char *msg);
  51. static void proGauthMsg(char *msg);
  52. static void proNoteMsg(char *msg);
  53. static void proNetMode(char *msg);
  54. static void proSimMode(char *msg);
  55. static void proPwrMode(char *msg);
  56. static void proFotaMsg(char *msg);
  57. static void proGmrMsg(char *msg);
  58. static void proSmsMsg(char *msg);
  59. static void proAlarmMsg(void);
  60. static void proPendMsg(void);
  61. static void proToneMsg(char *msg);
  62. static void proGPIPMsg(char *msg);
  63. static void proGGIPMsg(char *msg);
  64. static void proCsqMsg(char *msg);
  65. static void proMicSpk(int mic, int spk);
  66. static void proCopsMsg(char *msg);
  67. void cmdsProcess(char *msg, int len){//撌脣縧�匧�頧行揢銵?
  68. int i,j;
  69. char buf[10];
  70. //if(sutApp.pocInitStatus==0) sutApp.pocInitStatus=1;
  71. if(sutApp.gtMode==0){
  72. appSleepCtl(ASLEEP_POC, 1);
  73. tryWakeupApp();
  74. MSG_INFO(1,"POC:%s",msg);
  75. if(msgCmp(msg, "PocSleep")){//POC瘚潭�皝X�?
  76. appSleepCtl(ASLEEP_POC, 0);
  77. }
  78. // else if(msgCmp(msg, "+POC:WAKEUP")){//POC�𠺶��𧢲�?
  79. // }else if(msgCmp(msg, "+POC:8B")){
  80. // buf[0]=msg[9];buf[1]=msg[10];buf[2]=0;
  81. // proSpk(atoi(buf));
  82. // }else if(msgCmp(msg, "+POC:0B")){//+POC:0B000000
  83. // buf[0]=msg[7];buf[1]=msg[8];buf[2]=0;
  84. // proMic(atoi(buf));
  85. // }else if(msgCmp(msg, "+POC:0C00")){
  86. // proMic(3);//敶閖𨺗蝏𤘪�
  87. // }else if(msgCmp(msg, "+LSHTTS: END")){
  88. // sutPocStatus.TTS=0;
  89. // }else if(msgCmp(msg, "+HTTS: START")){
  90. // paControl(true);
  91. // sutPocStatus.TTS=1;
  92. // }
  93. else if(msgCmp(msg, "PTT_") || msgCmp(msg, "GW_")) pocGetVer(msg);
  94. else if(msgCmp(msg, "+POC:02000000")){
  95. //setPocPara(msg+13,len-13);
  96. //sutApp.startPoc=1;
  97. }else if(msgCmp(msg, "+POC:81")) pro81Msg(msg+7);
  98. else if(msgCmp(msg, "+POC:LOGIN")) pro82Msg(msg+7);
  99. else if(msgCmp(msg, "+POC:3D")) pro3dMsg(msg+7);
  100. else if(msgCmp(msg, "+POC:3E")) pro3eMsg(msg+7);
  101. else if(msgCmp(msg, "+POC:80")) pro80Msg(msg+7);
  102. else if(msgCmp(msg, "+POC:1E")) pro1eMsg(msg+7);
  103. else if(msgCmp(msg, "+POC:JOINGRP")) pro86Msg(msg+7);
  104. else if(msgCmp(msg, "+POC:83")) pro83Msg(msg+7);
  105. else if(msgCmp(msg, "+POC:84")) pro84Msg(msg+7);
  106. else if(msgCmp(msg, "+POC:0E")) pro0eMsg(msg+7);
  107. else if(msgCmp(msg, "+POC:1D")) pro1dMsg(msg+7);
  108. // else if(msgCmp(msg, "+POC:0D")) pro0dMsg(msg+7);
  109. // else if(msgCmp(msg, "+POC:28")) pro28Msg(msg);
  110. // else if(msgCmp(msg, "+POC:7F000000")) proVoiceMode(msg+13);
  111. else if(msgCmp(msg, "+CCID: ")) proCCIDMsg(msg+7);
  112. // else if(msgCmp(msg, "$GNRMC"))process_gps_data(msg+7,len-7);
  113. else if(msgCmp(msg, "+CTEC:")) proNetMode(msg+7);
  114. else if(msgCmp(msg, "+CSQ: ")) proCsqMsg(msg+6);
  115. else if(msgCmp(msg, "+COPS:")) proCopsMsg(msg);
  116. else if(msgCmp(msg, "+CPIN: READY")) sutApp.cardStatus=1;
  117. else if(msgCmp(msg, "+SIMCROSS"))proSimMode(msg+10);
  118. else if(msgCmp(msg, "SV")) strcpy(sutApp.modemVer, msg);
  119. // else if(msgCmp(msg,"+CACCP:"))ProGetMicLV(msg);
  120. else MSG_INFO(1, "skip:%d,%s", len,msg);
  121. }
  122. }
  123. //憭��POC璅∪�靽⊥�
  124. void pocCmdHandler(unsigned char *msg, int len){
  125. //�㗇��航��伐�憒��銝齿糓+POC:SLEEP嚗釶OC�賢𤧅�雴�
  126. static char tmp[300],ch;
  127. static int k=0;
  128. unsigned int j;
  129. if(sutApp.authReady==0) return;
  130. if(sutApp.gtMode !=0 && sutApp.gtTMode != 0){
  131. usbOutPut(msg, len);//TM璅∪�銝讠凒�仿�譍�
  132. return;
  133. }
  134. for(j=0;j<len;j++){//餈�誘
  135. if(k>=sizeof(tmp)) k=0;
  136. tmp[k++]=msg[j];
  137. if(ch=='\r' && msg[j]=='\n'){
  138. if(k!=2){
  139. //憭��
  140. k -=2;tmp[k]=0;//�餅��噼膠�Z�
  141. cmdsProcess(tmp,k);
  142. }
  143. k=0;
  144. }
  145. ch=msg[j];
  146. }
  147. }
  148. static void proMicSpk(int mic, int spk){
  149. if(mic==0 && spk==0){//0000
  150. if(newPara.KeySound!=0) pttBeepStart(false);
  151. sutPocStatus.spk=0;
  152. sutPocStatus.mic=0;
  153. sutPocStatus.TONE=0;
  154. }else if(mic==1 && spk==0){//0100
  155. if(newPara.KeySound!=0) pttBeepStart(false);
  156. sutPocStatus.mic=1;
  157. }else if(mic==0 && spk==1){//0001
  158. if(newPara.KeySound!=0) paControl(true);//pttBeepStart(false);
  159. else paControl(true);//�喲𡡒�鞟內�單𧒄嚗䔶�閬��撘���号
  160. sutPocStatus.spk=1;
  161. sutPocStatus.mic=0;
  162. }else if(mic==0 && spk==13){//0013
  163. if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
  164. }else if(mic==0 && spk==2){
  165. paControl(true);
  166. sutPocStatus.TONE=1;
  167. }
  168. }
  169. static void micPro(int mic){
  170. switch(mic){
  171. case 0://�喲𡡒mic
  172. sutPocStatus.mic=0;
  173. break;
  174. case 1://�枏�mic
  175. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  176. sutPocStatus.mic=1;
  177. //sutPocStatus.spk=0;
  178. break;
  179. }
  180. }
  181. static void spkPro(int spk){
  182. switch(spk){
  183. case 0://tone�喳��喲𡡒spk
  184. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  185. sutPocStatus.spk=0;
  186. break;
  187. case 1://tone�喳�靽脲�spk�枏�
  188. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  189. paControl(true);
  190. sutPocStatus.spk=1;
  191. sutPocStatus.mic=0;
  192. break;
  193. case 2://�剜𦆮TTS
  194. paControl(true);
  195. sutPocStatus.TTS=1;
  196. break;
  197. case 13://�a漲憭梯揖嚗�虾隞另one�寞��?
  198. if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
  199. break;
  200. }
  201. }
  202. /*POC撌脣鍳�冽��?*/
  203. static void pocStartMsg(void){
  204. sutApp.pocInitStatus=1;
  205. }
  206. /*敶枏�韐血噡��撅䂿黎蝏��銵其縑�?銝�甈⊥�扯繮�𡝗��?
  207. 銝滚�摨𠉛鍂��鍂銝滚���瘙��隞?
  208. 隞𦒘��函瑪�啁蒈敶蓥�銝餃𢆡銝𦠜𥁒銝�甈∪�銵?
  209. �飊T+POC=0D0000銋煺�銝𦠜𥁒銝�甈∪�銵?
  210. msg:000000,iiii(蝏��銵函揣撘?,dddddddd(蝏�D),nnnn(蝏���䀹㺭),mmmmmm(蝏��蝘?*/
  211. static void pro80Msg(char *msg){
  212. }
  213. /*���函��𣂼�靽⊥��𡑒”
  214. �飊T+POC=0E0000xxxxxxxx�亥砭
  215. msg:010000,iiii(�𣂼��𡑒”蝝W�),dddddddd(�𣂼�ID),mmmmmmmm(�𣂼��滨妍)*/
  216. static void pro81Msg(char *msg){
  217. }
  218. /*
  219. +POC:LOGIN,2,6077024,3000300031000000
  220. */
  221. static void pro82Msg(char *msg){
  222. char buf[3],*pName;
  223. int type,len;
  224. char Username[POC_GROUP_USER_NAME_LEN*2];
  225. buf[0]=msg[0];buf[1]=msg[1];buf[2]=0;
  226. type=atoi(buf);
  227. switch(type){
  228. case 0:
  229. sutApp.reloginStatus=0;
  230. sutPocStatus.logined=0;
  231. if(0==memcmp(msg+10, "CEDECDF8C2E7C1ACBDD3",20)) sutPocStatus.PocLineOffReason=1;
  232. else if(0==memcmp(msg+10, "CEDEB7A8C1ACBDD3",16)) sutPocStatus.PocLineOffReason=2;
  233. else if(0==memcmp(msg+10, "C3BBD3D0B7FECEF1",16)) sutPocStatus.PocLineOffReason=3;
  234. else if(0==memcmp(msg+10, "B5C7C2BDCAA7B0DC",16)) sutPocStatus.PocLineOffReason=4;
  235. break;
  236. case 2:
  237. sutApp.reloginStatus=1;
  238. sutPocStatus.PocLineOffReason=0;
  239. len=strlen(msg+10);
  240. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  241. memcpy(Username, msg+10,len);
  242. Username[len]=0;
  243. StrAsciiToHex(Username, sutPocStatus.LocalUser.name);
  244. msg[10]=0;
  245. sutPocStatus.LocalUser.ID=strtol(&msg[2], &pName, 16);
  246. MSG_INFO(1, "Login ok");
  247. sutPocStatus.loginResult=3;
  248. break;
  249. }
  250. }
  251. /*�劐犖霂渲�
  252. msg:00,dddddddd(�𣂼�id),nnnnnnnn(�𣂼��滨妍)*/
  253. static void pro83Msg(char *msg){
  254. int len;
  255. char callerName[POC_GROUP_USER_NAME_LEN*2];
  256. backLightReset();//��頝箏����瘙厩�蝤讠𧬘
  257. len=strlen(msg+10);
  258. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  259. memcpy(callerName, msg+10,len);
  260. callerName[len]=0;
  261. if(0!=memcmp(callerName, sutPocStatus.CallName,len)) StrAsciiToHex(callerName, sutPocStatus.CallName);
  262. }
  263. /*�訫鐤�滚�靽⊥�
  264. msg:00,mmmmmmmmmm(�訫鐤蝏𤘪�靽⊥�)
  265. BAF4BDD0B3C9B9A6 銵函內 �澆㙈�𣂼�
  266. BAF4BDD0CAA7B0DC 銵函內 �澆㙈憭梯揖
  267. CDCBB3F6C1D9CAB1BAF4BDD0 銵函內 ���箔葩�嗅鐤�?
  268. C1D9CAB1BAF4BDD031BAC5BBFA 銵函內 銝湔𧒄�澆㙈 1 �瑟㦤*/
  269. static void pro84Msg(char *msg){
  270. //unsigned char danhureport[POC_GROUP_USER_NAME_LEN+1];
  271. //StrAsciiToHex(msg+2, danhureport);
  272. if(0==memcmp(msg+2, "C1D9CAB1BAF4BDD0",16)){//銝湔𧒄�澆㙈 XXXX �芰�銝湔𧒄�澆㙈
  273. msg[2+16]=0;
  274. }
  275. ttsPlay(ENCODE_USER_GBK, msg+2);
  276. if(0==memcmp(msg+2, "C1D9CAB1", 8)) sutPocStatus.danHuStatus=1;
  277. else if(0==memcmp(msg+2, "CDCBB3F6", 8)) sutPocStatus.danHuStatus=0;
  278. else if(0==memcmp(msg+2, "BAF4BDD0B3C9B9A6", 16)) sutPocStatus.danHuStatus=1;
  279. }
  280. /*��揢蝢斤�摰峕���誘(銵函內撌脩蒈敶?
  281. msg:00,dddddddd(蝏�d),nnnnnnnn(蝏��蝘?*/
  282. static void pro86Msg(char *msg){
  283. char buf[POC_GROUP_USER_NAME_LEN*4+40],*pName;
  284. int len,i;
  285. char GroupName[POC_GROUP_USER_NAME_LEN*2];
  286. char tmp[POC_GROUP_USER_NAME_LEN*2+20];
  287. char needTTs=0;
  288. sutPocStatus.logined=1;
  289. len=strlen(msg+10);
  290. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  291. memcpy(GroupName, msg+10,len);
  292. GroupName[len]=0;
  293. msg[10]=0;
  294. sutPocStatus.LocalGroup.ID=strtol(msg+2, &pName,16);
  295. StrAsciiToHex(GroupName, sutPocStatus.LocalGroup.name);
  296. if(sutPocStatus.firstLogin==0|| sutApp.reloginTts){
  297. snprintf(tmp, sizeof(tmp), "%s,眒腎翹,%s", sutPocStatus.LocalUser.name,sutPocStatus.LocalGroup.name);
  298. backLightReset();//蝚砌�甈∠蒈敶閙𧒄嚗䔶����鈭株絲�?
  299. needTTs=1;
  300. sutApp.reloginTts=0;
  301. }else{
  302. snprintf(tmp, sizeof(tmp), "輛⻌,%s",sutPocStatus.LocalGroup.name);
  303. if(sutApp.groupTTSEnable!=0){
  304. needTTs=1;
  305. sutApp.groupTTSEnable=0;
  306. }
  307. }
  308. if(needTTs!=0){
  309. memset(buf, 0, sizeof(buf));
  310. for(i=0;i<strlen(tmp);i++){
  311. snprintf(GroupName, sizeof(GroupName), "%02x", tmp[i]);
  312. strcat(buf, GroupName);
  313. }
  314. ttsPlay(ENCODE_USER_GBK, buf);
  315. }
  316. sutPocStatus.danHuStatus=0;
  317. sutPocStatus.firstLogin=1;
  318. }
  319. /*�亥砭��撅䂿黎蝏��餅㺭���摨?
  320. �飊T+POC=3D0000�瑕�
  321. msg:000000,nnnn(��撅𧼮�撠睲葵蝢斤�)*/
  322. static void pro3dMsg(char *msg){
  323. char *pName;
  324. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  325. sutPocStatus.ListUpdate=1;
  326. MSG_INFO(1, "groupNum:%d", sutPocStatus.ListCurOnlineNum);
  327. }
  328. /*�亥砭��撅𧼮銁蝥踵��䀹�餅㺭���摨?
  329. �飊T+POC=3E0000�瑕�
  330. msg:000000,nnnn(��撅𧼮�撠睲葵�函瑪�𣂼�)*/
  331. static void pro3eMsg(char *msg){
  332. char *pName;
  333. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  334. sutPocStatus.ListUpdate=1;
  335. MSG_INFO(1, "userNum:%d", sutPocStatus.ListCurOnlineNum);
  336. }
  337. /*�亥砭���函��𣂼�靽⊥��嗉��痹�敺堒��函瑪�𣂼��餅㺭
  338. msg:000000,nnnn(�函瑪�𣂼��餅㺭)*/
  339. static void pro0eMsg(char *msg){
  340. }
  341. /*摰𡁻��亥砭���函黎蝏�葉��銁蝥踵��䀝縑�臬�摨?
  342. �飊T+POC=1E0000xxxxx�瑕�
  343. msg:010000,iiii(�𣂼��𡑒”蝝W�),dddddddd(�𣂼�ID),mmmmmmmm(�𣂼��滨妍)*/
  344. static void pro1eMsg(char *msg){
  345. char name[POC_GROUP_USER_NAME_LEN*2+1];
  346. int len;
  347. unsigned long id;
  348. char *pTemp;
  349. if(!uiAssist.status)return 1;
  350. len = strlen(&msg[18]);
  351. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  352. memcpy(name, &msg[18], len);
  353. name[len]=0;
  354. msg[18]=0;
  355. id=strtol(&msg[10],&pTemp,16);
  356. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
  357. if(name[0]==0){
  358. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
  359. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
  360. }else StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  361. sutPocStatus.ListFillIndex++;
  362. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  363. sutPocStatus.ListGetOneFlag=1;
  364. sutPocStatus.ListDetailValid=1;
  365. }
  366. }
  367. /*摰𡁏𧒄�亥砭��撅䂿�靽⊥�
  368. �飊T+POC=1D0000xxxxx�瑕�
  369. msg:000000,iiii(蝏��銵函揣撘?,dddddddd(蝏�D),nnnn(�𣂼�銝芣㺭),mmmmmmmmm(�滨妍)*/
  370. static void pro1dMsg(char *msg){
  371. unsigned short num;
  372. char name[POC_GROUP_USER_NAME_LEN*2+1];
  373. unsigned long id;
  374. unsigned short index;
  375. char *pTemp;
  376. int len;
  377. if(!uiAssist.status)return ;
  378. len = strlen(&msg[22]);//撌脣縧�匧�頧行揢銵?
  379. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  380. memcpy(name, &msg[22], len);
  381. name[len]=0;
  382. msg[22]=0;
  383. num=strtol(&msg[18],&pTemp,16);
  384. msg[18]=0;
  385. id=strtol(&msg[10],&pTemp,16);
  386. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=id;
  387. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].usernum=num;
  388. if(name[0]==0){
  389. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
  390. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[1]=0;
  391. }else
  392. StrAsciiToHex(name, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
  393. sutPocStatus.ListFillIndex++;
  394. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  395. sutPocStatus.ListGetOneFlag=1;
  396. sutPocStatus.ListDetailValid=1;
  397. }
  398. }
  399. /*
  400. +POC_VER:01027
  401. msg=01027
  402. */
  403. static void pocGetVer(char *msg){
  404. snprintf(sutApp.pocVersion, sizeof(sutApp.pocVersion), "%s",msg);
  405. }
  406. static void pocGetPpp(char *msg){
  407. if(msg[0]=='1') sutApp.pocPpp=1;
  408. else sutApp.pocPpp=0;
  409. }
  410. /*
  411. +GAUTH:AD86EBCCECC4
  412. msg=AD86EBCCECC4+�噼膠
  413. */
  414. static void proGauthMsg(char *msg){
  415. #if 1
  416. unsigned char newAuthTable[10]={0x50,0x28,0xaf,0x6d,0x08,0x9c,0x1b,0xe4,0x23,0x77};
  417. unsigned char randBuf[100];
  418. char buf[3];
  419. int len,i,j;
  420. len=0;
  421. for(i=0;i<strlen(msg);i++){
  422. if(msg[i]=='\r' || msg[i]=='\n' || msg[i]=='\0') goto MSG_DONE;
  423. randBuf[len++]=msg[i];
  424. }
  425. MSG_DONE:
  426. //�瑕�銝脣僎頧祆揢�?6餈𥕦��惩�銝?
  427. if(len%2 || 0!=restoreDataFormatByHex(randBuf,len)){
  428. MSG_WARN(1, "auth get error");
  429. return;
  430. }
  431. len /= 2;//敺堒��惩�靽⊥�:�踹漲銝槌en��andBuf
  432. extCodeBuffer(randBuf, len,newAuthTable, sizeof(newAuthTable));
  433. snprintf(randBuf, sizeof(randBuf), "AT+SAUTH=");
  434. //撠�鵭摨虫蛹i��mp���隞亙��剛��嗡葡�枏��煾�?
  435. for(j=0;j<sizeof(newAuthTable);j++){
  436. snprintf(buf, sizeof(buf),"%02x",newAuthTable[j]);
  437. strcat(randBuf, buf);
  438. }
  439. strcat(randBuf, "\r\n");
  440. msgAtSend(randBuf);
  441. MSG_INFO(0, randBuf);
  442. #else
  443. #define FACTORY_MARK "PC-TOOL"
  444. #define MODULE_MARK "PC-TEST-TOOL"
  445. unsigned char randBuf[20];
  446. unsigned char tmp[16+16+20];
  447. unsigned char imei[20];
  448. char sendBuf[sizeof(tmp)*2+20]="AT+SAUTH=";
  449. char *fillPtr=sendBuf+9;
  450. char buf[3];
  451. char *imeiPtr;
  452. int len,i,j;
  453. len=0;
  454. for(i=0;i<strlen(msg);i++){
  455. if(msg[i]=='\r' || msg[i]=='\n' || msg[i]=='\0') goto MSG_DONE;
  456. randBuf[len++]=msg[i];
  457. }
  458. MSG_DONE:
  459. //�瑕�銝脣僎頧祆揢�?6餈𥕦��惩�銝?
  460. if(len%2 || 0!=restoreDataFormatByHex(randBuf,len)){
  461. MSG_WARN(1, "auth get error");
  462. return;
  463. }
  464. len /= 2;//敺堒��惩�靽⊥�:�踹漲銝槌en��andBuf
  465. //撖嫣葡餈𥡝��惩��?�惩�撖孵�銝箏��?�箏�+霈曉�ID[32+32+20]
  466. imeiPtr=ohpocGetIMEI();
  467. if(NULL==imeiPtr){
  468. MSG_WARN(1, "imei is not ready");
  469. return;
  470. }
  471. MSG_INFO(1, "IMEI:%s",imeiPtr);
  472. i=strlen(imeiPtr);
  473. if(i>sizeof(imei)){
  474. MSG_ERR(1, "imei buffer overflow:%d",i);
  475. return;
  476. }
  477. memcpy(imei, imeiPtr,i);//敺堒�IMEI�唳旿:�踹漲銝槐��mei
  478. //蝏���讛悅�唳旿
  479. memset(tmp, 0,sizeof(tmp));
  480. memcpy(tmp,FACTORY_MARK,strlen(FACTORY_MARK));
  481. memcpy(tmp+16, MODULE_MARK,strlen(MODULE_MARK));
  482. tmp[32]=i;
  483. memcpy(tmp+33,imei,i);
  484. i=32+1+i;
  485. //雿輻鍂�踹漲銝槌en��andBuf�惩�銝脣笆�踹漲銝槐��mp餈𥡝��惩�
  486. extCodeBuffer(randBuf, len, tmp, i);
  487. //撠�鵭摨虫蛹i��mp���隞亙��剛��嗡葡�枏��煾�?
  488. for(j=0;j<i;j++){
  489. snprintf(buf, sizeof(buf),"%02x",tmp[j]);
  490. *fillPtr++=buf[0];
  491. *fillPtr++=buf[1];
  492. }
  493. *fillPtr++='\r';
  494. *fillPtr++='\n';
  495. *fillPtr++='\0';
  496. msgAtSend(sendBuf);
  497. MSG_INFO(0, sendBuf);
  498. #endif
  499. }
  500. /*
  501. +NOTE:0,1
  502. msg=0,1+�噼膠
  503. */
  504. static void proNoteMsg(char *msg){
  505. MSG_INFO(1,"authAck:%s",msg);
  506. }
  507. /*
  508. +CTEC: 0,0
  509. msg=0,0
  510. */
  511. static void proNetMode(char *msg){
  512. unsigned char netModeValue;
  513. char cmd[30];
  514. if(msg[0]<'0' || msg[0]>'9') return;
  515. netModeValue=atoi(msg);
  516. ctecCurrentSet=netModeValue;
  517. if(ctecCurrentSet != newPara.netMode){
  518. snprintf(cmd, sizeof(cmd),"AT+CTEC=%d,%d\r\n", ctecCurrentSet, newPara.netMode);
  519. msgAtSend(cmd);
  520. }
  521. }
  522. /*
  523. +COPS: 0,2,"46000",7
  524. msg=+COPS: 0,2,"46000",7
  525. */
  526. static void proCopsMsg(char *msg){
  527. int i,j=0,codeType;
  528. for(i=0;i<strlen(msg);i++){
  529. if(msg[i]==','){
  530. if(++j==3){
  531. codeType=msg[i+1]-0x30;
  532. if(codeType==7) codeType=4;
  533. if(netshowvalue!=codeType) netshowvalue=codeType;
  534. return;
  535. }
  536. }
  537. }
  538. }
  539. /*
  540. +SIMCROSS:0
  541. msg=0/1
  542. */
  543. static void proSimMode(char *msg){
  544. unsigned char tmpSim;
  545. tmpSim=msg[0]-0x30;
  546. if(tmpSim!=0 && tmpSim!=1) return;
  547. sutApp.simSel=tmpSim;
  548. }
  549. /*
  550. +UDP:0,5,30
  551. msg=0,5,30
  552. */
  553. static void proPwrMode(char *msg){
  554. int seg1,seg2;
  555. short i;
  556. char buf[15];
  557. for(i=2;i<strlen(msg);i++){
  558. if(msg[i]==','){
  559. seg1=atoi(msg+2);
  560. seg2=atoi(msg+i+1);
  561. pwrModeAckHandler(seg1,seg2);
  562. }
  563. }
  564. }
  565. /*
  566. +FOTA:1,0
  567. +FOTA:1,XXX
  568. +FOTA:0
  569. +FOTA:1
  570. +FOTA:2
  571. msg=1,xxxx
  572. */
  573. static void proFotaMsg(char *msg){
  574. if(msg[1]==','){
  575. if(msg[2]=='0' && msg[3]==0) sutApp.fotaStatus=1;
  576. else{
  577. strcpy(sutApp.fotaVersion, msg+2);
  578. sutApp.fotaStatus=2;
  579. }
  580. }else if(msg[1]==0){
  581. if(msg[0]=='0') sutApp.fotaStatus=3;
  582. else if(msg[0]=='1') sutApp.fotaStatus=4;
  583. else if(msg[0]=='2') sutApp.fotaStatus=5;
  584. }
  585. }
  586. /*
  587. SV63302_T02
  588. msg=SV63302_T02
  589. */
  590. static void proGmrMsg(char *msg){
  591. snprintf(sutApp.modemVer, sizeof(sutApp.modemVer), "%s", msg);
  592. }
  593. /*
  594. +SMS:1,B2E2CAD4313233
  595. msg=1,B2E2CAD4313233
  596. */
  597. static void proSmsMsg(char *msg){
  598. unsigned char smsType=msg[0]-0x30;
  599. unsigned len=strlen(msg+2);
  600. if(len%2 || 0!=restoreDataFormatByHex(msg+2,len)){
  601. MSG_WARN(1, "sms data error");
  602. return;
  603. }
  604. len /= 2;
  605. sutMess.codeType=smsType;
  606. sutSms.smsUpdate=1;
  607. memcpy(sutMess.GBKMess1+4, msg+2, len);
  608. }
  609. /*�滚𦛚�冽𥁒銝见��亥郎TTS嚗釶OC撌脫偘�伐��砌縑�臬蘨�鞟內*/
  610. static void proAlarmMsg(void){
  611. }
  612. static void proPendMsg(void){
  613. MSG_INFO(1, "active auth now");
  614. msgAtSend("AT+GAUTH\r\n");//�其����璉�瘚?
  615. }
  616. static void proToneMsg(char *msg){
  617. #ifndef ENABLE_PWM_BEEP
  618. if(msg[0]=='1'){
  619. sutPocStatus.TONE=1;
  620. paControl(true);
  621. }else if(msg[0]=='0'){
  622. sutPocStatus.TONE=0;
  623. }
  624. #endif
  625. }
  626. /*
  627. +GPIP:183.131.13.10
  628. msg=183.131.13.10
  629. */
  630. static void proGPIPMsg(char *msg){
  631. if(strlen(msg)<7) return;
  632. if(strcmp(showPIP, msg)==0) return;
  633. snprintf(showPIP, sizeof(showPIP), "%s",msg);
  634. MSG_INFO(1, "updatePIP:%s", showPIP);
  635. }
  636. /*
  637. +GGIP:183.131.13.6
  638. msg=183.131.13.6
  639. */
  640. static void proGGIPMsg(char *msg){
  641. if(strlen(msg)<7) return;
  642. if(strcmp(showGIP, msg)==0) return;
  643. snprintf(showGIP, sizeof(showGIP), "%s",msg);
  644. MSG_INFO(1, "updateGIP:%s", showGIP);
  645. }
  646. /*
  647. +CSQ: 14,99
  648. msg=14,99
  649. */
  650. static void proCsqMsg(char *msg){
  651. int csq=atoi(msg);
  652. if(csq != sutApp.g_iCSQ) sutApp.g_iCSQ=csq;
  653. }
  654. /*
  655. +HEADSET:1
  656. msg=1
  657. */
  658. void proHeadSet(char *msg){
  659. switch(msg[0]){
  660. case '0'://HEADSET CONNECT
  661. sutApp.earLev=1;
  662. //msgAtSend("AT+AUDCH=1,3\r\n");
  663. sutApp.pcant=2;
  664. VolMicUpdate();
  665. VolSpkUpdate();
  666. break;//HEADSET DISCONNECTED
  667. case '1':
  668. sutApp.earLev=0;
  669. //msgAtSend("AT+AUDCH=0,0\r\n");
  670. sutApp.pcant=4;
  671. VolMicUpdate();
  672. VolSpkUpdate();
  673. break;//HEADSET BTN PRESS
  674. case '2':
  675. micPttHandler(1);
  676. break;//HEADSET BTN RELEASED
  677. case '3':
  678. micPttHandler(0);
  679. break;
  680. }
  681. }
  682. /*
  683. +CCID: 898604851920C0133569
  684. msg=898604851920C0133569
  685. */
  686. void proCCIDMsg(char *msg){
  687. sutApp.cardStatus=1;
  688. msg[6]=0;
  689. sutApp.copstype=atoi(msg+4);
  690. }
  691. void LogoutOutTimeCheck(unsigned int interval){
  692. //�厩瑪�舘�餈�3����滨蒈敶𤏪���閬�偘�曄蒈敶蓥縑��
  693. static unsigned char lastLoginStatus=0;
  694. static unsigned int cnt=0;
  695. if(sutApp.reloginStatus == lastLoginStatus) return;
  696. if(sutApp.reloginStatus==0){//�勗銁蝥踹��鞉�蝥�
  697. if(++cnt>=(180000/interval)){
  698. cnt=0;
  699. sutApp.reloginTts=1;
  700. }
  701. }else{//�望�蝥踹�銝羓瑪
  702. cnt=0;
  703. }
  704. lastLoginStatus=sutApp.reloginStatus;
  705. }
  706. char *ohpocGetIMEI(void){
  707. static char imei[16]={0};
  708. if(imei[0]==0){
  709. if(LSAPI_SIM_GetIMEI(imei)==0){
  710. return imei;
  711. }
  712. }
  713. return NULL;
  714. }