poc(4938).c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  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+1;//龰飯瘍綴珨弇
  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);
  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);
  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,index;
  223. int type,len;
  224. char Username[POC_GROUP_USER_NAME_LEN*2];
  225. index=FindIndexBydouhao(msg,1);
  226. MSG_INFO(1,"douhao =========%d",index);
  227. type=atoi(buf+index);
  228. switch(type){
  229. case 0:
  230. sutApp.reloginStatus=0;
  231. sutPocStatus.logined=0;
  232. if(0==memcmp(msg+10, "CEDECDF8C2E7C1ACBDD3",20)) sutPocStatus.PocLineOffReason=1;
  233. else if(0==memcmp(msg+10, "CEDEB7A8C1ACBDD3",16)) sutPocStatus.PocLineOffReason=2;
  234. else if(0==memcmp(msg+10, "C3BBD3D0B7FECEF1",16)) sutPocStatus.PocLineOffReason=3;
  235. else if(0==memcmp(msg+10, "B5C7C2BDCAA7B0DC",16)) sutPocStatus.PocLineOffReason=4;
  236. break;
  237. case 2:
  238. sutApp.reloginStatus=1;
  239. sutPocStatus.PocLineOffReason=0;
  240. index=FindIndexBydouhao(msg,3);
  241. len=strlen(msg+index);
  242. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  243. memcpy(Username, msg+index,len);
  244. Username[len]=0;
  245. StrAsciiToHex(Username, sutPocStatus.LocalUser.name);
  246. //msg[10]=0;
  247. index=FindIndexBydouhao(msg,2);
  248. sutPocStatus.LocalUser.ID=atoi(msg+index);//strtol(&msg+index, &pName, 16);
  249. MSG_INFO(1, "Login ok");
  250. sutPocStatus.loginResult=3;
  251. break;
  252. }
  253. }
  254. /*�劐犖霂渲�
  255. msg:00,dddddddd(�𣂼�id),nnnnnnnn(�𣂼��滨妍)*/
  256. static void pro83Msg(char *msg){
  257. int len;
  258. char callerName[POC_GROUP_USER_NAME_LEN*2];
  259. backLightReset();//��頝箏����瘙厩�蝤讠𧬘
  260. len=strlen(msg+10);
  261. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  262. memcpy(callerName, msg+10,len);
  263. callerName[len]=0;
  264. if(0!=memcmp(callerName, sutPocStatus.CallName,len)) StrAsciiToHex(callerName, sutPocStatus.CallName);
  265. }
  266. /*�訫鐤�滚�靽⊥�
  267. msg:00,mmmmmmmmmm(�訫鐤蝏𤘪�靽⊥�)
  268. BAF4BDD0B3C9B9A6 銵函內 �澆㙈�𣂼�
  269. BAF4BDD0CAA7B0DC 銵函內 �澆㙈憭梯揖
  270. CDCBB3F6C1D9CAB1BAF4BDD0 銵函內 ���箔葩�嗅鐤�?
  271. C1D9CAB1BAF4BDD031BAC5BBFA 銵函內 銝湔𧒄�澆㙈 1 �瑟㦤*/
  272. static void pro84Msg(char *msg){
  273. //unsigned char danhureport[POC_GROUP_USER_NAME_LEN+1];
  274. //StrAsciiToHex(msg+2, danhureport);
  275. if(0==memcmp(msg+2, "C1D9CAB1BAF4BDD0",16)){//銝湔𧒄�澆㙈 XXXX �芰�銝湔𧒄�澆㙈
  276. msg[2+16]=0;
  277. }
  278. ttsPlay(ENCODE_USER_GBK, msg+2);
  279. if(0==memcmp(msg+2, "C1D9CAB1", 8)) sutPocStatus.danHuStatus=1;
  280. else if(0==memcmp(msg+2, "CDCBB3F6", 8)) sutPocStatus.danHuStatus=0;
  281. else if(0==memcmp(msg+2, "BAF4BDD0B3C9B9A6", 16)) sutPocStatus.danHuStatus=1;
  282. }
  283. /*
  284. +POC:JOINGRP,0,201536,80622f67e8904700500053004b6dd58b0000
  285. */
  286. static void pro86Msg(char *msg){
  287. char buf[POC_GROUP_USER_NAME_LEN*4+40],*pName;
  288. int len,i;
  289. char GroupName[POC_GROUP_USER_NAME_LEN*2];
  290. char tmp[POC_GROUP_USER_NAME_LEN*2+20];
  291. char needTTs=0,index;
  292. sutPocStatus.logined=1;
  293. index=FindIndexBydouhao(msg, 3);
  294. len=strlen(msg+index);
  295. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  296. memcpy(GroupName, msg+index,len);
  297. GroupName[len]=0;
  298. //msg[10]=0;
  299. index=FindIndexBydouhao(msg, 2);
  300. sutPocStatus.LocalGroup.ID=atoi(msg+index);
  301. StrAsciiToHex(GroupName, sutPocStatus.LocalGroup.name);
  302. if(sutPocStatus.firstLogin==0|| sutApp.reloginTts){
  303. snprintf(tmp, sizeof(tmp), "%s,眒腎翹,%s", sutPocStatus.LocalUser.name,sutPocStatus.LocalGroup.name);
  304. backLightReset();//蝚砌�甈∠蒈敶閙𧒄嚗䔶����鈭株絲�?
  305. needTTs=1;
  306. sutApp.reloginTts=0;
  307. }else{
  308. snprintf(tmp, sizeof(tmp), "輛⻌,%s",sutPocStatus.LocalGroup.name);
  309. if(sutApp.groupTTSEnable!=0){
  310. needTTs=1;
  311. sutApp.groupTTSEnable=0;
  312. }
  313. }
  314. if(needTTs!=0){
  315. memset(buf, 0, sizeof(buf));
  316. for(i=0;i<strlen(tmp);i++){
  317. snprintf(GroupName, sizeof(GroupName), "%02x", tmp[i]);
  318. strcat(buf, GroupName);
  319. }
  320. ttsPlay(ENCODE_USER_GBK, buf);
  321. }
  322. sutPocStatus.danHuStatus=0;
  323. sutPocStatus.firstLogin=1;
  324. }
  325. /*�亥砭��撅䂿黎蝏��餅㺭���摨?
  326. �飊T+POC=3D0000�瑕�
  327. msg:000000,nnnn(��撅𧼮�撠睲葵蝢斤�)*/
  328. static void pro3dMsg(char *msg){
  329. char *pName;
  330. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  331. sutPocStatus.ListUpdate=1;
  332. MSG_INFO(1, "groupNum:%d", sutPocStatus.ListCurOnlineNum);
  333. }
  334. /*�亥砭��撅𧼮銁蝥踵��䀹�餅㺭���摨?
  335. �飊T+POC=3E0000�瑕�
  336. msg:000000,nnnn(��撅𧼮�撠睲葵�函瑪�𣂼�)*/
  337. static void pro3eMsg(char *msg){
  338. char *pName;
  339. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  340. sutPocStatus.ListUpdate=1;
  341. MSG_INFO(1, "userNum:%d", sutPocStatus.ListCurOnlineNum);
  342. }
  343. /*�亥砭���函��𣂼�靽⊥��嗉��痹�敺堒��函瑪�𣂼��餅㺭
  344. msg:000000,nnnn(�函瑪�𣂼��餅㺭)*/
  345. static void pro0eMsg(char *msg){
  346. }
  347. /*摰𡁻��亥砭���函黎蝏�葉��銁蝥踵��䀝縑�臬�摨?
  348. �飊T+POC=1E0000xxxxx�瑕�
  349. msg:010000,iiii(�𣂼��𡑒”蝝W�),dddddddd(�𣂼�ID),mmmmmmmm(�𣂼��滨妍)*/
  350. static void pro1eMsg(char *msg){
  351. char name[POC_GROUP_USER_NAME_LEN*2+1];
  352. int len;
  353. unsigned long id;
  354. char *pTemp;
  355. if(!uiAssist.status)return 1;
  356. len = strlen(&msg[18]);
  357. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  358. memcpy(name, &msg[18], len);
  359. name[len]=0;
  360. msg[18]=0;
  361. id=strtol(&msg[10],&pTemp,16);
  362. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
  363. if(name[0]==0){
  364. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
  365. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
  366. }else StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  367. sutPocStatus.ListFillIndex++;
  368. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  369. sutPocStatus.ListGetOneFlag=1;
  370. sutPocStatus.ListDetailValid=1;
  371. }
  372. }
  373. /*摰𡁏𧒄�亥砭��撅䂿�靽⊥�
  374. �飊T+POC=1D0000xxxxx�瑕�
  375. msg:000000,iiii(蝏��銵函揣撘?,dddddddd(蝏�D),nnnn(�𣂼�銝芣㺭),mmmmmmmmm(�滨妍)*/
  376. static void pro1dMsg(char *msg){
  377. unsigned short num;
  378. char name[POC_GROUP_USER_NAME_LEN*2+1];
  379. unsigned long id;
  380. unsigned short index;
  381. char *pTemp;
  382. int len;
  383. if(!uiAssist.status)return ;
  384. len = strlen(&msg[22]);//撌脣縧�匧�頧行揢銵?
  385. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  386. memcpy(name, &msg[22], len);
  387. name[len]=0;
  388. msg[22]=0;
  389. num=strtol(&msg[18],&pTemp,16);
  390. msg[18]=0;
  391. id=strtol(&msg[10],&pTemp,16);
  392. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=id;
  393. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].usernum=num;
  394. if(name[0]==0){
  395. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
  396. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[1]=0;
  397. }else
  398. StrAsciiToHex(name, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
  399. sutPocStatus.ListFillIndex++;
  400. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  401. sutPocStatus.ListGetOneFlag=1;
  402. sutPocStatus.ListDetailValid=1;
  403. }
  404. }
  405. /*
  406. +POC_VER:01027
  407. msg=01027
  408. */
  409. static void pocGetVer(char *msg){
  410. snprintf(sutApp.pocVersion, sizeof(sutApp.pocVersion), "%s",msg);
  411. }
  412. static void pocGetPpp(char *msg){
  413. if(msg[0]=='1') sutApp.pocPpp=1;
  414. else sutApp.pocPpp=0;
  415. }
  416. /*
  417. +GAUTH:AD86EBCCECC4
  418. msg=AD86EBCCECC4+�噼膠
  419. */
  420. static void proGauthMsg(char *msg){
  421. #if 1
  422. unsigned char newAuthTable[10]={0x50,0x28,0xaf,0x6d,0x08,0x9c,0x1b,0xe4,0x23,0x77};
  423. unsigned char randBuf[100];
  424. char buf[3];
  425. int len,i,j;
  426. len=0;
  427. for(i=0;i<strlen(msg);i++){
  428. if(msg[i]=='\r' || msg[i]=='\n' || msg[i]=='\0') goto MSG_DONE;
  429. randBuf[len++]=msg[i];
  430. }
  431. MSG_DONE:
  432. //�瑕�銝脣僎頧祆揢�?6餈𥕦��惩�銝?
  433. if(len%2 || 0!=restoreDataFormatByHex(randBuf,len)){
  434. MSG_WARN(1, "auth get error");
  435. return;
  436. }
  437. len /= 2;//敺堒��惩�靽⊥�:�踹漲銝槌en��andBuf
  438. extCodeBuffer(randBuf, len,newAuthTable, sizeof(newAuthTable));
  439. snprintf(randBuf, sizeof(randBuf), "AT+SAUTH=");
  440. //撠�鵭摨虫蛹i��mp���隞亙��剛��嗡葡�枏��煾�?
  441. for(j=0;j<sizeof(newAuthTable);j++){
  442. snprintf(buf, sizeof(buf),"%02x",newAuthTable[j]);
  443. strcat(randBuf, buf);
  444. }
  445. strcat(randBuf, "\r\n");
  446. msgAtSend(randBuf);
  447. MSG_INFO(0, randBuf);
  448. #else
  449. #define FACTORY_MARK "PC-TOOL"
  450. #define MODULE_MARK "PC-TEST-TOOL"
  451. unsigned char randBuf[20];
  452. unsigned char tmp[16+16+20];
  453. unsigned char imei[20];
  454. char sendBuf[sizeof(tmp)*2+20]="AT+SAUTH=";
  455. char *fillPtr=sendBuf+9;
  456. char buf[3];
  457. char *imeiPtr;
  458. int len,i,j;
  459. len=0;
  460. for(i=0;i<strlen(msg);i++){
  461. if(msg[i]=='\r' || msg[i]=='\n' || msg[i]=='\0') goto MSG_DONE;
  462. randBuf[len++]=msg[i];
  463. }
  464. MSG_DONE:
  465. //�瑕�銝脣僎頧祆揢�?6餈𥕦��惩�銝?
  466. if(len%2 || 0!=restoreDataFormatByHex(randBuf,len)){
  467. MSG_WARN(1, "auth get error");
  468. return;
  469. }
  470. len /= 2;//敺堒��惩�靽⊥�:�踹漲銝槌en��andBuf
  471. //撖嫣葡餈𥡝��惩��?�惩�撖孵�銝箏��?�箏�+霈曉�ID[32+32+20]
  472. imeiPtr=ohpocGetIMEI();
  473. if(NULL==imeiPtr){
  474. MSG_WARN(1, "imei is not ready");
  475. return;
  476. }
  477. MSG_INFO(1, "IMEI:%s",imeiPtr);
  478. i=strlen(imeiPtr);
  479. if(i>sizeof(imei)){
  480. MSG_ERR(1, "imei buffer overflow:%d",i);
  481. return;
  482. }
  483. memcpy(imei, imeiPtr,i);//敺堒�IMEI�唳旿:�踹漲銝槐��mei
  484. //蝏���讛悅�唳旿
  485. memset(tmp, 0,sizeof(tmp));
  486. memcpy(tmp,FACTORY_MARK,strlen(FACTORY_MARK));
  487. memcpy(tmp+16, MODULE_MARK,strlen(MODULE_MARK));
  488. tmp[32]=i;
  489. memcpy(tmp+33,imei,i);
  490. i=32+1+i;
  491. //雿輻鍂�踹漲銝槌en��andBuf�惩�銝脣笆�踹漲銝槐��mp餈𥡝��惩�
  492. extCodeBuffer(randBuf, len, tmp, i);
  493. //撠�鵭摨虫蛹i��mp���隞亙��剛��嗡葡�枏��煾�?
  494. for(j=0;j<i;j++){
  495. snprintf(buf, sizeof(buf),"%02x",tmp[j]);
  496. *fillPtr++=buf[0];
  497. *fillPtr++=buf[1];
  498. }
  499. *fillPtr++='\r';
  500. *fillPtr++='\n';
  501. *fillPtr++='\0';
  502. msgAtSend(sendBuf);
  503. MSG_INFO(0, sendBuf);
  504. #endif
  505. }
  506. /*
  507. +NOTE:0,1
  508. msg=0,1+�噼膠
  509. */
  510. static void proNoteMsg(char *msg){
  511. MSG_INFO(1,"authAck:%s",msg);
  512. }
  513. /*
  514. +CTEC: 0,0
  515. msg=0,0
  516. */
  517. static void proNetMode(char *msg){
  518. unsigned char netModeValue;
  519. char cmd[30];
  520. if(msg[0]<'0' || msg[0]>'9') return;
  521. netModeValue=atoi(msg);
  522. ctecCurrentSet=netModeValue;
  523. if(ctecCurrentSet != newPara.netMode){
  524. snprintf(cmd, sizeof(cmd),"AT+CTEC=%d,%d\r\n", ctecCurrentSet, newPara.netMode);
  525. msgAtSend(cmd);
  526. }
  527. }
  528. /*
  529. +COPS: 0,2,"46000",7
  530. msg=+COPS: 0,2,"46000",7
  531. */
  532. static void proCopsMsg(char *msg){
  533. int i,j=0,codeType;
  534. for(i=0;i<strlen(msg);i++){
  535. if(msg[i]==','){
  536. if(++j==3){
  537. codeType=msg[i+1]-0x30;
  538. if(codeType==7) codeType=4;
  539. if(netshowvalue!=codeType) netshowvalue=codeType;
  540. return;
  541. }
  542. }
  543. }
  544. }
  545. /*
  546. +SIMCROSS:0
  547. msg=0/1
  548. */
  549. static void proSimMode(char *msg){
  550. unsigned char tmpSim;
  551. tmpSim=msg[0]-0x30;
  552. if(tmpSim!=0 && tmpSim!=1) return;
  553. sutApp.simSel=tmpSim;
  554. }
  555. /*
  556. +UDP:0,5,30
  557. msg=0,5,30
  558. */
  559. static void proPwrMode(char *msg){
  560. int seg1,seg2;
  561. short i;
  562. char buf[15];
  563. for(i=2;i<strlen(msg);i++){
  564. if(msg[i]==','){
  565. seg1=atoi(msg+2);
  566. seg2=atoi(msg+i+1);
  567. pwrModeAckHandler(seg1,seg2);
  568. }
  569. }
  570. }
  571. /*
  572. +FOTA:1,0
  573. +FOTA:1,XXX
  574. +FOTA:0
  575. +FOTA:1
  576. +FOTA:2
  577. msg=1,xxxx
  578. */
  579. static void proFotaMsg(char *msg){
  580. if(msg[1]==','){
  581. if(msg[2]=='0' && msg[3]==0) sutApp.fotaStatus=1;
  582. else{
  583. strcpy(sutApp.fotaVersion, msg+2);
  584. sutApp.fotaStatus=2;
  585. }
  586. }else if(msg[1]==0){
  587. if(msg[0]=='0') sutApp.fotaStatus=3;
  588. else if(msg[0]=='1') sutApp.fotaStatus=4;
  589. else if(msg[0]=='2') sutApp.fotaStatus=5;
  590. }
  591. }
  592. /*
  593. SV63302_T02
  594. msg=SV63302_T02
  595. */
  596. static void proGmrMsg(char *msg){
  597. snprintf(sutApp.modemVer, sizeof(sutApp.modemVer), "%s", msg);
  598. }
  599. /*
  600. +SMS:1,B2E2CAD4313233
  601. msg=1,B2E2CAD4313233
  602. */
  603. static void proSmsMsg(char *msg){
  604. unsigned char smsType=msg[0]-0x30;
  605. unsigned len=strlen(msg+2);
  606. if(len%2 || 0!=restoreDataFormatByHex(msg+2,len)){
  607. MSG_WARN(1, "sms data error");
  608. return;
  609. }
  610. len /= 2;
  611. sutMess.codeType=smsType;
  612. sutSms.smsUpdate=1;
  613. memcpy(sutMess.GBKMess1+4, msg+2, len);
  614. }
  615. /*�滚𦛚�冽𥁒銝见��亥郎TTS嚗釶OC撌脫偘�伐��砌縑�臬蘨�鞟內*/
  616. static void proAlarmMsg(void){
  617. }
  618. static void proPendMsg(void){
  619. MSG_INFO(1, "active auth now");
  620. msgAtSend("AT+GAUTH\r\n");//�其����璉�瘚?
  621. }
  622. static void proToneMsg(char *msg){
  623. #ifndef ENABLE_PWM_BEEP
  624. if(msg[0]=='1'){
  625. sutPocStatus.TONE=1;
  626. paControl(true);
  627. }else if(msg[0]=='0'){
  628. sutPocStatus.TONE=0;
  629. }
  630. #endif
  631. }
  632. /*
  633. +GPIP:183.131.13.10
  634. msg=183.131.13.10
  635. */
  636. static void proGPIPMsg(char *msg){
  637. if(strlen(msg)<7) return;
  638. if(strcmp(showPIP, msg)==0) return;
  639. snprintf(showPIP, sizeof(showPIP), "%s",msg);
  640. MSG_INFO(1, "updatePIP:%s", showPIP);
  641. }
  642. /*
  643. +GGIP:183.131.13.6
  644. msg=183.131.13.6
  645. */
  646. static void proGGIPMsg(char *msg){
  647. if(strlen(msg)<7) return;
  648. if(strcmp(showGIP, msg)==0) return;
  649. snprintf(showGIP, sizeof(showGIP), "%s",msg);
  650. MSG_INFO(1, "updateGIP:%s", showGIP);
  651. }
  652. /*
  653. +CSQ: 14,99
  654. msg=14,99
  655. */
  656. static void proCsqMsg(char *msg){
  657. int csq=atoi(msg);
  658. if(csq != sutApp.g_iCSQ) sutApp.g_iCSQ=csq;
  659. }
  660. /*
  661. +HEADSET:1
  662. msg=1
  663. */
  664. void proHeadSet(char *msg){
  665. switch(msg[0]){
  666. case '0'://HEADSET CONNECT
  667. sutApp.earLev=1;
  668. //msgAtSend("AT+AUDCH=1,3\r\n");
  669. sutApp.pcant=2;
  670. VolMicUpdate();
  671. VolSpkUpdate();
  672. break;//HEADSET DISCONNECTED
  673. case '1':
  674. sutApp.earLev=0;
  675. //msgAtSend("AT+AUDCH=0,0\r\n");
  676. sutApp.pcant=4;
  677. VolMicUpdate();
  678. VolSpkUpdate();
  679. break;//HEADSET BTN PRESS
  680. case '2':
  681. micPttHandler(1);
  682. break;//HEADSET BTN RELEASED
  683. case '3':
  684. micPttHandler(0);
  685. break;
  686. }
  687. }
  688. /*
  689. +CCID: 898604851920C0133569
  690. msg=898604851920C0133569
  691. */
  692. void proCCIDMsg(char *msg){
  693. sutApp.cardStatus=1;
  694. msg[6]=0;
  695. sutApp.copstype=atoi(msg+4);
  696. }
  697. void LogoutOutTimeCheck(unsigned int interval){
  698. //�厩瑪�舘�餈?����滨蒈敶𤏪���閬�偘�曄蒈敶蓥縑�?
  699. static unsigned char lastLoginStatus=0;
  700. static unsigned int cnt=0;
  701. if(sutApp.reloginStatus == lastLoginStatus) return;
  702. if(sutApp.reloginStatus==0){//�勗銁蝥踹��鞉�蝥? if(++cnt>=(180000/interval)){
  703. cnt=0;
  704. sutApp.reloginTts=1;
  705. }
  706. }else{//�望�蝥踹�銝羓瑪
  707. cnt=0;
  708. }
  709. lastLoginStatus=sutApp.reloginStatus;
  710. }
  711. char *ohpocGetIMEI(void){
  712. static char imei[16]={0};
  713. if(imei[0]==0){
  714. if(LSAPI_SIM_GetIMEI(imei)==0){
  715. return imei;
  716. }
  717. }
  718. return NULL;
  719. }