poc.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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. static unsigned short cnt=0;
  10. //3绉掓煡璇�竴娆?
  11. if(sutApp.gtMode!=0) return;//GT妯″紡鍚庝笉鍐嶆煡璇?
  12. if(++cnt<(5*1000/dly)) return;
  13. cnt=0;
  14. //if(getAppObjStatus(ASLEEP_POC)==0) return;//POC浼戠湢鏃讹紝涓嶅彂鎸囦护
  15. //if(getAppObjStatus(ASLEEP_LCD)==0) return;
  16. //鐢ㄤ簬妫€娴嬪苟璁剧疆POC鍙傛暟
  17. msgAtSend("AT+COPS?\r\n");
  18. msgAtSend("AT+CTEC?\r\n");//鏌ヨ�褰撳墠缃戠粶鍒跺紡
  19. msgAtSend("AT+CSQ\r\n");//鏌ヨ�淇″彿寮哄害
  20. #ifndef USE_BND_POC
  21. if(sutApp.pocParaDone==0) msgAtSend("AT+POC=020000\r\n");
  22. msgAtSend("AT+UDP?\r\n");//鏌ヨ�鍔熻€楃姸鎬?
  23. msgAtSend("AT+GPIP?\r\nAT+GGIP?\r\n");//鏌ヨ�PIP,GIP
  24. #endif
  25. }
  26. static void micPro(int mic);
  27. static void spkPro(int spk);
  28. static void pocStartMsg(void);
  29. static void pro80Msg(char *msg);
  30. static void pro81Msg(char *msg);
  31. static void pro82Msg(char *msg);
  32. static void pro83Msg(char *msg);
  33. static void pro84Msg(char *msg);
  34. static void pro86Msg(char *msg);
  35. static void pro3dMsg(char *msg);
  36. static void pro3eMsg(char *msg);
  37. static void pro0eMsg(char *msg);
  38. static void pro1eMsg(char *msg);
  39. static void pro1dMsg(char *msg);
  40. static void pocGetVer(char *msg);
  41. static void pocGetPpp(char *msg);
  42. static void proGauthMsg(char *msg);
  43. static void proNoteMsg(char *msg);
  44. static void proNetMode(char *msg);
  45. static void proSimMode(char *msg);
  46. static void proPwrMode(char *msg);
  47. static void proFotaMsg(char *msg);
  48. static void proGmrMsg(char *msg);
  49. static void proSmsMsg(char *msg);
  50. static void proAlarmMsg(void);
  51. static void proPendMsg(void);
  52. static void proToneMsg(char *msg);
  53. static void proGPIPMsg(char *msg);
  54. static void proGGIPMsg(char *msg);
  55. static void proCsqMsg(char *msg);
  56. static void proMicSpk(int mic, int spk);
  57. static void proCopsMsg(char *msg);
  58. static void proHeadSet(char *msg);
  59. static void ProGetMicLV(char *msg,int len);
  60. void cmdsProcess(char *msg, int len){//宸插幓鎺夊洖杞︽崲琛?
  61. int i,j;
  62. char buf[10];
  63. if(sutApp.pocInitStatus==0) sutApp.pocInitStatus=1;
  64. if(sutApp.gtMode==0){
  65. //appSleepCtl(ASLEEP_POC, 1);
  66. tryWakeupApp();
  67. MSG_INFO(1,"POC:%s",msg);
  68. if(msgCmp(msg, "+POC:WAKEUP")){//POC鍞ら啋浜?
  69. }else if(msgCmp(msg, "+POC:8B")){
  70. buf[0]=msg[7];buf[1]=msg[8];buf[2]=0;
  71. i=atoi(buf);
  72. buf[0]=msg[9];buf[1]=msg[10];buf[2]=0;
  73. j=atoi(buf);
  74. proMicSpk(i, j);
  75. }else if(msgCmp(msg, "+LSHTTS: END")){
  76. sutPocStatus.TTS=0;
  77. }else if(msgCmp(msg, "+HTTS: START")){
  78. paControl(true);
  79. sutPocStatus.TTS=1;
  80. }
  81. else if(msgCmp(msg, "+CTEC:")) proNetMode(msg+7);
  82. else if(msgCmp(msg, "+CSQ: ")) proCsqMsg(msg+6);
  83. else if(msgCmp(msg, "+COPS:")) proCopsMsg(msg);
  84. else if(msgCmp(msg, "+CPIN: READY")) sutApp.cardStatus=1;
  85. else if(msgCmp(msg, "+SIMCROSS"))proSimMode(msg+10);
  86. else if(msgCmp(msg, "SV")) strcpy(sutApp.modemVer, msg);
  87. else if(msgCmp(msg,"+CACCP:"))ProGetMicLV(msg,len);
  88. else MSG_INFO(1, "skip:%d,%s", len,msg);
  89. }
  90. }
  91. //澶勭悊POC妯″潡淇℃伅
  92. void pocCmdHandler(unsigned char *msg, int len){
  93. //鏈夋秷鎭�繘鏉ワ紝濡傛灉涓嶆槸+POC:SLEEP锛孭OC閮藉敜閱掍簡
  94. static char tmp[300],ch;
  95. static int k=0;
  96. unsigned int j;
  97. if(sutApp.authReady==0) return;
  98. if(sutApp.gtMode !=0 && sutApp.gtTMode != 0){
  99. //MSG_INFO(1,"stop USBsend");
  100. usbOutPut(msg, len);//TM TRACE
  101. return;
  102. }
  103. for(j=0;j<len;j++){//杩囨护
  104. if(k>=sizeof(tmp)) k=0;
  105. tmp[k++]=msg[j];
  106. if(ch=='\r' && msg[j]=='\n'){
  107. if(k!=2){
  108. //澶勭悊
  109. k -=2;tmp[k]=0;//鍘绘帀鍥炶溅鎹㈣�
  110. cmdsProcess(tmp,k);
  111. }
  112. k=0;
  113. }
  114. ch=msg[j];
  115. }
  116. }
  117. static void proMicSpk(int mic, int spk){
  118. if(mic==0 && spk==0){//0000
  119. if(newPara.KeySound!=0) pttBeepStart(false);
  120. sutPocStatus.spk=0;
  121. sutPocStatus.mic=0;
  122. sutPocStatus.TONE=0;
  123. }else if(mic==1 && spk==0){//0100
  124. if(newPara.KeySound!=0) pttBeepStart(false);
  125. sutPocStatus.mic=1;
  126. }else if(mic==0 && spk==1){//0001
  127. if(newPara.KeySound!=0) paControl(true);//pttBeepStart(false);
  128. else paControl(true);//鍏抽棴鎻愮ず闊虫椂锛屼篃瑕佹墦寮€鍠囧彮
  129. sutPocStatus.spk=1;
  130. sutPocStatus.mic=0;
  131. }else if(mic==0 && spk==13){//0013
  132. if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
  133. }else if(mic==0 && spk==2){
  134. paControl(true);
  135. sutPocStatus.TONE=1;
  136. }
  137. }
  138. static void micPro(int mic){
  139. switch(mic){
  140. case 0://鍏抽棴mic
  141. sutPocStatus.mic=0;
  142. break;
  143. case 1://鎵撳紑mic
  144. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  145. sutPocStatus.mic=1;
  146. //sutPocStatus.spk=0;
  147. break;
  148. }
  149. }
  150. static void spkPro(int spk){
  151. switch(spk){
  152. case 0://tone闊冲悗鍏抽棴spk
  153. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  154. sutPocStatus.spk=0;
  155. break;
  156. case 1://tone闊冲悗淇濇寔spk鎵撳紑
  157. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  158. paControl(true);
  159. sutPocStatus.spk=1;
  160. sutPocStatus.mic=0;
  161. break;
  162. case 2://鎾�斁TTS
  163. paControl(true);
  164. sutPocStatus.TTS=1;
  165. break;
  166. case 13://鎶㈤害澶辫触锛屽彲浠�one鐗规畩闊?
  167. if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
  168. break;
  169. }
  170. }
  171. /*POC宸插惎鍔ㄦ垚鍔?*/
  172. static void pocStartMsg(void){
  173. sutApp.pocInitStatus=1;
  174. }
  175. /*褰撳墠璐﹀彿鎵€灞炵兢缁勫垪琛ㄤ俊鎭?涓€娆℃€ц幏鍙栨墍鏈?
  176. 涓嶅悓搴旂敤閲囩敤涓嶅悓闇€姹傛寚浠?
  177. 浠庝笉鍦ㄧ嚎鍒扮櫥褰曚細涓诲姩涓婃姤涓€娆″垪琛?
  178. 鍙慉T+POC=0D0000涔熶細涓婃姤涓€娆″垪琛?
  179. msg:000000,iiii(缁勫垪琛ㄧ储寮?,dddddddd(缁処D),nnnn(缁勬垚鍛樻暟),mmmmmm(缁勫悕绉?*/
  180. static void pro80Msg(char *msg){
  181. }
  182. /*鎵€鍦ㄧ粍鎴愬憳淇℃伅鍒楄〃
  183. 鍙慉T+POC=0E0000xxxxxxxx鏌ヨ�
  184. msg:010000,iiii(鎴愬憳鍒楄〃绱㈠紩),dddddddd(鎴愬憳ID),mmmmmmmm(鎴愬憳鍚嶇О)*/
  185. static void pro81Msg(char *msg){
  186. }
  187. /*鐧诲綍鐘舵€佷俊鎭?
  188. msg:ss(00鏈�櫥褰?02宸茬櫥褰?,dddddddd(鎴愬憳id),mmmmmmmm(鐘舵€佷俊鎭�唴瀹?
  189. 00 CEDECDF8C2E7C1ACBDD3 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鏃犵綉缁滆繛鎺?鎷ㄥ彿娌?鎴愬姛)
  190. 00 CEDEB7A8C1ACBDD3 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鏃犳硶杩炴帴(IP 涓嶅�鎴栧畾 鍚戝崱)
  191. 00 C3BBD3D0B7FECEF1 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?娌℃湁鏈嶅姟(娌℃敞鍐?
  192. 00 B5C7C2BDCAA7B0DC 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鐧婚檰澶辫触(璐﹀彿閿欒�)
  193. 00 0D5CBBAC5D0C5CFA2B4EDCEF3 璐﹀彿淇℃伅閿欒�
  194. 02 0001A750 B2E2CAD431BAC5(娴嬭瘯 1 鍙?,*/
  195. static void pro82Msg(char *msg){
  196. char buf[3],*pName;
  197. int type,len;
  198. char Username[POC_GROUP_USER_NAME_LEN*2];
  199. buf[0]=msg[0];buf[1]=msg[1];buf[2]=0;
  200. type=atoi(buf);
  201. switch(type){
  202. case 0:
  203. sutPocStatus.logined=0;
  204. if(0==memcmp(msg+10, "CEDECDF8C2E7C1ACBDD3",20)) sutPocStatus.PocLineOffReason=1;
  205. else if(0==memcmp(msg+10, "CEDEB7A8C1ACBDD3",16)) sutPocStatus.PocLineOffReason=2;
  206. else if(0==memcmp(msg+10, "C3BBD3D0B7FECEF1",16)) sutPocStatus.PocLineOffReason=3;
  207. else if(0==memcmp(msg+10, "B5C7C2BDCAA7B0DC",16)) sutPocStatus.PocLineOffReason=4;
  208. break;
  209. case 2:
  210. sutPocStatus.PocLineOffReason=0;
  211. len=strlen(msg+10);
  212. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  213. memcpy(Username, msg+10,len);
  214. Username[len]=0;
  215. StrAsciiToHex(Username, sutPocStatus.LocalUser.name);
  216. msg[10]=0;
  217. sutPocStatus.LocalUser.ID=strtol(&msg[2], &pName, 16);
  218. MSG_INFO(1, "Login ok");
  219. sutPocStatus.loginResult=3;
  220. break;
  221. }
  222. }
  223. /*鏈変汉璇磋瘽
  224. msg:00,dddddddd(鎴愬憳id),nnnnnnnn(鎴愬憳鍚嶇О)*/
  225. static void pro83Msg(char *msg){
  226. int len;
  227. char callerName[POC_GROUP_USER_NAME_LEN*2];
  228. backLightReset();//閺€璺哄煂閺堝�姹夌拠纾嬬樈
  229. len=strlen(msg+10);
  230. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  231. memcpy(callerName, msg+10,len);
  232. callerName[len]=0;
  233. if(0!=memcmp(callerName, sutPocStatus.CallName,len)) StrAsciiToHex(callerName, sutPocStatus.CallName);
  234. }
  235. /*鍗曞懠鍝嶅簲淇℃伅
  236. msg:00,mmmmmmmmmm(鍗曞懠缁撴灉淇℃伅)
  237. BAF4BDD0B3C9B9A6 琛ㄧず 鍛煎彨鎴愬姛
  238. BAF4BDD0CAA7B0DC 琛ㄧず 鍛煎彨澶辫触
  239. CDCBB3F6C1D9CAB1BAF4BDD0 琛ㄧず 閫€鍑轰复鏃跺懠鍙?
  240. C1D9CAB1BAF4BDD031BAC5BBFA 琛ㄧず 涓存椂鍛煎彨 1 鍙锋満*/
  241. static void pro84Msg(char *msg){
  242. //unsigned char danhureport[POC_GROUP_USER_NAME_LEN+1];
  243. //StrAsciiToHex(msg+2, danhureport);
  244. ttsPlay(ENCODE_USER_GBK, msg+2);
  245. if(0==memcmp(msg+2, "C1D9CAB1", 8)) sutPocStatus.danHuStatus=1;
  246. else if(0==memcmp(msg+2, "CDCBB3F6", 8)) sutPocStatus.danHuStatus=0;
  247. else if(0==memcmp(msg+2, "BAF4BDD0B3C9B9A6", 16)) sutPocStatus.danHuStatus=1;
  248. }
  249. /*鍒囨崲缇ょ粍瀹屾垚鎸囦护(琛ㄧず宸茬櫥褰?
  250. msg:00,dddddddd(缁刬d),nnnnnnnn(缁勫悕绉?*/
  251. static void pro86Msg(char *msg){
  252. char buf[POC_GROUP_USER_NAME_LEN*4+40],*pName;
  253. int len,i;
  254. char GroupName[POC_GROUP_USER_NAME_LEN*2];
  255. char tmp[POC_GROUP_USER_NAME_LEN*2+20];
  256. char needTTs=0;
  257. sutPocStatus.logined=1;
  258. len=strlen(msg+10);
  259. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  260. memcpy(GroupName, msg+10,len);
  261. GroupName[len]=0;
  262. msg[10]=0;
  263. sutPocStatus.LocalGroup.ID=strtol(msg+2, &pName,16);
  264. StrAsciiToHex(GroupName, sutPocStatus.LocalGroup.name);
  265. if(sutPocStatus.firstLogin==0){
  266. snprintf(tmp, sizeof(tmp), "%s,已登录,%s", sutPocStatus.LocalUser.name,sutPocStatus.LocalGroup.name);
  267. backLightReset();//绗�竴娆$櫥褰曟椂锛屼繚鎸佸睆浜�捣鏉?
  268. needTTs=1;
  269. }else{
  270. snprintf(tmp, sizeof(tmp), "进入,%s",sutPocStatus.LocalGroup.name);
  271. if(sutApp.groupTTSEnable!=0){
  272. needTTs=1;
  273. sutApp.groupTTSEnable=0;
  274. }
  275. }
  276. if(needTTs!=0){
  277. memset(buf, 0, sizeof(buf));
  278. for(i=0;i<strlen(tmp);i++){
  279. snprintf(GroupName, sizeof(GroupName), "%02x", tmp[i]);
  280. strcat(buf, GroupName);
  281. }
  282. ttsPlay(ENCODE_USER_GBK, buf);
  283. }
  284. sutPocStatus.danHuStatus=0;
  285. sutPocStatus.firstLogin=1;
  286. }
  287. /*鏌ヨ�鎵€灞炵兢缁勬€绘暟鐨勫搷搴?
  288. 鍙慉T+POC=3D0000鑾峰緱
  289. msg:000000,nnnn(鎵€灞炲�灏戜釜缇ょ粍)*/
  290. static void pro3dMsg(char *msg){
  291. char *pName;
  292. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  293. sutPocStatus.ListUpdate=1;
  294. MSG_INFO(1, "groupNum:%d", sutPocStatus.ListCurOnlineNum);
  295. }
  296. /*鏌ヨ�鎵€灞炲湪绾挎垚鍛樻€绘暟鐨勫搷搴?
  297. 鍙慉T+POC=3E0000鑾峰緱
  298. msg:000000,nnnn(鎵€灞炲�灏戜釜鍦ㄧ嚎鎴愬憳)*/
  299. static void pro3eMsg(char *msg){
  300. char *pName;
  301. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  302. sutPocStatus.ListUpdate=1;
  303. MSG_INFO(1, "userNum:%d", sutPocStatus.ListCurOnlineNum);
  304. }
  305. /*鏌ヨ�鎵€鍦ㄧ粍鎴愬憳淇℃伅鏃惰繑鍥烇紝寰楀埌鍦ㄧ嚎鎴愬憳鎬绘暟
  306. msg:000000,nnnn(鍦ㄧ嚎鎴愬憳鎬绘暟)*/
  307. static void pro0eMsg(char *msg){
  308. }
  309. /*瀹氶噺鏌ヨ�鎵€鍦ㄧ兢缁勪腑鐨勫湪绾挎垚鍛樹俊鎭�搷搴?
  310. 鍙慉T+POC=1E0000xxxxx鑾峰緱
  311. msg:010000,iiii(鎴愬憳鍒楄〃绱㈠紩),dddddddd(鎴愬憳ID),mmmmmmmm(鎴愬憳鍚嶇О)*/
  312. static void pro1eMsg(char *msg){
  313. char name[POC_GROUP_USER_NAME_LEN*2+1];
  314. int len;
  315. unsigned long id;
  316. char *pTemp;
  317. if(!uiAssist.status)return 1;
  318. len = strlen(&msg[18]);
  319. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  320. memcpy(name, &msg[18], len);
  321. name[len]=0;
  322. msg[18]=0;
  323. id=strtol(&msg[10],&pTemp,16);
  324. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
  325. if(name[0]==0){
  326. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
  327. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
  328. }else StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  329. sutPocStatus.ListFillIndex++;
  330. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  331. sutPocStatus.ListGetOneFlag=1;
  332. sutPocStatus.ListDetailValid=1;
  333. }
  334. }
  335. /*瀹氭椂鏌ヨ�鎵€灞炵粍淇℃伅
  336. 鍙慉T+POC=1D0000xxxxx鑾峰緱
  337. msg:000000,iiii(缁勫垪琛ㄧ储寮?,dddddddd(缁処D),nnnn(鎴愬憳涓�暟),mmmmmmmmm(鍚嶇О)*/
  338. static void pro1dMsg(char *msg){
  339. unsigned short num;
  340. char name[POC_GROUP_USER_NAME_LEN*2+1];
  341. unsigned long id;
  342. unsigned short index;
  343. char *pTemp;
  344. int len;
  345. if(!uiAssist.status)return ;
  346. len = strlen(&msg[22]);//宸插幓鎺夊洖杞︽崲琛?
  347. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  348. memcpy(name, &msg[22], len);
  349. name[len]=0;
  350. msg[22]=0;
  351. num=strtol(&msg[18],&pTemp,16);
  352. msg[18]=0;
  353. id=strtol(&msg[10],&pTemp,16);
  354. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=id;
  355. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].usernum=num;
  356. if(name[0]==0){
  357. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
  358. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[1]=0;
  359. }else
  360. StrAsciiToHex(name, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
  361. sutPocStatus.ListFillIndex++;
  362. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  363. sutPocStatus.ListGetOneFlag=1;
  364. sutPocStatus.ListDetailValid=1;
  365. }
  366. }
  367. /*
  368. +POC_VER:01027
  369. msg=01027
  370. */
  371. static void pocGetVer(char *msg){
  372. snprintf(sutApp.pocVersion, sizeof(sutApp.pocVersion), "%s",msg);
  373. }
  374. static void pocGetPpp(char *msg){
  375. if(msg[0]=='1') sutApp.pocPpp=1;
  376. else sutApp.pocPpp=0;
  377. }
  378. /*
  379. +GAUTH:AD86EBCCECC4
  380. msg=AD86EBCCECC4+鍥炶溅
  381. */
  382. static void proGauthMsg(char *msg){
  383. unsigned char newAuthTable[10]={0x50,0x28,0xaf,0x6d,0x08,0x9c,0x1b,0xe4,0x23,0x77};
  384. unsigned char randBuf[100];
  385. char buf[3];
  386. int len,i,j;
  387. len=0;
  388. for(i=0;i<strlen(msg);i++){
  389. if(msg[i]=='\r' || msg[i]=='\n' || msg[i]=='\0') goto MSG_DONE;
  390. randBuf[len++]=msg[i];
  391. }
  392. MSG_DONE:
  393. //鑾峰彇涓插苟杞�崲鎴?6杩涘埗鍔犲瘑涓?
  394. if(len%2 || 0!=restoreDataFormatByHex(randBuf,len)){
  395. MSG_WARN(1, "auth get error");
  396. return;
  397. }
  398. len /= 2;//寰楀埌鍔犲瘑淇℃伅:闀垮害涓簂en鐨剅andBuf
  399. extCodeBuffer(randBuf, len,newAuthTable, sizeof(newAuthTable));
  400. snprintf(randBuf, sizeof(randBuf), "AT+SAUTH=");
  401. //灏嗛暱搴︿负i鐨則mp鍐呭瓨浠ュ崄鍏�繘鍒朵覆鎵撳寘鍙戦€?
  402. for(j=0;j<sizeof(newAuthTable);j++){
  403. snprintf(buf, sizeof(buf),"%02x",newAuthTable[j]);
  404. strcat(randBuf, buf);
  405. }
  406. strcat(randBuf, "\r\n");
  407. msgAtSend(randBuf);
  408. MSG_INFO(0, randBuf);
  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. char w=0;
  439. unsigned char netModeValue;
  440. MSG_INFO(1,"enter PORCOPS");
  441. for(i=0;i<strlen(msg);i++){
  442. if(msg[i]==','){
  443. if(++j==3){
  444. codeType=msg[i+1]-0x30;
  445. if(codeType==7) codeType=4;
  446. if(netshowvalue!=codeType) netshowvalue=codeType;
  447. return;
  448. }
  449. }else if(msg[i]=='"'){
  450. if(++w==1){
  451. codeType=atoi(msg+i+1);
  452. if(codeType>0 && codeType != sutApp.copstype) sutApp.copstype=codeType;
  453. }
  454. }
  455. }
  456. }
  457. /*
  458. +SIMCROSS:0
  459. msg=0/1
  460. */
  461. static void proSimMode(char *msg){
  462. unsigned char tmpSim;
  463. tmpSim=msg[0]-0x30;
  464. if(tmpSim!=0 && tmpSim!=1) return;
  465. if(tmpSim==1)sutApp.simSel=0;
  466. else if(tmpSim==0)sutApp.simSel=1;
  467. }
  468. /*
  469. +UDP:0,5,30
  470. msg=0,5,30
  471. */
  472. static void proPwrMode(char *msg){
  473. int seg1,seg2;
  474. short i;
  475. char buf[15];
  476. for(i=2;i<strlen(msg);i++){
  477. if(msg[i]==','){
  478. seg1=atoi(msg+2);
  479. seg2=atoi(msg+i+1);
  480. pwrModeAckHandler(seg1,seg2);
  481. }
  482. }
  483. }
  484. /*
  485. +FOTA:1,0
  486. +FOTA:1,XXX
  487. +FOTA:0
  488. +FOTA:1
  489. +FOTA:2
  490. msg=1,xxxx
  491. */
  492. static void proFotaMsg(char *msg){
  493. if(msg[1]==','){
  494. if(msg[2]=='0' && msg[3]==0){
  495. fotaStepSet(6);
  496. }else{
  497. strcpy(sutApp.fotaVersion, msg+2);
  498. fotaStepSet(9);
  499. }
  500. }else if(msg[1]==0){
  501. if(msg[0]=='0'){
  502. fotaStepSet(7);
  503. }else if(msg[0]=='1') showLoading();
  504. else if(msg[0]=='2'){
  505. fotaStepSet(8);
  506. }
  507. }
  508. }
  509. /*
  510. SV63302_T02
  511. msg=SV63302_T02
  512. */
  513. static void proGmrMsg(char *msg){
  514. snprintf(sutApp.modemVer, sizeof(sutApp.modemVer), "%s", msg);
  515. }
  516. /*
  517. +SMS:1,B2E2CAD4313233
  518. msg=1,B2E2CAD4313233
  519. */
  520. static void proSmsMsg(char *msg){
  521. unsigned char smsType=msg[0]-0x30;
  522. unsigned len=strlen(msg+2);
  523. if(len%2 || 0!=restoreDataFormatByHex(msg+2,len)){
  524. MSG_WARN(1, "sms data error");
  525. return;
  526. }
  527. len /= 2;
  528. sutMess.codeType=smsType;
  529. sutSms.smsUpdate=1;
  530. memcpy(sutMess.GBKMess1+4, msg+2, len);
  531. }
  532. /*鏈嶅姟鍣ㄦ姤涓嬪彂鎶ヨ�TTS锛孭OC宸叉挱鎶ワ紝鏈�俊鎭�彧鎻愮ず*/
  533. static void proAlarmMsg(void){
  534. }
  535. static void proPendMsg(void){
  536. MSG_INFO(1, "active auth now");
  537. msgAtSend("AT+GAUTH\r\n");//鐢ㄤ簬鎺堟潈妫€娴?
  538. }
  539. static void proToneMsg(char *msg){
  540. #ifndef ENABLE_PWM_BEEP
  541. if(msg[0]=='1'){
  542. sutPocStatus.TONE=1;
  543. paControl(true);
  544. }else if(msg[0]=='0'){
  545. sutPocStatus.TONE=0;
  546. }
  547. #endif
  548. }
  549. /*
  550. +GPIP:183.131.13.10
  551. msg=183.131.13.10
  552. */
  553. static void proGPIPMsg(char *msg){
  554. if(strlen(msg)<7) return;
  555. if(strcmp(showPIP, msg)==0) return;
  556. snprintf(showPIP, sizeof(showPIP), "%s",msg);
  557. MSG_INFO(1, "updatePIP:%s", showPIP);
  558. }
  559. /*
  560. +GGIP:183.131.13.6
  561. msg=183.131.13.6
  562. */
  563. static void proGGIPMsg(char *msg){
  564. if(strlen(msg)<7) return;
  565. if(strcmp(showGIP, msg)==0) return;
  566. snprintf(showGIP, sizeof(showGIP), "%s",msg);
  567. MSG_INFO(1, "updateGIP:%s", showGIP);
  568. }
  569. /*
  570. +CSQ: 14,99
  571. msg=14,99
  572. */
  573. static void proCsqMsg(char *msg){
  574. int csq=atoi(msg);
  575. if(csq != sutApp.g_iCSQ) sutApp.g_iCSQ=csq;
  576. }
  577. /*
  578. +HEADSET:1
  579. msg=1
  580. */
  581. static void proHeadSet(char *msg){
  582. switch(msg[0]){
  583. case '0'://HEADSET CONNECT
  584. sutApp.earLev=1;
  585. msgAtSend("AT+AUDCH=1,3\r\n");
  586. sutApp.pcant=2;
  587. break;//HEADSET DISCONNECTED
  588. case '1':
  589. sutApp.earLev=0;
  590. msgAtSend("AT+AUDCH=0,0\r\n");
  591. sutApp.pcant=4;
  592. break;//HEADSET BTN PRESS
  593. case '2':
  594. micPttHandler(1);
  595. break;//HEADSET BTN RELEASED
  596. case '3':
  597. micPttHandler(0);
  598. break;
  599. }
  600. }
  601. static void ProGetATIMsg(char *msg){strcpy(sutApp.modemVer, msg);}
  602. static void ProGetMicLV(char *msg,int len){
  603. char buf[30];
  604. char NeedSet=0;
  605. if(len<=8) return;//忽虐掉+CACCP: 指令,否则会无限循环,因为AT+CACCP=0,0,0,.....指令设置后也是返回+CACCP: 指令
  606. msg[11]=0;
  607. msg[15]=0;
  608. if(newPara.VolMicLvCu!=htoi(&msg[9]))NeedSet=1;
  609. if(newPara.VolMicLvXi!=htoi(&msg[13]))NeedSet=1;
  610. if(NeedSet==0){
  611. sutApp.Get_MicLv=1;
  612. return;
  613. }
  614. snprintf(buf, sizeof(buf),"AT+CACCP=0,0,0,\"%02x00%02x00\"\r\n",newPara.VolMicLvCu,newPara.VolMicLvXi);
  615. msgAtSend(buf);
  616. MSG_INFO(0,buf);
  617. }
  618. char *ohpocGetICCID(void){
  619. return NULL;
  620. }
  621. char *ohpocGetIMEI(void){
  622. static char imei[16]={0};
  623. if(imei[0]==0){
  624. if(LSAPI_SIM_GetIMEI(imei)==0){
  625. return imei;
  626. }
  627. }
  628. return NULL;
  629. }
  630. void ohpocGetClock(MY_CLOCK *myclock){
  631. current_zone_time(myclock);
  632. }
  633. unsigned long htoi(char s[])
  634. {
  635. int i = 0;
  636. unsigned long long n = 0;
  637. if (s[0] == '0' && (s[1]=='x' || s[1]=='X')) i = 2;
  638. else i = 0;
  639. for (; (s[i] >= '0' && s[i] <= '9') || (s[i] >= 'a' && s[i] <= 'z') || (s[i] >='A' && s[i] <= 'Z');++i){
  640. if (tolower(s[i]) > '9') n = 16 * n + (10 + tolower(s[i]) - 'a');
  641. else n = 16 * n + (tolower(s[i]) - '0');
  642. }
  643. return n;
  644. }