poc(1030).c 20 KB

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