poc.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. #include "includes.h"
  2. POC_DEF sutPocStatus;
  3. void pocDataInit(void){
  4. memset((unsigned char *)&sutPocStatus, 0, sizeof(POC_DEF));
  5. }
  6. unsigned long long htoi(char s[])
  7. {
  8. int i = 0;
  9. unsigned long long n = 0;
  10. if (s[0] == '0' && (s[1]=='x' || s[1]=='X')) i = 2;
  11. else i = 0;
  12. for (; (s[i] >= '0' && s[i] <= '9') || (s[i] >= 'a' && s[i] <= 'z') || (s[i] >='A' && s[i] <= 'Z');++i){
  13. if (tolower(s[i]) > '9') n = 16 * n + (10 + tolower(s[i]) - 'a');
  14. else n = 16 * n + (tolower(s[i]) - '0');
  15. }
  16. return n;
  17. }
  18. /*
  19. MakeStringToUpperCap
  20. 閬嶅巻data锛屽皢闈炲ぇ鍐欏瓧姣嶈浆鎴愬ぇ鍐欏瓧姣�
  21. */
  22. void MakeStringToUpperCap(unsigned char *data, unsigned short len){
  23. unsigned short i;
  24. for(i=0;i<len;i++)
  25. {
  26. if(data[i] >= 'a' && data[i] <= 'z')
  27. data[i] -= 0x20;
  28. }
  29. }
  30. /*鎺у埗鏌ヨ�POC璁剧疆鐘舵€?
  31. dly:鎺ュ彛琚�皟鐢ㄧ殑棰戠巼锛屽崟浣峬s*/
  32. void pocProCtl(int dly){
  33. //3缁夋帗鐓$拠顫��濞�?
  34. static unsigned short cnt=0;
  35. static unsigned short timecnt=0;// 5鍒嗛挓鏍″噯涓€娆℃椂闂�
  36. if(sutApp.gtMode!=0) return;//GT濡�€崇础閸氬簼绗夐崘宥嗙叀鐠�?
  37. if(++cnt<(5*1000/dly)) return;
  38. cnt=0;
  39. if(getAppObjStatus(ASLEEP_LCD)==0) return;//POC娴兼垹婀㈤弮璁圭礉娑撳秴褰傞幐鍥︽姢
  40. msgAtSend("AT+COPS?\r\n");
  41. msgAtSend("AT+CTEC?\r\n");//閺屻儴顕楄ぐ鎾冲�缂冩垹绮堕崚璺虹础
  42. msgAtSend("AT+CSQ\r\n");//閺屻儴顕楁穱鈥冲娇瀵�搫瀹�
  43. msgAtSend("AT+POC=280000\r\n");//鑾峰彇鍖椾含鏃堕棿
  44. #ifdef CONFIG_AUDIO_AFTER_INIT
  45. msgAtSend("AT+CACCP=0,0,1,\"\"\r\n");//妫€娴媘ic鏄�惁琚玬ute鎺変簡
  46. #endif
  47. }
  48. static void micPro(int mic);
  49. static void spkPro(int spk);
  50. static void pocStartMsg(void);
  51. static void pro80Msg(char *msg);
  52. static void pro81Msg(char *msg);
  53. static void pro82Msg(char *msg);
  54. static void pro83Msg(char *msg);
  55. static void pro84Msg(char *msg);
  56. static void pro86Msg(char *msg);
  57. static void pro3dMsg(char *msg);
  58. static void pro3eMsg(char *msg);
  59. static void pro0eMsg(char *msg);
  60. static void pro1eMsg(char *msg);
  61. static void pro1dMsg(char *msg);
  62. static void pocGetVer(char *msg);
  63. static void proNoteMsg(char *msg);
  64. static void proNetMode(char *msg);
  65. static void proSimMode(char *msg);
  66. static void proGmrMsg(char *msg);
  67. static void proSmsMsg(char *msg);
  68. static void proCsqMsg(char *msg);
  69. static void proMicSpk(int mic, int spk);
  70. static void proCopsMsg(char *msg);
  71. static bool proMicGain(char *msg);
  72. static void pro96Msg(char *msg);
  73. static void pro28Msg(char *msg);
  74. static void pro0dMsg(char *msg);
  75. static void pro0eMsg(char *msg);
  76. static void pro3bMsg (char *msg);
  77. static void Pro7DMsg(char *msg);
  78. void pro8CMsg(char *msg);
  79. void cmdsProcess(char *msg, int len){//宸插幓鎺夊洖杞︽崲琛?
  80. int i,j;
  81. char buf[10];
  82. if(sutApp.pocInitStatus==0) sutApp.pocInitStatus=1;
  83. if(sutApp.gtMode==0){
  84. if(msgCmp(msg,"+POC")){
  85. //鏄疨OC 淇℃伅 鍞ら啋
  86. if(!msgCmp(msg,"+POC:28")&&!msgCmp(msg,"+POC:85")&&!msgCmp(msg,"+POC:97")){
  87. backLightReset();
  88. tryWakeupApp();
  89. MSG_INFO(1,"POCwakeup");
  90. }
  91. }
  92. MSG_INFO(1,"POC:%s",msg);
  93. if(msgCmp(msg, "PocSleep")){//POC浼戠湢浜?
  94. appSleepCtl(ASLEEP_POC, 0);
  95. }else if(msgCmp(msg, "+POC:WAKEUP")){//POC鍞ら啋浜?
  96. }else if(msgCmp(msg, "+POC:8B")){
  97. #if 1
  98. buf[0]=msg[7];buf[1]=msg[8];buf[2]=0;
  99. i=atoi(buf);
  100. buf[0]=msg[9];buf[1]=msg[10];buf[2]=0;
  101. j=atoi(buf);
  102. proMicSpk(i, j);
  103. #endif
  104. }else if(msgCmp(msg, "+LSHTTS: END")){
  105. sutPocStatus.TTS=0;
  106. }else if(msgCmp(msg, "+HTTS: START")){
  107. paControl(true);
  108. sutPocStatus.TTS=1;
  109. }else if(msgCmp(msg, "+POC:02000000")) setPocPara(msg+13,len-13);
  110. else if(msgCmp(msg,"+POC:9600")) pro96Msg(msg);
  111. else if(msgCmp(msg, "+POC:82")) pro82Msg(msg);
  112. else if(msgCmp(msg, "+POC:86")) pro86Msg(msg);
  113. else if(msgCmp(msg, "+POC:83")) pro83Msg(msg);
  114. else if(msgCmp(msg, "+POC:28")) pro28Msg(msg);
  115. else if(msgCmp(msg, "+POC:80")) pro80Msg(msg);
  116. else if(msgCmp(msg, "+POC:81")) pro81Msg(msg);
  117. else if(msgCmp(msg, "+POC:0D")) pro0dMsg(msg);
  118. //else if(msgCmp(msg, "+POC:0E")) pro0eMsg(msg);
  119. else if(msgCmp(msg, "+POC:3B")) pro3bMsg(msg);
  120. else if(msgCmp(msg, "+POC:7D")) Pro7DMsg(msg+13);
  121. else if(msgCmp(msg, "+POC:84")) pro84Msg(msg+7);
  122. else if(msgCmp(msg, "+CTEC:")) proNetMode(msg+7);
  123. else if(msgCmp(msg, "+CSQ: ")) proCsqMsg(msg+6);
  124. else if(msgCmp(msg, "+POC:8C00")) pro8CMsg(msg);
  125. else if(msgCmp(msg, "+POC:1D")) pro1dMsg(msg+7);
  126. // else if(msgCmp(msg, "+HEADSET:")) proHeadSet(msg+9);
  127. else if(msgCmp(msg, "+POC:START")) pocStartMsg();
  128. else if(msgCmp(msg, "+POC_VER:")) pocGetVer(msg+9);
  129. else if(msgCmp(msg, "+NOTE:")) proNoteMsg(msg+6);
  130. else if(msgCmp(msg, "+SIMCROSS:")) proSimMode(msg+10);
  131. else if(msgCmp(msg, "SV")) proGmrMsg(msg);
  132. else if(msgCmp(msg, "+SMS:")) proSmsMsg(msg+5);
  133. else if(msgCmp(msg, "+COPS:")) proCopsMsg(msg);
  134. else if(msgCmp(msg, "+CPIN: READY")) sutApp.cardStatus=1;
  135. //else if(msgCmp(msg, "+CCID: ")) proCCIDMsg(msg+7);
  136. else if(msgCmp(msg, "+CACCP: ")){
  137. if(false==proMicGain(msg+8)) proCaccpMsg(msg+8);
  138. }else MSG_INFO(1, "skip:%d,%s", len,msg);
  139. }
  140. }
  141. //澶勭悊POC妯″潡淇℃伅
  142. void pocCmdHandler(unsigned char *msg, int len){
  143. //鏈夋秷鎭�繘鏉ワ紝濡傛灉涓嶆槸+POC:SLEEP锛孭OC閮藉敜閱掍簡
  144. static char tmp[300],ch;
  145. static int k=0;
  146. unsigned int j;
  147. if(sutApp.authReady==0) return;
  148. if(sutApp.gtMode !=0 && sutApp.gtTMode != 0){
  149. usbOutPut(msg, len);//TM妯″紡涓嬬洿鎺ラ€忎紶
  150. return;
  151. }
  152. for(j=0;j<len;j++){//杩囨护
  153. if(k>=sizeof(tmp)) k=0;
  154. tmp[k++]=msg[j];
  155. if(ch=='\r' && msg[j]=='\n'){
  156. if(k!=2){
  157. //澶勭悊
  158. k -=2;tmp[k]=0;//鍘绘帀鍥炶溅鎹㈣�
  159. MakeStringToUpperCap(tmp, k);
  160. cmdsProcess(tmp,k);
  161. }
  162. k=0;
  163. }
  164. ch=msg[j];
  165. }
  166. }
  167. static void proMicSpk(int mic, int spk){
  168. if(mic==0 && spk==0){//0000
  169. if(newPara.KeySound!=0) pttBeepStart(false);
  170. sutPocStatus.spk=0;
  171. sutPocStatus.mic=0;
  172. sutPocStatus.TONE=0;
  173. }else if(mic==1 && spk==0){//0100
  174. if(newPara.KeySound!=0) pttBeepStart(false);
  175. sutPocStatus.mic=1;
  176. }else if(mic==0 && spk==1){//0001
  177. if(newPara.KeySound!=0) paControl(true);//pttBeepStart(false);
  178. else paControl(true);//鍏抽棴鎻愮ず闊虫椂锛屼篃瑕佹墦寮€鍠囧彮
  179. sutPocStatus.spk=1;
  180. sutPocStatus.mic=0;
  181. }else if(mic==0 && spk==13){//0013
  182. if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
  183. }else if(mic==0 && spk==2){
  184. paControl(true);
  185. sutPocStatus.TONE=1;
  186. }
  187. }
  188. static void micPro(int mic){
  189. switch(mic){
  190. case 0://鍏抽棴mic
  191. sutPocStatus.mic=0;
  192. break;
  193. case 1://鎵撳紑mic
  194. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  195. sutPocStatus.mic=1;
  196. //sutPocStatus.spk=0;
  197. break;
  198. }
  199. }
  200. static void spkPro(int spk){
  201. switch(spk){
  202. case 0://tone闊冲悗鍏抽棴spk
  203. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  204. sutPocStatus.spk=0;
  205. break;
  206. case 1://tone闊冲悗淇濇寔spk鎵撳紑
  207. if(newPara.KeySound!=0) beepStart(TONE_NORMAL);
  208. paControl(true);
  209. sutPocStatus.spk=1;
  210. sutPocStatus.mic=0;
  211. break;
  212. case 2://鎾�斁TTS
  213. paControl(true);
  214. sutPocStatus.TTS=1;
  215. break;
  216. case 13://鎶㈤害澶辫触锛屽彲浠�one鐗规畩闊?
  217. if(newPara.KeySound!=0) beepStart(TONE_SPECIAL);
  218. break;
  219. }
  220. }
  221. /*POC宸插惎鍔ㄦ垚鍔?*/
  222. static void pocStartMsg(void){
  223. sutApp.pocInitStatus=1;
  224. }
  225. /*褰撳墠璐﹀彿鎵€灞炵兢缁勫垪琛ㄤ俊鎭?涓€娆℃€ц幏鍙栨墍鏈?
  226. 涓嶅悓搴旂敤閲囩敤涓嶅悓闇€姹傛寚浠?
  227. 浠庝笉鍦ㄧ嚎鍒扮櫥褰曚細涓诲姩涓婃姤涓€娆″垪琛?
  228. 鍙慉T+POC=0D0000涔熶細涓婃姤涓€娆″垪琛?
  229. msg:000000,iiii(缁勫垪琛ㄧ储寮?,dddddddd(缁処D),nnnn(缁勬垚鍛樻暟),mmmmmm(缁勫悕绉?*/
  230. static void pro80Msg(char *msg){
  231. char Groupname[POC_GROUP_USER_NAME_LEN];
  232. char len;
  233. char Idbuf[5]={0};
  234. if(msg[8]=='2')return;
  235. len=strlen(&msg[29]);
  236. memcpy(Groupname, &msg[29], len);
  237. memcpy(Idbuf,&msg[25],4);
  238. //MakeStrEndByNewLine(msg);
  239. memset(sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name,0,sizeof(sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name));
  240. msg[25]=0;
  241. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=htoi(&msg[17]);
  242. if(sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID==0xFFFFFFFF){
  243. if(sutUIstatus.Status==UIS_MENU_FRIEND_SEL){
  244. sutPocStatus.ListUpdate=1;
  245. sutPocStatus.ListDetailValid=1;
  246. sutPocStatus.ListCurOnlineNum=htoi(Idbuf);
  247. //if(sutPocStatus.danHuStatus!=0)sutPocStatus.ListCurOnlineNum--;// 鑼朵綑鍗曞懠鍘绘帀涓存椂缇ょ粍
  248. MSG_INFO(1, "friend:%d", sutPocStatus.ListCurOnlineNum);
  249. }
  250. return;
  251. }
  252. if(sutPocStatus.ListFillIndex>0){
  253. if(sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID==sutPocStatus.AllGroups[sutPocStatus.ListFillIndex-1].ID){
  254. MSG_INFO(1,"id===chongfu==================%d\r\n",sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID);
  255. return;
  256. }
  257. }
  258. if(msg[29]==0) sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
  259. else {
  260. LwEndingToBiEndingStr(Groupname,len);
  261. unicodeToGbk(Groupname, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name, &len);
  262. }
  263. //msg[29+8]=0;
  264. MSG_INFO(1,"AllGroups===%s,%d,%d\r\n",sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name,sutPocStatus.ExceptionReadNum,sutPocStatus.ListFillIndex);
  265. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].status=2;
  266. sutPocStatus.ListFillIndex++;
  267. MSG_INFO(1,"get groups end\r\n");
  268. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  269. MSG_INFO(1,"get groups finish--\r\n");
  270. sutPocStatus.ListGetOneFlag=1;
  271. }
  272. }
  273. /*鎵€鍦ㄧ粍鎴愬憳淇℃伅鍒楄〃
  274. 鍙慉T+POC=0E0000xxxxxxxx鏌ヨ�
  275. msg:010000,iiii(鎴愬憳鍒楄〃绱㈠紩),dddddddd(鎴愬憳ID),mmmmmmmm(鎴愬憳鍚嶇О)*/
  276. static void pro81Msg(char *msg){
  277. char Username[POC_GROUP_USER_NAME_LEN];
  278. char len;
  279. unsigned char i=0;
  280. if(sutPocStatus.NeedGetUser==2){
  281. len=strlen(&msg[25]);
  282. memcpy(Username, &msg[25], len);
  283. memset(UserArr[sutPocStatus.ListFillIndex].UserName,0,POC_GROUP_USER_NAME_LEN);
  284. msg[25]=0;
  285. UserArr[sutPocStatus.ListFillIndex].id=htoi(&msg[17]);
  286. /*
  287. if(sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID==0xFFFFFFFF){
  288. return;
  289. }
  290. */
  291. if(msg[29]==0) UserArr[sutPocStatus.ListFillIndex].UserName[0]=' ';
  292. else {
  293. LwEndingToBiEndingStr(Username,len);
  294. unicodeToGbk(Username, UserArr[sutPocStatus.ListFillIndex].UserName, &len);
  295. }
  296. MSG_INFO(1,"GetAllUsers===%s,%d\r\n",UserArr[sutPocStatus.ListFillIndex].UserName,sutPocStatus.ListFillIndex);
  297. sutPocStatus.ListFillIndex++;
  298. if(sutPocStatus.ListFillIndex==sutPocStatus.UserSum){
  299. sutPocStatus.NeedGetUser=0;
  300. /*
  301. 如果有新用户需添加至leader
  302. */
  303. }
  304. }
  305. if(sutPocStatus.NeedGetUser!=0)return;//获取所有成员信息
  306. len=strlen(&msg[25]);
  307. memcpy(Username, &msg[25], len);
  308. memset(sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name,0,POC_GROUP_USER_NAME_LEN);
  309. msg[25]=0;
  310. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=htoi(&msg[17]);
  311. if(sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID==0xFFFFFFFF){
  312. return;
  313. }
  314. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].status=msg[8]-0x30;
  315. //1
  316. if(sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].status==1&&sutUIstatus.Status==UIS_MENU_USER_SEL)return; //涓嶅湪绾� 涓嶆樉绀�
  317. if(msg[29]==0) sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
  318. else {
  319. LwEndingToBiEndingStr(Username,len);
  320. unicodeToGbk(Username, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name, &len);
  321. }
  322. //msg[29+8]=0;
  323. MSG_INFO(1,"AllUsers===%s,%d,%d\r\n",sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name,sutPocStatus.ExceptionReadNum,sutPocStatus.ListFillIndex);
  324. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].status=msg[8]-0x30;
  325. sutPocStatus.ListFillIndex++;
  326. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  327. sutPocStatus.ListGetOneFlag=1;
  328. MSG_INFO(1,"get users finish--\r\n");
  329. }
  330. }
  331. /*鐧诲綍鐘舵€佷俊鎭?
  332. msg:ss(00鏈�櫥褰?02宸茬櫥褰?,dddddddd(鎴愬憳id),mmmmmmmm(鐘舵€佷俊鎭�唴瀹?
  333. 00 CEDECDF8C2E7C1ACBDD3 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鏃犵綉缁滆繛鎺?鎷ㄥ彿娌?鎴愬姛)
  334. 00 CEDEB7A8C1ACBDD3 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鏃犳硶杩炴帴(IP 涓嶅�鎴栧畾 鍚戝崱)
  335. 00 C3BBD3D0B7FECEF1 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?娌℃湁鏈嶅姟(娌℃敞鍐?
  336. 00 B5C7C2BDCAA7B0DC 琛ㄧず涓嶅湪绾匡紝杈撳嚭淇℃伅涓?鐧婚檰澶辫触(璐﹀彿閿欒�)
  337. 00 0D5CBBAC5D0C5CFA2B4EDCEF3 璐﹀彿淇℃伅閿欒�
  338. 02 0001A750 B2E2CAD431BAC5(娴嬭瘯 1 鍙?,*/
  339. static void pro82Msg(char *msg){
  340. char buf[3],*pName;
  341. int type,len,i;
  342. char Username[POC_GROUP_USER_NAME_LEN*2];
  343. buf[0]=msg[7];buf[1]=msg[8];buf[2]=0;
  344. type=atoi(buf);
  345. switch(type){
  346. case 0:
  347. sutPocStatus.logined=0;
  348. break;
  349. case 2:
  350. sutPocStatus.PocLineOffReason=0;
  351. len = strlen(&msg[17]);
  352. memcpy(Username,&msg[17],len);
  353. Username[len]=0;
  354. LwEndingToBiEndingStr(Username,len);
  355. unicodeToGbk(Username,sutPocStatus.LocalUser.name,&len);
  356. msg[17]=0;
  357. sutPocStatus.LocalUser.ID=strtol(&msg[9],&pName,16);
  358. MSG_INFO(1, "Login ok");
  359. //getNameFlag=1;//
  360. sutPocStatus.loginResult=3;
  361. break;
  362. }
  363. }
  364. /*鏈変汉璇磋瘽
  365. msg:00,dddddddd(鎴愬憳id),nnnnnnnn(鎴愬憳鍚嶇О)*/
  366. static void pro83Msg(char *msg){
  367. int len;
  368. char callerName[POC_GROUP_USER_NAME_LEN*2];
  369. char *pName;
  370. unsigned short i=0;
  371. unsigned char Needcat=1;
  372. char temp[POC_GROUP_USER_NAME_LEN];
  373. len=strlen(msg);
  374. paControl(true);
  375. sutPocStatus.PaDlyStart=1;
  376. if(memcmp(&msg[len-28],"2857B28BDD8B2E002E002E000000",28)!=0)return;
  377. backLightReset();//闁衡偓鐠哄搫鐓傞柡鍫濐槷濮瑰�鎷犵壕瀣�▓
  378. len=strlen(&msg[17])-28;//鍘绘帀 姝e湪瀵硅�璇濆瓧鏍�---鑼朵綑
  379. if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN;
  380. //else i++;//鎶婃渶鍚�0 涔熸嫹璐濊繘鏉�
  381. memcpy(callerName,&msg[17],len);
  382. LwEndingToBiEndingStr(callerName,len);
  383. unicodeToGbk(callerName, sutPocStatus.CallName, &len);
  384. //StrUnicodeToAnsiBig(sutPocStatus.Callname,i,&msg[17+8]);
  385. *(msg+17) = 0;
  386. sutPocStatus.CallID = strtol(&msg[9],&pName,16);
  387. msg[17]=0;
  388. for(i=0;i<MAX_USER;i++){
  389. if(UserArr[i].id==sutPocStatus.CallID){
  390. Needcat=0;
  391. break;
  392. }
  393. }
  394. if(Needcat){
  395. snprintf(temp,sizeof(temp),"监听组-%s",sutPocStatus.CallName);
  396. strcpy(sutPocStatus.CallName,temp);
  397. MSG_INFO(1,"监听组---%s",temp);
  398. }
  399. }
  400. /*鍗曞懠鍝嶅簲淇℃伅
  401. msg:00,mmmmmmmmmm(鍗曞懠缁撴灉淇℃伅)
  402. BAF4BDD0B3C9B9A6 琛ㄧず 鍛煎彨鎴愬姛
  403. BAF4BDD0CAA7B0DC 琛ㄧず 鍛煎彨澶辫触
  404. CDCBB3F6C1D9CAB1BAF4BDD0 琛ㄧず 閫€鍑轰复鏃跺懠鍙?
  405. C1D9CAB1BAF4BDD031BAC5BBFA 琛ㄧず 涓存椂鍛煎彨 1 鍙锋満*/
  406. static void pro84Msg(char *msg){
  407. LwEndingToBiEndingStr(msg+2,strlen(msg+2));
  408. ttsPlay(ENCODE_USER_UNICODE_BE, msg+2); //ENCODE_USER_UNICODE_BE
  409. if(0==memcmp(msg+2, "C1D9CAB1", 8)) sutPocStatus.danHuStatus=1;
  410. else if(0==memcmp(msg+2, "CDCBB3F6", 8)) sutPocStatus.danHuStatus=0;
  411. else if(0==memcmp(msg+2, "BAF4BDD0B3C9B9A6", 16)) sutPocStatus.danHuStatus=1;
  412. }
  413. /*鍒囨崲缇ょ粍瀹屾垚鎸囦护(琛ㄧず宸茬櫥褰?
  414. msg:00,dddddddd(缁刬d),nnnnnnnn(缁勫悕绉?*/
  415. static void pro86Msg(char *msg){
  416. char buf[POC_GROUP_USER_NAME_LEN*4+40],*pName;
  417. int len,i;
  418. char GroupName[POC_GROUP_USER_NAME_LEN*2]={0};
  419. char tmp[POC_GROUP_USER_NAME_LEN*2+20]={0};
  420. char needTTs=0;
  421. if(msg[9]=='F'&&msg[10]=='F')return ;
  422. sutPocStatus.logined=1;
  423. if(msg[8]=='0'){
  424. len = strlen(&msg[17]);
  425. MSG_INFO(1,"len====%d",len);
  426. memcpy(GroupName,&msg[17],len);
  427. GroupName[len]=0;
  428. msg[17]=0;
  429. sutPocStatus.LocalGroup.ID=strtol(&msg[9],&pName,16);
  430. LwEndingToBiEndingStr(GroupName,len);
  431. unicodeToGbk(GroupName, sutPocStatus.LocalGroup.name, &len);
  432. MSG_INFO(1,"groupnamelen======%d",len);
  433. MSG_INFO(1,"groupname======%s",sutPocStatus.LocalGroup.name);
  434. sutPocStatus.danHuStatus=0;
  435. snprintf(tmp,sizeof(tmp),"AT+POC=3B0000%08x\r\n",sutPocStatus.LocalGroup.ID);
  436. ModemSendAt(tmp);
  437. sutPocStatus.NeedGetUser=1;
  438. }else if(msg[8]=='1'){
  439. //鍗曞懠妯″紡
  440. sutPocStatus.danHuStatus=1;
  441. }
  442. backLightReset();
  443. sutPocStatus.firstLogin=1;
  444. }
  445. /*鏌ヨ�鎵€灞炵兢缁勬€绘暟鐨勫搷搴?
  446. 鍙慉T+POC=3D0000鑾峰緱
  447. msg:000000,nnnn(鎵€灞炲�灏戜釜缇ょ粍)*/
  448. static void pro3dMsg(char *msg){
  449. char *pName;
  450. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  451. sutPocStatus.ListUpdate=1;
  452. MSG_INFO(1, "groupNum:%d", sutPocStatus.ListCurOnlineNum);
  453. }
  454. /*鏌ヨ�鎵€灞炲湪绾挎垚鍛樻€绘暟鐨勫搷搴?
  455. 鍙慉T+POC=3E0000鑾峰緱
  456. msg:000000,nnnn(鎵€灞炲�灏戜釜鍦ㄧ嚎鎴愬憳)*/
  457. static void pro3eMsg(char *msg){
  458. char *pName;
  459. sutPocStatus.ListCurOnlineNum=strtol(&msg[6],&pName,16);
  460. sutPocStatus.ListUpdate=1;
  461. MSG_INFO(1, "userNum:%d", sutPocStatus.ListCurOnlineNum);
  462. }
  463. /*瀹氶噺鏌ヨ�鎵€鍦ㄧ兢缁勪腑鐨勫湪绾挎垚鍛樹俊鎭�搷搴?
  464. 鍙慉T+POC=1E0000xxxxx鑾峰緱
  465. msg:010000,iiii(鎴愬憳鍒楄〃绱㈠紩),dddddddd(鎴愬憳ID),mmmmmmmm(鎴愬憳鍚嶇О)*/
  466. static void pro1eMsg(char *msg){
  467. char name[POC_GROUP_USER_NAME_LEN*2+1];
  468. int len;
  469. unsigned long id;
  470. char *pTemp;
  471. if(!uiAssist.status)return 1;
  472. len = strlen(&msg[18]);
  473. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  474. memcpy(name, &msg[18], len);
  475. name[len]=0;
  476. msg[18]=0;
  477. id=strtol(&msg[10],&pTemp,16);
  478. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
  479. if(name[0]==0){
  480. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
  481. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
  482. }else StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  483. sutPocStatus.ListFillIndex++;
  484. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  485. sutPocStatus.ListGetOneFlag=1;
  486. sutPocStatus.ListDetailValid=1;
  487. }
  488. }
  489. /*瀹氭椂鏌ヨ�鎵€灞炵粍淇℃伅
  490. 鍙慉T+POC=1D0000xxxxx鑾峰緱
  491. msg:000000,iiii(缁勫垪琛ㄧ储寮?,dddddddd(缁処D),nnnn(鎴愬憳涓�暟),mmmmmmmmm(鍚嶇О)*/
  492. static void pro1dMsg(char *msg){
  493. unsigned short num;
  494. char name[POC_GROUP_USER_NAME_LEN*2+1];
  495. unsigned long id;
  496. unsigned short index;
  497. char *pTemp;
  498. int len;
  499. if(!uiAssist.status)return ;
  500. len = strlen(&msg[22]);//瀹告彃骞撻幒澶婃礀鏉烇附宕茬悰?
  501. if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2;
  502. memcpy(name, &msg[22], len);
  503. name[len]=0;
  504. msg[22]=0;
  505. num=strtol(&msg[18],&pTemp,16);
  506. msg[18]=0;
  507. id=strtol(&msg[10],&pTemp,16);
  508. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=id;
  509. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].usernum=num;
  510. if(name[0]==0){
  511. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
  512. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[1]=0;
  513. }else
  514. StrAsciiToHex(name, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
  515. sutPocStatus.ListFillIndex++;
  516. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  517. sutPocStatus.ListGetOneFlag=1;
  518. sutPocStatus.ListDetailValid=1;
  519. }
  520. }
  521. /*
  522. +POC_VER:01027
  523. msg=01027
  524. */
  525. static void pocGetVer(char *msg){
  526. snprintf(sutApp.pocVersion, sizeof(sutApp.pocVersion), "%s",msg);
  527. }
  528. /*
  529. +NOTE:0,1
  530. msg=0,1+鍥炶溅
  531. */
  532. static void proNoteMsg(char *msg){
  533. MSG_INFO(1,"authAck:%s",msg);
  534. }
  535. /*
  536. +CTEC: 0,0
  537. msg=0,0
  538. */
  539. static void proNetMode(char *msg){
  540. unsigned char netModeValue;
  541. char cmd[30];
  542. if(msg[0]<'0' || msg[0]>'9') return;
  543. netModeValue=atoi(msg);
  544. ctecCurrentSet=netModeValue;
  545. if(ctecCurrentSet != newPara.netMode){
  546. snprintf(cmd, sizeof(cmd),"AT+CTEC=%d,%d\r\n", ctecCurrentSet, newPara.netMode);
  547. msgAtSend(cmd);
  548. }
  549. }
  550. /*
  551. +COPS: 0,2,"46000",7
  552. msg=+COPS: 0,2,"46000",7
  553. */
  554. static void proCopsMsg(char *msg){
  555. int i,j=0,codeType;
  556. char w=0;
  557. unsigned char netModeValue;
  558. for(i=0;i<strlen(msg);i++){
  559. if(msg[i]==','){
  560. if(++j==3){
  561. codeType=msg[i+1]-0x30;
  562. if(codeType==7) codeType=4;
  563. if(netshowvalue!=codeType) netshowvalue=codeType;
  564. return;
  565. }
  566. }else if(msg[i]=='"'){
  567. if(++w==1){
  568. codeType=atoi(msg+i+1);
  569. if(codeType>0 && codeType != sutApp.copstype) sutApp.copstype=codeType;
  570. }
  571. }
  572. }
  573. }
  574. /*
  575. +SIMCROSS:0
  576. msg=0/1
  577. */
  578. static void proSimMode(char *msg){
  579. unsigned char tmpSim;
  580. tmpSim=msg[0]-0x30;
  581. if(tmpSim!=0 && tmpSim!=1) return;
  582. sutApp.simSel=tmpSim;
  583. }
  584. /*
  585. +FOTA:1,0
  586. +FOTA:1,XXX
  587. +FOTA:0
  588. +FOTA:1
  589. +FOTA:2
  590. msg=1,xxxx
  591. */
  592. static void proFotaMsg(char *msg){
  593. if(msg[1]==','){
  594. if(msg[2]=='0' && msg[3]==0) sutApp.fotaStatus=1;
  595. else{
  596. strcpy(sutApp.fotaVersion, msg+2);
  597. sutApp.fotaStatus=2;
  598. }
  599. }else if(msg[1]==0){
  600. if(msg[0]=='0') sutApp.fotaStatus=3;
  601. else if(msg[0]=='1') sutApp.fotaStatus=4;
  602. else if(msg[0]=='2') sutApp.fotaStatus=5;
  603. }
  604. }
  605. /*
  606. SV63302_T02
  607. msg=SV63302_T02
  608. */
  609. static void proGmrMsg(char *msg){
  610. snprintf(sutApp.modemVer, sizeof(sutApp.modemVer), "%s", msg);
  611. }
  612. /*
  613. +SMS:1,B2E2CAD4313233
  614. msg=1,B2E2CAD4313233
  615. */
  616. static void proSmsMsg(char *msg){
  617. unsigned char smsType=msg[0]-0x30;
  618. unsigned len=strlen(msg+2);
  619. if(len%2 || 0!=restoreDataFormatByHex(msg+2,len)){
  620. MSG_WARN(1, "sms data error");
  621. return;
  622. }
  623. len /= 2;
  624. sutMess.codeType=smsType;
  625. sutSms.smsUpdate=1;
  626. memcpy(sutMess.GBKMess1+4, msg+2, len);
  627. }
  628. /*
  629. +CSQ: 14,99
  630. msg=14,99
  631. */
  632. static void proCsqMsg(char *msg){
  633. int csq=atoi(msg);
  634. if(csq != sutApp.g_iCSQ) sutApp.g_iCSQ=csq;
  635. }
  636. static void pro96Msg(char *msg){
  637. if(msg[10]=='0'){
  638. sutPocStatus.PaDlyStart=1;
  639. paControl(true);
  640. sutPocStatus.mic=1;
  641. }
  642. else if(msg[10]=='3'){
  643. paControl(true);
  644. backLightReset();
  645. sutPocStatus.logined=1;
  646. sutPocStatus.spk=1;
  647. sutPocStatus.mic=0;
  648. }else if(msg[10]=='4'){
  649. sutPocStatus.spk=0;
  650. sutPocStatus.TTS=0;
  651. sutPocStatus.PaDlyStart=1;
  652. }else if(msg[10]=='1'){
  653. sutPocStatus.PaDlyStart=1;
  654. sutPocStatus.mic=0;
  655. }
  656. }
  657. /*
  658. +POC:2800000016010A101F2401
  659. */
  660. static void pro28Msg(char *msg){
  661. char buf[20];
  662. if(msg[7]=='F' && msg[8]=='F')return;
  663. if(msg[5]=='2' && msg[6]=='8'){
  664. //PocGetTime=1;
  665. //+POC:2800000014040e10132002
  666. StrAsciiToHex(&msg[13],buf);
  667. My_Clock.year=buf[0];;
  668. My_Clock.month=buf[1];;
  669. My_Clock.day=buf[2];;
  670. My_Clock.hour=buf[3];;
  671. My_Clock.min=buf[4];;
  672. My_Clock.sec=buf[5];
  673. MSG_INFO(1,"NewTime:%02d-%02d-%02d %02d:%02d:%02d",
  674. My_Clock.year,My_Clock.month,My_Clock.day,
  675. My_Clock.hour,My_Clock.min,My_Clock.sec);
  676. sutApp.PocGetTime=1;
  677. return ;
  678. }
  679. }
  680. static void pro0dMsg(char *msg){
  681. if(sutUIstatus.Status!=UIS_MENU_GROUP_SEL)return;
  682. sutPocStatus.ListUpdate=1;
  683. sutPocStatus.ListDetailValid=1;
  684. sutPocStatus.ListCurOnlineNum=htoi(&msg[13])-1;
  685. if(sutPocStatus.danHuStatus!=0)sutPocStatus.ListCurOnlineNum--;// 鑼朵綑鍗曞懠鍘绘帀涓存椂缇ょ粍
  686. MSG_INFO(1, "groupNum:%d", sutPocStatus.ListCurOnlineNum);
  687. }
  688. static void pro0eMsg(char *msg){
  689. sutPocStatus.ListUpdate=1;
  690. sutPocStatus.ListDetailValid=1;
  691. sutPocStatus.ListCurOnlineNum=htoi(&msg[13])-1;
  692. if(sutPocStatus.danHuStatus!=0)sutPocStatus.ListCurOnlineNum--;// 鑼朵綑鍗曞懠鍘绘帀涓存椂缇ょ粍
  693. MSG_INFO(1, "friend:%d", sutPocStatus.ListCurOnlineNum);
  694. }
  695. //+POC:3b 00 0000 006c 0002 0001
  696. //+POC:3b000000006c00020001
  697. static void pro3bMsg (char *msg){
  698. char buf[40];
  699. if(msg[5]=='3' && msg[6]=='B'){
  700. if(sutPocStatus.NeedGetUser==0){
  701. sutPocStatus.ListUpdate=1;
  702. sutPocStatus.ListDetailValid=1;
  703. }
  704. sutPocStatus.ListCurOnlineNum =htoi(&msg[21]);
  705. msg[17]=0;
  706. sutPocStatus.UserSum= htoi(&msg[13]);
  707. if(sutPocStatus.NeedGetUser){
  708. snprintf(buf, sizeof(buf), "AT+POC=130000%08x0000006400000000\r\n",sutPocStatus.LocalGroup.ID);//默认成员100
  709. sutPocStatus.ListFillIndex=0;
  710. sutPocStatus.NeedGetUser=2;
  711. if(sutPocStatus.UserSum==0)sutPocStatus.NeedGetUser=0;
  712. msgAtSend(buf);
  713. //MSG_INFO(1,buf);
  714. }
  715. MSG_INFO(1, "UserSum:%d,UserOnline:%d",sutPocStatus.UserSum,sutPocStatus.ListCurOnlineNum);
  716. }
  717. }
  718. static void Pro7DMsg(char *msg){
  719. int i,j,len,ver;
  720. char bufTemp[40];
  721. len = strlen(msg);
  722. j=0;
  723. StrAsciiToHex(msg,bufTemp);
  724. strncpy(sutApp.pocVersion,bufTemp,sizeof(sutApp.pocVersion));
  725. }
  726. /*
  727. +HEADSET:1
  728. msg=1
  729. */
  730. void proHeadSet(char *msg){
  731. switch(msg[0]){
  732. case '0'://HEADSET CONNECT
  733. sutApp.earLev=1;
  734. //msgAtSend("AT+AUDCH=1,3\r\n");
  735. sutApp.pcant=2;
  736. VolMicUpdate();
  737. VolSpkUpdate();
  738. break;//HEADSET DISCONNECTED
  739. case '1':
  740. sutApp.earLev=0;
  741. //msgAtSend("AT+AUDCH=0,0\r\n");
  742. sutApp.pcant=4;
  743. VolMicUpdate();
  744. VolSpkUpdate();
  745. break;//HEADSET BTN PRESS
  746. case '2':
  747. micPttHandler(1);
  748. break;//HEADSET BTN RELEASED
  749. case '3':
  750. micPttHandler(0);
  751. break;
  752. }
  753. }
  754. /*
  755. +CCID: 898604851920C0133569
  756. msg=898604851920C0133569
  757. */
  758. void proCCIDMsg(char *msg){
  759. sutApp.cardStatus=1;
  760. msg[6]=0;
  761. sutApp.copstype=atoi(msg+4);
  762. }
  763. void LogoutOutTimeCheck(unsigned int interval){
  764. //鎺夌嚎鍚庤秴杩�3鍒嗛挓鍐嶇櫥褰曪紝闇€瑕佹挱鏀剧櫥褰曚俊鎭�
  765. static unsigned char lastLoginStatus=0;
  766. static unsigned int cnt=0;
  767. if(sutApp.reloginStatus == lastLoginStatus) return;
  768. if(sutApp.reloginStatus==0){//鐢卞湪绾垮彉鎴愭帀绾�
  769. if(++cnt>=(180000/interval)){
  770. cnt=0;
  771. sutApp.reloginTts=1;
  772. }
  773. }else{//鐢辨帀绾垮啀涓婄嚎
  774. cnt=0;
  775. }
  776. lastLoginStatus=sutApp.reloginStatus;
  777. }
  778. /*
  779. +CACCP: "04000a00"
  780. msg="04000a00"
  781. */
  782. static bool proMicGain(char *msg){
  783. if(0==strncmp(msg+1, "00000000", 8)) sutApp.audioReconfig=1;
  784. else sutApp.audioReconfig=0;
  785. MSG_INFO(1, ">>NeedReconfigAudio:%s", sutApp.audioReconfig?"yes":"no");
  786. return (sutApp.audioReconfig?true:false);
  787. }
  788. char *ohpocGetIMEI(void){
  789. static char imei[16]={0};
  790. if(imei[0]==0){
  791. if(LSAPI_SIM_GetIMEI(imei)==0){
  792. return imei;
  793. }
  794. }
  795. return NULL;
  796. }
  797. void ohpocGetClock(MY_CLOCK *myclock){
  798. return;
  799. }
  800. //+POC:8C00934C0008 2222222222//data: cmd data
  801. void pro8CMsg(char *msg){
  802. char buf[500];
  803. char temp[3]={0};
  804. char cmd=0;
  805. memcpy(temp,msg+17,2);
  806. cmd=htoi(temp);
  807. switch(cmd){
  808. case NULLCMD://信标
  809. Recv_PackNewxinbiaopage(msg);
  810. break;
  811. case YAOYUN:
  812. LeaderRecv_handler(msg,1);
  813. break;
  814. case YAOBI:
  815. LeaderRecv_handler(msg,2);
  816. break;
  817. case GPSALLON:
  818. break;
  819. }
  820. }