poc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  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绉掓煡璇�竴娆?
  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. msgToModem("AT+COPS?\r\n");
  17. msgToModem("AT+CTEC?\r\n");//鏌ヨ�褰撳墠缃戠粶鍒跺紡
  18. msgToModem("AT+CSQ\r\n");//鏌ヨ�淇″彿寮哄害
  19. }
  20. char FindIndexBydouhao(char*data,char numb)
  21. {
  22. char i=0,j=0;
  23. while(*data){
  24. if(*data==','){
  25. i++;
  26. if(i==numb)return j+1;//取逗号后一位
  27. }
  28. data++;
  29. j++;
  30. }
  31. return 0;
  32. }
  33. static void micPro(int mic);
  34. static void spkPro(int spk);
  35. static void pocStartMsg(void);
  36. static void pro80Msg(char *msg);
  37. static void pro81Msg(char *msg);
  38. static void pro82Msg(char *msg);
  39. static void pro83Msg(char *msg);
  40. static void pro84Msg(char *msg);
  41. static void pro86Msg(char *msg);
  42. static void pro3dMsg(char *msg);
  43. static void pro3eMsg(char *msg);
  44. static void pro0eMsg(char *msg);
  45. static void pro1eMsg(char *msg);
  46. static void pro1dMsg(char *msg);
  47. static void pocGetVer(char *msg);
  48. static void pocGetPpp(char *msg);
  49. static void proGauthMsg(char *msg);
  50. static void proNoteMsg(char *msg);
  51. static void proNetMode(char *msg);
  52. static void proSimMode(char *msg);
  53. static void proPwrMode(char *msg);
  54. static void proFotaMsg(char *msg);
  55. static void proGmrMsg(char *msg);
  56. static void proSmsMsg(char *msg);
  57. static void proAlarmMsg(void);
  58. static void proPendMsg(void);
  59. static void proToneMsg(char *msg);
  60. static void proGPIPMsg(char *msg);
  61. static void proGGIPMsg(char *msg);
  62. static void proCsqMsg(char *msg);
  63. static void proMicSpk(int mic, int spk);
  64. static void proCopsMsg(char *msg);
  65. void cmdsProcess(char *msg, int len){//宸插幓鎺夊洖杞︽崲琛?
  66. int i,j;
  67. char buf[10];
  68. //if(sutApp.pocInitStatus==0) sutApp.pocInitStatus=1;
  69. if(sutApp.gtMode==0){
  70. appSleepCtl(ASLEEP_POC, 1);
  71. tryWakeupApp();
  72. MSG_INFO(1,"POC:%s",msg);
  73. if(msgCmp(msg, "PocSleep")){//POC娴兼垹婀㈡禍?
  74. appSleepCtl(ASLEEP_POC, 0);
  75. }else if(msgCmp(msg, "+POC:PLAY")) spkPro(atoi(msg+10));
  76. else if(msgCmp(msg, "+POC:reqspk,0")) micPro(1);
  77. else if(msgCmp(msg, "+POC:relspk,0")) micPro(0);
  78. else if(msgCmp(msg, "PTT_") || msgCmp(msg, "GW_")) pocGetVer(msg);
  79. else if(msgCmp(msg, "+POC:02000000")){
  80. //setPocPara(msg+13,len-13);
  81. //sutApp.startPoc=1;
  82. }else if(msgCmp(msg, "+POC:81")) pro81Msg(msg+7);
  83. else if(msgCmp(msg, "+POC:LOGIN")) pro82Msg(msg);
  84. else if(msgCmp(msg, "+POC:3D")) pro3dMsg(msg+7);
  85. else if(msgCmp(msg, "+POC:3E")) pro3eMsg(msg+7);
  86. else if(msgCmp(msg, "+POC:80")) pro80Msg(msg+7);
  87. else if(msgCmp(msg, "+POC:1E")) pro1eMsg(msg+7);
  88. else if(msgCmp(msg, "+POC:JOINGRP")) pro86Msg(msg);
  89. else if(msgCmp(msg, "+POC:SPEAK")) pro83Msg(msg);
  90. else if(msgCmp(msg, "+POC:NOTICE")) pro84Msg(msg);
  91. else if(msgCmp(msg, "+POC:0E")) pro0eMsg(msg+7);
  92. else if(msgCmp(msg, "+POC:1D")) pro1dMsg(msg+7);
  93. // else if(msgCmp(msg, "+POC:0D")) pro0dMsg(msg+7);
  94. // else if(msgCmp(msg, "+POC:28")) pro28Msg(msg);
  95. // else if(msgCmp(msg, "+POC:7F000000")) proVoiceMode(msg+13);
  96. else if(msgCmp(msg, "+CCID: ")) proCCIDMsg(msg+7);
  97. // else if(msgCmp(msg, "$GNRMC"))process_gps_data(msg+7,len-7);
  98. else if(msgCmp(msg, "+CTEC:")) proNetMode(msg+7);
  99. else if(msgCmp(msg, "+CSQ: ")) proCsqMsg(msg+6);
  100. else if(msgCmp(msg, "+COPS:")) proCopsMsg(msg);
  101. else if(msgCmp(msg, "+CPIN: READY")) sutApp.cardStatus=1;
  102. else if(msgCmp(msg, "+SIMCROSS"))proSimMode(msg+10);
  103. else if(msgCmp(msg, "SV")) strcpy(sutApp.modemVer, msg);
  104. // else if(msgCmp(msg,"+CACCP:"))ProGetMicLV(msg);
  105. else MSG_INFO(1, "skip:%d,%s", len,msg);
  106. }
  107. }
  108. //澶勭悊POC妯″潡淇℃伅
  109. void pocCmdHandler(unsigned char *msg, int len){
  110. //鏈夋秷鎭�繘鏉ワ紝濡傛灉涓嶆槸+POC:SLEEP锛孭OC閮藉敜閱掍簡
  111. static char tmp[300],ch;
  112. static int k=0;
  113. unsigned int j;
  114. if(sutApp.authReady==0) return;
  115. if(sutApp.gtMode !=0 && sutApp.gtTMode != 0){
  116. usbOutPut(msg, len);//TM妯″紡涓嬬洿鎺ラ€忎紶
  117. return;
  118. }
  119. for(j=0;j<len;j++){//杩囨护
  120. if(k>=sizeof(tmp)) k=0;
  121. tmp[k++]=msg[j];
  122. if(ch=='\r' && msg[j]=='\n'){
  123. if(k!=2){
  124. //澶勭悊
  125. k -=2;tmp[k]=0;//鍘绘帀鍥炶溅鎹㈣�
  126. cmdsProcess(tmp,k);
  127. }
  128. k=0;
  129. }
  130. ch=msg[j];
  131. }
  132. }
  133. static void proMicSpk(int mic, int spk){
  134. if(mic==0 && spk==0){//0000
  135. if(newPara.KeySound!=0) pttBeepStart(false);
  136. sutPocStatus.spk=0;
  137. sutPocStatus.mic=0;
  138. sutPocStatus.TONE=0;
  139. }else if(mic==1 && spk==0){//0100
  140. if(newPara.KeySound!=0) pttBeepStart(false);
  141. sutPocStatus.mic=1;
  142. }else if(mic==0 && spk==1){//0001
  143. if(newPara.KeySound!=0) paControl(true);//pttBeepStart(false);
  144. else paControl(true);//鍏抽棴鎻愮ず闊虫椂锛屼篃瑕佹墦寮€鍠囧彮
  145. sutPocStatus.spk=1;
  146. sutPocStatus.mic=0;
  147. }else if(mic==0 && spk==13){//0013
  148. if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
  149. }else if(mic==0 && spk==2){
  150. paControl(true);
  151. sutPocStatus.TONE=1;
  152. }
  153. }
  154. static void micPro(int mic){
  155. switch(mic){
  156. case 0://鍏抽棴mic
  157. sutPocStatus.mic=0;
  158. break;
  159. case 1://鎵撳紑mic
  160. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  161. sutPocStatus.mic=1;
  162. //sutPocStatus.spk=0;
  163. break;
  164. }
  165. }
  166. static void spkPro(int spk){
  167. switch(spk){
  168. case 0:
  169. sutPocStatus.spk=0;
  170. break;
  171. case 1:
  172. sutPocStatus.spk=1;
  173. break;
  174. }
  175. }
  176. /*POC宸插惎鍔ㄦ垚鍔?*/
  177. static void pocStartMsg(void){
  178. sutApp.pocInitStatus=1;
  179. }
  180. /*褰撳墠璐﹀彿鎵€灞炵兢缁勫垪琛ㄤ俊鎭?涓€娆℃€ц幏鍙栨墍鏈?
  181. 涓嶅悓搴旂敤閲囩敤涓嶅悓闇€姹傛寚浠?
  182. 浠庝笉鍦ㄧ嚎鍒扮櫥褰曚細涓诲姩涓婃姤涓€娆″垪琛?
  183. 鍙慉T+POC=0D0000涔熶細涓婃姤涓€娆″垪琛?
  184. msg:000000,iiii(缁勫垪琛ㄧ储寮?,dddddddd(缁処D),nnnn(缁勬垚鍛樻暟),mmmmmm(缁勫悕绉?*/
  185. static void pro80Msg(char *msg){
  186. }
  187. /*鎵€鍦ㄧ粍鎴愬憳淇℃伅鍒楄〃
  188. 鍙慉T+POC=0E0000xxxxxxxx鏌ヨ�
  189. msg:010000,iiii(鎴愬憳鍒楄〃绱㈠紩),dddddddd(鎴愬憳ID),mmmmmmmm(鎴愬憳鍚嶇О)*/
  190. static void pro81Msg(char *msg){
  191. }
  192. /*
  193. +POC:LOGIN,2,6077024,3000300031000000
  194. */
  195. static void pro82Msg(char *msg){
  196. char *pName,index;
  197. int type,len;
  198. char Username[POC_GROUP_USER_NAME_LEN*2];
  199. index=FindIndexBydouhao(msg,3);
  200. if(index<17)return;//长度不够的直接丢了
  201. index=FindIndexBydouhao(msg,1);
  202. type=atoi(msg+index);
  203. MSG_INFO(1,"type=======%d",type);
  204. switch(type){
  205. case 0:
  206. sutApp.reloginStatus=0;
  207. sutPocStatus.logined=0;
  208. if(0==memcmp(msg+10, "CEDECDF8C2E7C1ACBDD3",20)) sutPocStatus.PocLineOffReason=1;
  209. else if(0==memcmp(msg+10, "CEDEB7A8C1ACBDD3",16)) sutPocStatus.PocLineOffReason=2;
  210. else if(0==memcmp(msg+10, "C3BBD3D0B7FECEF1",16)) sutPocStatus.PocLineOffReason=3;
  211. else if(0==memcmp(msg+10, "B5C7C2BDCAA7B0DC",16)) sutPocStatus.PocLineOffReason=4;
  212. break;
  213. case 2:
  214. sutApp.reloginStatus=1;
  215. sutPocStatus.PocLineOffReason=0;
  216. index=FindIndexBydouhao(msg,3);
  217. len=strlen(msg+index);
  218. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  219. memcpy(Username, msg+index,len);
  220. Username[len]=0;
  221. //StrAsciiToHex(Username, sutPocStatus.LocalUser.name);
  222. LwEndingToBiEndingStr(Username,len);
  223. unicodeToGbk(Username, sutPocStatus.LocalUser.name, &len);
  224. sutPocStatus.LocalUser.name[len]=0;
  225. //msg[10]=0;
  226. index=FindIndexBydouhao(msg,2);
  227. sutPocStatus.LocalUser.ID=atoi(msg+index);//strtol(&msg+index, &pName, 16);
  228. MSG_INFO(1, "Login ok");
  229. sutPocStatus.loginResult=3;
  230. break;
  231. }
  232. }
  233. /*鏈変汉璇磋瘽
  234. msg:00,dddddddd(鎴愬憳id),nnnnnnnn(鎴愬憳鍚嶇О)*/
  235. static void pro83Msg(char *msg){
  236. int len;
  237. char index;
  238. char callerName[POC_GROUP_USER_NAME_LEN*2];
  239. backLightReset();//閺€璺哄煂閺堝�姹夌拠纾嬬樈
  240. index=FindIndexBydouhao(msg,3);
  241. if(index<17)return;//长度不够的直接丢了
  242. len=strlen(msg+index);
  243. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  244. memcpy(callerName, msg+index,len);
  245. callerName[len]=0;
  246. if(0!=memcmp(callerName, sutPocStatus.CallName,len)) {
  247. LwEndingToBiEndingStr(callerName,len);
  248. unicodeToGbk(callerName, sutPocStatus.CallName, &len);
  249. sutPocStatus.CallName[len]=0;
  250. }
  251. }
  252. /*鍗曞懠鍝嶅簲淇℃伅
  253. msg:00,mmmmmmmmmm(鍗曞懠缁撴灉淇℃伅)
  254. BAF4BDD0B3C9B9A6 琛ㄧず 鍛煎彨鎴愬姛
  255. BAF4BDD0CAA7B0DC 琛ㄧず 鍛煎彨澶辫触
  256. CDCBB3F6C1D9CAB1BAF4BDD0 琛ㄧず 閫€鍑轰复鏃跺懠鍙?
  257. C1D9CAB1BAF4BDD031BAC5BBFA 琛ㄧず 涓存椂鍛煎彨 1 鍙锋満*/
  258. static void pro84Msg(char *msg){
  259. char index,len=0;
  260. index=FindIndexBydouhao(msg,1);
  261. if(index<17)return;
  262. //ttsPlay(ENCODE_USER_GBK, msg+2);
  263. if(msgCmp(msg+index, "344ef6657c54eb53")) sutPocStatus.danHuStatus=1;
  264. else if(msgCmp(msg+index, "0090fa51344ef6657c54eb530000")) sutPocStatus.danHuStatus=0;
  265. MSG_INFO(1,"sutPocStatus.danHuStatus=====%d",sutPocStatus.danHuStatus);
  266. //else if(0==memcmp(msg+2, "BAF4BDD0B3C9B9A6", 16)) sutPocStatus.danHuStatus=1;
  267. }
  268. /*
  269. +POC:JOINGRP,0,201536,80622f67e8904700500053004b6dd58b0000
  270. */
  271. static void pro86Msg(char *msg){
  272. char buf[POC_GROUP_USER_NAME_LEN*4+40],*pName;
  273. int len,i;
  274. char GroupName[POC_GROUP_USER_NAME_LEN*2];
  275. char tmp[POC_GROUP_USER_NAME_LEN*2+20];
  276. char needTTs=0,index;
  277. sutPocStatus.logined=1;
  278. index=FindIndexBydouhao(msg, 3);
  279. len=strlen(msg+index);
  280. if(len>POC_GROUP_USER_NAME_LEN*2) len=POC_GROUP_USER_NAME_LEN*2;
  281. memcpy(GroupName, msg+index,len);
  282. GroupName[len]=0;
  283. //msg[10]=0;
  284. index=FindIndexBydouhao(msg, 2);
  285. sutPocStatus.LocalGroup.ID=atoi(msg+index);
  286. //StrAsciiToHex(GroupName, sutPocStatus.LocalGroup.name);
  287. LwEndingToBiEndingStr(GroupName,len);
  288. unicodeToGbk(GroupName, sutPocStatus.LocalGroup.name, &len);
  289. sutPocStatus.LocalGroup.name[len]=0;
  290. if(sutPocStatus.firstLogin==0|| sutApp.reloginTts){
  291. snprintf(tmp, sizeof(tmp), "%s,已登录,%s", sutPocStatus.LocalUser.name,sutPocStatus.LocalGroup.name);
  292. backLightReset();//绗�竴娆$櫥褰曟椂锛屼繚鎸佸睆浜�捣鏉?
  293. needTTs=1;
  294. sutApp.reloginTts=0;
  295. }else{
  296. snprintf(tmp, sizeof(tmp), "进入,%s",sutPocStatus.LocalGroup.name);
  297. if(sutApp.groupTTSEnable!=0){
  298. needTTs=1;
  299. sutApp.groupTTSEnable=0;
  300. }
  301. }
  302. if(needTTs!=0){
  303. memset(buf, 0, sizeof(buf));
  304. for(i=0;i<strlen(tmp);i++){
  305. snprintf(GroupName, sizeof(GroupName), "%02x", tmp[i]);
  306. strcat(buf, GroupName);
  307. }
  308. //ttsPlay(ENCODE_USER_GBK, buf);
  309. }
  310. sutPocStatus.danHuStatus=0;
  311. sutPocStatus.firstLogin=1;
  312. }
  313. /*鏌ヨ�鎵€灞炵兢缁勬€绘暟鐨勫搷搴?
  314. 鍙慉T+POC=3D0000鑾峰緱
  315. msg:000000,nnnn(鎵€灞炲�灏戜釜缇ょ粍)*/
  316. static void pro3dMsg(char *msg){
  317. char *pName;
  318. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  319. sutPocStatus.ListUpdate=1;
  320. MSG_INFO(1, "groupNum:%d", sutPocStatus.ListCurOnlineNum);
  321. }
  322. /*鏌ヨ�鎵€灞炲湪绾挎垚鍛樻€绘暟鐨勫搷搴?
  323. 鍙慉T+POC=3E0000鑾峰緱
  324. msg:000000,nnnn(鎵€灞炲�灏戜釜鍦ㄧ嚎鎴愬憳)*/
  325. static void pro3eMsg(char *msg){
  326. char *pName;
  327. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  328. sutPocStatus.ListUpdate=1;
  329. MSG_INFO(1, "userNum:%d", sutPocStatus.ListCurOnlineNum);
  330. }
  331. /*鏌ヨ�鎵€鍦ㄧ粍鎴愬憳淇℃伅鏃惰繑鍥烇紝寰楀埌鍦ㄧ嚎鎴愬憳鎬绘暟
  332. msg:000000,nnnn(鍦ㄧ嚎鎴愬憳鎬绘暟)*/
  333. static void pro0eMsg(char *msg){
  334. }
  335. /*瀹氶噺鏌ヨ�鎵€鍦ㄧ兢缁勪腑鐨勫湪绾挎垚鍛樹俊鎭�搷搴?
  336. 鍙慉T+POC=1E0000xxxxx鑾峰緱
  337. msg:010000,iiii(鎴愬憳鍒楄〃绱㈠紩),dddddddd(鎴愬憳ID),mmmmmmmm(鎴愬憳鍚嶇О)*/
  338. static void pro1eMsg(char *msg){
  339. char name[POC_GROUP_USER_NAME_LEN*2+1];
  340. int len;
  341. unsigned long id;
  342. char *pTemp;
  343. if(!uiAssist.status)return 1;
  344. len = strlen(&msg[18]);
  345. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  346. memcpy(name, &msg[18], len);
  347. name[len]=0;
  348. msg[18]=0;
  349. id=strtol(&msg[10],&pTemp,16);
  350. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
  351. if(name[0]==0){
  352. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
  353. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
  354. }else StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  355. sutPocStatus.ListFillIndex++;
  356. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  357. sutPocStatus.ListGetOneFlag=1;
  358. sutPocStatus.ListDetailValid=1;
  359. }
  360. }
  361. /*瀹氭椂鏌ヨ�鎵€灞炵粍淇℃伅
  362. 鍙慉T+POC=1D0000xxxxx鑾峰緱
  363. msg:000000,iiii(缁勫垪琛ㄧ储寮?,dddddddd(缁処D),nnnn(鎴愬憳涓�暟),mmmmmmmmm(鍚嶇О)*/
  364. static void pro1dMsg(char *msg){
  365. unsigned short num;
  366. char name[POC_GROUP_USER_NAME_LEN*2+1];
  367. unsigned long id;
  368. unsigned short index;
  369. char *pTemp;
  370. int len;
  371. if(!uiAssist.status)return ;
  372. len = strlen(&msg[22]);//宸插幓鎺夊洖杞︽崲琛?
  373. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  374. memcpy(name, &msg[22], len);
  375. name[len]=0;
  376. msg[22]=0;
  377. num=strtol(&msg[18],&pTemp,16);
  378. msg[18]=0;
  379. id=strtol(&msg[10],&pTemp,16);
  380. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=id;
  381. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].usernum=num;
  382. if(name[0]==0){
  383. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
  384. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[1]=0;
  385. }else
  386. StrAsciiToHex(name, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
  387. sutPocStatus.ListFillIndex++;
  388. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  389. sutPocStatus.ListGetOneFlag=1;
  390. sutPocStatus.ListDetailValid=1;
  391. }
  392. }
  393. /*
  394. +POC_VER:01027
  395. msg=01027
  396. */
  397. static void pocGetVer(char *msg){
  398. snprintf(sutApp.pocVersion, sizeof(sutApp.pocVersion), "%s",msg);
  399. }
  400. static void pocGetPpp(char *msg){
  401. if(msg[0]=='1') sutApp.pocPpp=1;
  402. else sutApp.pocPpp=0;
  403. }
  404. /*
  405. +GAUTH:AD86EBCCECC4
  406. msg=AD86EBCCECC4+鍥炶溅
  407. */
  408. static void proGauthMsg(char *msg){
  409. }
  410. /*
  411. +NOTE:0,1
  412. msg=0,1+鍥炶溅
  413. */
  414. static void proNoteMsg(char *msg){
  415. MSG_INFO(1,"authAck:%s",msg);
  416. }
  417. /*
  418. +CTEC: 0,0
  419. msg=0,0
  420. */
  421. static void proNetMode(char *msg){
  422. unsigned char netModeValue;
  423. char cmd[30];
  424. if(msg[0]<'0' || msg[0]>'9') return;
  425. netModeValue=atoi(msg);
  426. ctecCurrentSet=netModeValue;
  427. if(ctecCurrentSet != newPara.netMode){
  428. snprintf(cmd, sizeof(cmd),"AT+CTEC=%d,%d\r\n", ctecCurrentSet, newPara.netMode);
  429. msgAtSend(cmd);
  430. }
  431. }
  432. /*
  433. +COPS: 0,2,"46000",7
  434. msg=+COPS: 0,2,"46000",7
  435. */
  436. static void proCopsMsg(char *msg){
  437. int i,j=0,codeType;
  438. for(i=0;i<strlen(msg);i++){
  439. if(msg[i]==','){
  440. if(++j==3){
  441. codeType=msg[i+1]-0x30;
  442. if(codeType==7) codeType=4;
  443. if(netshowvalue!=codeType) netshowvalue=codeType;
  444. return;
  445. }
  446. }
  447. }
  448. }
  449. /*
  450. +SIMCROSS:0
  451. msg=0/1
  452. */
  453. static void proSimMode(char *msg){
  454. unsigned char tmpSim;
  455. tmpSim=msg[0]-0x30;
  456. if(tmpSim!=0 && tmpSim!=1) return;
  457. sutApp.simSel=tmpSim;
  458. }
  459. /*
  460. +UDP:0,5,30
  461. msg=0,5,30
  462. */
  463. static void proPwrMode(char *msg){
  464. int seg1,seg2;
  465. short i;
  466. char buf[15];
  467. for(i=2;i<strlen(msg);i++){
  468. if(msg[i]==','){
  469. seg1=atoi(msg+2);
  470. seg2=atoi(msg+i+1);
  471. pwrModeAckHandler(seg1,seg2);
  472. }
  473. }
  474. }
  475. /*
  476. +FOTA:1,0
  477. +FOTA:1,XXX
  478. +FOTA:0
  479. +FOTA:1
  480. +FOTA:2
  481. msg=1,xxxx
  482. */
  483. static void proFotaMsg(char *msg){
  484. if(msg[1]==','){
  485. if(msg[2]=='0' && msg[3]==0) sutApp.fotaStatus=1;
  486. else{
  487. strcpy(sutApp.fotaVersion, msg+2);
  488. sutApp.fotaStatus=2;
  489. }
  490. }else if(msg[1]==0){
  491. if(msg[0]=='0') sutApp.fotaStatus=3;
  492. else if(msg[0]=='1') sutApp.fotaStatus=4;
  493. else if(msg[0]=='2') sutApp.fotaStatus=5;
  494. }
  495. }
  496. /*
  497. SV63302_T02
  498. msg=SV63302_T02
  499. */
  500. static void proGmrMsg(char *msg){
  501. snprintf(sutApp.modemVer, sizeof(sutApp.modemVer), "%s", msg);
  502. }
  503. /*
  504. +SMS:1,B2E2CAD4313233
  505. msg=1,B2E2CAD4313233
  506. */
  507. static void proSmsMsg(char *msg){
  508. }
  509. /*鏈嶅姟鍣ㄦ姤涓嬪彂鎶ヨ�TTS锛孭OC宸叉挱鎶ワ紝鏈�俊鎭�彧鎻愮ず*/
  510. static void proAlarmMsg(void){
  511. }
  512. static void proPendMsg(void){
  513. MSG_INFO(1, "active auth now");
  514. msgAtSend("AT+GAUTH\r\n");//鐢ㄤ簬鎺堟潈妫€娴?
  515. }
  516. static void proToneMsg(char *msg){
  517. #ifndef ENABLE_PWM_BEEP
  518. if(msg[0]=='1'){
  519. sutPocStatus.TONE=1;
  520. paControl(true);
  521. }else if(msg[0]=='0'){
  522. sutPocStatus.TONE=0;
  523. }
  524. #endif
  525. }
  526. /*
  527. +GPIP:183.131.13.10
  528. msg=183.131.13.10
  529. */
  530. static void proGPIPMsg(char *msg){
  531. if(strlen(msg)<7) return;
  532. if(strcmp(showPIP, msg)==0) return;
  533. snprintf(showPIP, sizeof(showPIP), "%s",msg);
  534. MSG_INFO(1, "updatePIP:%s", showPIP);
  535. }
  536. /*
  537. +GGIP:183.131.13.6
  538. msg=183.131.13.6
  539. */
  540. static void proGGIPMsg(char *msg){
  541. if(strlen(msg)<7) return;
  542. if(strcmp(showGIP, msg)==0) return;
  543. snprintf(showGIP, sizeof(showGIP), "%s",msg);
  544. MSG_INFO(1, "updateGIP:%s", showGIP);
  545. }
  546. /*
  547. +CSQ: 14,99
  548. msg=14,99
  549. */
  550. static void proCsqMsg(char *msg){
  551. int csq=atoi(msg);
  552. if(csq != sutApp.g_iCSQ) sutApp.g_iCSQ=csq;
  553. }
  554. /*
  555. +HEADSET:1
  556. msg=1
  557. */
  558. void proHeadSet(char *msg){
  559. switch(msg[0]){
  560. case '0'://HEADSET CONNECT
  561. sutApp.earLev=1;
  562. //msgAtSend("AT+AUDCH=1,3\r\n");
  563. sutApp.pcant=2;
  564. VolMicUpdate();
  565. VolSpkUpdate();
  566. break;//HEADSET DISCONNECTED
  567. case '1':
  568. sutApp.earLev=0;
  569. //msgAtSend("AT+AUDCH=0,0\r\n");
  570. sutApp.pcant=4;
  571. VolMicUpdate();
  572. VolSpkUpdate();
  573. break;//HEADSET BTN PRESS
  574. case '2':
  575. micPttHandler(1);
  576. break;//HEADSET BTN RELEASED
  577. case '3':
  578. micPttHandler(0);
  579. break;
  580. }
  581. }
  582. /*
  583. +CCID: 898604851920C0133569
  584. msg=898604851920C0133569
  585. */
  586. void proCCIDMsg(char *msg){
  587. sutApp.cardStatus=1;
  588. msg[6]=0;
  589. sutApp.copstype=atoi(msg+4);
  590. }
  591. void LogoutOutTimeCheck(unsigned int interval){
  592. //鎺夌嚎鍚庤秴杩?鍒嗛挓鍐嶇櫥褰曪紝闇€瑕佹挱鏀剧櫥褰曚俊鎭?
  593. static unsigned char lastLoginStatus=0;
  594. static unsigned int cnt=0;
  595. if(sutApp.reloginStatus == lastLoginStatus) return;
  596. if(sutApp.reloginStatus==0){//鐢卞湪绾垮彉鎴愭帀绾?
  597. if(++cnt>=(180000/interval)){
  598. cnt=0;
  599. sutApp.reloginTts=1;
  600. }
  601. }else{//鐢辨帀绾垮啀涓婄嚎
  602. cnt=0;
  603. }
  604. lastLoginStatus=sutApp.reloginStatus;
  605. }
  606. char *ohpocGetIMEI(void){
  607. static char imei[16]={0};
  608. if(imei[0]==0){
  609. if(LSAPI_SIM_GetIMEI(imei)==0){
  610. return imei;
  611. }
  612. }
  613. return NULL;
  614. }