PocTask.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. #include "includes.h"
  2. int g_iModemVer=0;
  3. unsigned char g_iPocVer[20];
  4. SUT_POC_STATUS sutPocStatus;
  5. unsigned char danhureport[POC_GROUP_NAME_LEN];
  6. unsigned long g_ulGroupID;
  7. //+POC:1D00000000000000539B000BC4ACC8CFC8BAD7E9
  8. int GetAllGroups(char *msg)
  9. {
  10. unsigned short num;
  11. char name[POC_GROUP_NAME_LEN*2+1];
  12. unsigned long id;
  13. unsigned short index;
  14. char *pTemp;
  15. unsigned char len;
  16. // 当前index 组ID 组内成员个数 组名
  17. //+POC:1D000000 0001 0000539C 000B B2E2CAD4D7E931
  18. //成员查询 当前index 成员ID 成员名
  19. //+POC:1E010000 0000 0001CC49 3237
  20. if(msg[5]=='1' && msg[6]=='D'){
  21. if(!uiAssist.status)return 1;
  22. len = strlen(&msg[29])-2;
  23. if(len >= POC_GROUP_NAME_LEN*2) len = POC_GROUP_NAME_LEN*2;
  24. memcpy(name, &msg[29], len);
  25. name[len]=0;
  26. //组内成员个数
  27. msg[29]=0;
  28. num=strtol(&msg[25],&pTemp,16);
  29. //组ID
  30. msg[25]=0;
  31. id=strtol(&msg[17],&pTemp,16);
  32. //添加
  33. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=id;
  34. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].usernum=num;
  35. if(name[0]==0)
  36. {//当模块吐出来的名字为空时,自动添加为空格,防止显示时会死掉
  37. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
  38. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[1]=0;
  39. }else
  40. StrAsciiToHex(name, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
  41. //printf("name====%s\r\n",sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
  42. sutPocStatus.ListFillIndex++;
  43. // printf("ListFillIndex==%d,ExceptionReadNum-==%d---------\r\n",sutPocStatus.ListFillIndex,sutPocStatus.ExceptionReadNum);
  44. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  45. sutPocStatus.ListGetOneFlag=1;
  46. //printf("ListGetOneFlag==1----------\r\n");
  47. }
  48. return 1;
  49. }
  50. //+POC:groups,3,1,1,112213,4B6DD58BA47FC47E31000000
  51. if(0==ModemStrCmp(msg,"+POC:groups,"))
  52. {
  53. index=IndexReturnBySymbol(msg,',',4);
  54. sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=atoi(&msg[index]);
  55. index=IndexReturnBySymbol(msg,',',5);
  56. ExchangeHighLowByte(&msg[index],strlen(&msg[index])-2);
  57. StrUnicodeToAnsi(sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name,strlen(&msg[index])-2,&msg[index]);
  58. sutPocStatus.ListFillIndex++;
  59. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  60. sutPocStatus.ListGetOneFlag=1;
  61. //printf("ListGetOneFlag==1----------\r\n");
  62. }
  63. return 1;
  64. }
  65. return 0;
  66. }
  67. int GetAllUsers(char *msg)
  68. {
  69. unsigned short num;
  70. char name[POC_USER_NAME_LEN*2+1];
  71. unsigned long id;
  72. unsigned short index;
  73. char *pTemp;
  74. unsigned char len;
  75. //成员查询 当前index 成员ID 成员名
  76. //+POC:1E010000 0000 0001CC49 3237
  77. if(msg[5]=='1' && msg[6]=='E'){
  78. if(!uiAssist.status)return 1;
  79. len = strlen(&msg[25])-2;
  80. if(len >= POC_USER_NAME_LEN*2) len = POC_USER_NAME_LEN*2;
  81. memcpy(name, &msg[25], len);
  82. name[len]=0;
  83. // //
  84. // msg[29]=0;
  85. // num=strtol(&msg[25],&pTemp,16);
  86. //成员ID
  87. msg[25]=0;
  88. id=strtol(&msg[17],&pTemp,16);
  89. //添加
  90. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
  91. //sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].usernum=num;
  92. if(name[0]==0)
  93. {//当模块吐出来的名字为空时,自动添加为空格,防止显示时会死掉
  94. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
  95. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
  96. }else
  97. StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  98. // printf("Username====%s\r\n",sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  99. sutPocStatus.ListFillIndex++;
  100. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum)sutPocStatus.ListGetOneFlag=1;
  101. return 1;
  102. }
  103. //+POC:members,4,0,1,65985,2875376230000000 总数4 索引0 状态1(1-离线2--在线不在本组 3在线在组) ID 名称
  104. if(0==ModemStrCmp(msg,"+POC:members,"))
  105. {
  106. index=IndexReturnBySymbol(msg,',',3);
  107. if(atoi(&msg[index])!=3)return 1;
  108. index=IndexReturnBySymbol(msg,',',4);
  109. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=atoi(&msg[index]);
  110. index=IndexReturnBySymbol(msg,',',5);
  111. ExchangeHighLowByte(&msg[index],strlen(&msg[index])-2);
  112. StrUnicodeToAnsi(sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name,strlen(&msg[index])-2,&msg[index]);
  113. sutPocStatus.ListFillIndex++;
  114. if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){
  115. sutPocStatus.ListGetOneFlag=1;
  116. //printf("ListGetOneFlag==1----------\r\n");
  117. }
  118. return 1;
  119. }
  120. return 0;
  121. }
  122. char PocHandle(char *msg)
  123. {
  124. uint8_t temp[4];
  125. SUTDS ds;
  126. SUTDL dl;
  127. char buf[102];//100
  128. char *pName;
  129. unsigned char len,type;
  130. char pGroup[POC_GROUP_NAME_LEN*2]={0};
  131. static int Table[POC_GROUP_NAME_LEN*2]={0};
  132. unsigned short Index=0;
  133. int i;
  134. static unsigned char getNameFlag=0;
  135. static char Username[POC_USER_NAME_LEN+1];//因为播报时是先存了用户名,后面才存群组名,然后一起播报,故此值要是静态的,否则有时用户名会播报不出来
  136. char Groupname[POC_GROUP_NAME_LEN+1];
  137. //=============+LSHTTS: END
  138. if(msg[1]=='L' && msg[2]=='S' && msg[3]=='H' && msg[4]=='T' && msg[9]=='E'){
  139. sutPocStatus.TTS=0;
  140. if(sutPocStatus.Speaker==0)SpeakerDisable();
  141. return 1;
  142. }
  143. //+POC:0BXXYYYY
  144. //请求PTT返回
  145. //XX:00请求成功,可以不处理,因为同时有8Bxxyy回来处理打开喇叭
  146. //XX:FF请求失败,播报特tone音,与抢麦失败一样
  147. //YYYY:操作ID,不处理
  148. if(msg[5] == '0' && msg[6] == 'B')
  149. {
  150. // if(msg[7] == 'F' && msg[8] == 'F')
  151. // {
  152. // SpeakerEnable();
  153. // SetBeep(1000,10);
  154. // }
  155. // else if(msg[7] == '0' && msg[8] == '0')
  156. // {
  157. // sutPocStatus.Mic=1;
  158. // SpeakerEnable();
  159. // SetBeep(500,10);
  160. // //SlwTrace(INF, "Speak",1);
  161. // }
  162. return 1;
  163. }
  164. //+TONEON
  165. if(msg[5] == 'T' && msg[6] == 'O')
  166. {
  167. if(msg[7] == 'N' && msg[8] == 'E')
  168. {
  169. SpeakerEnable();
  170. uTimerCreate(UTIMER_BEEP,20);
  171. }
  172. return 1;
  173. }
  174. //+POC:8bxxyy
  175. //xx--mic控制 01--打开MIC
  176. // 00--关闭MIC
  177. //yy--speaker控制
  178. // 00--关闭speaker并要产生成功的滴音
  179. // 01--对方说话,打开speaker,并产生成功的滴音
  180. // 13--抢麦失败,打开speaker,并产生失败的滴音
  181. if(msg[5]=='8' && msg[6]=='B')
  182. {
  183. if( msg[7]=='0'&& msg[8]=='1')//xx == 01
  184. {
  185. enableDataSend();
  186. sutPocStatus.Mic=1;
  187. MicEnable();
  188. //SpeakerEnable();wjl
  189. //SetBeep(500,10);
  190. //uTimerCreate(UTIMER_BEEP,20);//wjl
  191. sutPocStatus.Speaker=0;
  192. //SpeakerDisable();
  193. sutPocStatus.Logined=1;
  194. }else if( msg[9]=='0'&& msg[10]=='2'){
  195. SpeakerEnable();
  196. }else if(msg[9]=='0' && msg[10] == '1')
  197. {//yy == 00 对方说话开始
  198. SpeakerEnable();
  199. enableDataSend();
  200. LCDBackLight(1);
  201. LcdOnTimeCt=0;
  202. ///////////////////
  203. //uTimerCreate(UTIMER_BEEP,20);
  204. // SetBeep(500,10);
  205. sutPocStatus.Logined=1;
  206. sutPocStatus.Speaker=1;
  207. sutPocStatus.Mic=0;
  208. // if(newPara.KeySound!=0){
  209. // SetBeep(500,10);
  210. // }
  211. }else if(msg[7]=='0'&& msg[8]=='0'&& msg[9]=='0' && msg[10] == '0')//xx == 00
  212. {
  213. sutPocStatus.Speaker=0;
  214. sutPocStatus.Mic=0;
  215. //SpeakerEnable();//wjl
  216. SpeakerDisable();//wjl
  217. //SetBeep(500,10);
  218. //uTimerCreate(UTIMER_BEEP,20);//wjl
  219. }
  220. if(msg[9]=='1' && msg[10]=='3')
  221. {
  222. //yy == 13 抢麦不成功滴音
  223. sutPocStatus.statusChaned=1;
  224. //sutPocStatus.Speaker=1;//3;//屏蔽掉后:能达到修改记录中的第6点
  225. SpeakerEnable();
  226. SetBeep(1000,10);
  227. }
  228. return 1;
  229. }
  230. //==============+POC:xxxx=============
  231. //+POC:820100000000 +POC:8201ffffffff
  232. //+POC:82 02 00002c8d 4b6dd58b3100300032000000 登陆成功,提示“测试102”
  233. //+POC:82 02 0000D590 B5E7C1BFB2E2CAD432 登陆成功 提示"电量测试2"
  234. if(msg[5]=='8' && msg[6]=='2')
  235. {
  236. buf[0] = msg[7];
  237. buf[1] = msg[8];
  238. buf[2] = 0;
  239. type = atoi(buf);
  240. switch(type)
  241. {
  242. case 0://离线 ID无效
  243. //if(sutPocStatus.Logined) HigosStartCnt(1);
  244. sutPocStatus.danHunStatus=0;//掉线,清单呼显示状态为非单呼状态
  245. sutPocStatus.Logined=0;
  246. sutGpsInfo.isGpsAuthOk=0;
  247. snprintf(buf, sizeof(buf),"[msg]");
  248. if(msg[17] == 'B' && msg[18]== '5' && msg[25] == 'C' && msg[26] == 'A')
  249. {//帐号信息错误
  250. pocTimeOutTime=5;
  251. sutPocStatus.loginResult=1;
  252. strcat(buf, "账号信息错误");
  253. }
  254. else
  255. if(msg[17] == 'C' && msg[18]== 'E' && msg[25] == 'C' && msg[26] == '2')
  256. {//无网络连接
  257. if(sutPocStatus.loginResult != 1)
  258. sutPocStatus.loginResult=2;
  259. strcat(buf, "无网络连接");
  260. }else if(msg[17] == 'C' && msg[18]== 'E' && msg[25] == 'C' && msg[26] == '1'){
  261. sutPocStatus.loginResult=5;
  262. strcat(buf, "无法连接");
  263. }else if(msg[17] == 'C' && msg[18]== '3' && msg[25] == 'B' && msg[26] == '7'){
  264. if(sutPocStatus.loginResult!=4) sutPocStatus.loginResult=6;
  265. strcat(buf, "没有服务");
  266. }
  267. else strcat(buf, "No login");
  268. SlwTrace(INF, buf, 1);
  269. break;
  270. case 1://登陆中 ID无效
  271. SlwTrace(INF, "login ing",1);
  272. break;
  273. case 2://登陆成功 ID为用户ID
  274. len = strlen(&msg[17])-2;
  275. if(len >= POC_USER_NAME_LEN) len = POC_USER_NAME_LEN;
  276. memcpy(Username,&msg[17],len);
  277. Username[len]=0;
  278. StrAsciiToHex(Username,sutPocStatus.LocalUser.name);
  279. msg[17]=0;
  280. sutPocStatus.LocalUser.ID=strtol(&msg[9],&pName,16);
  281. SlwTrace(INF, "login ok",1);
  282. getNameFlag=1;//登陆成功时,获取过了用户名字,后面可以播报了
  283. sutPocStatus.loginResult=3;
  284. break;
  285. case 3://注销中 ID无效
  286. SlwTrace(INF, "logout ing",1);
  287. break;
  288. }
  289. return 1;
  290. }
  291. //+POC:3D000003
  292. //+POC:3E000000 0001
  293. if(msg[5]=='3' && (msg[6]=='D'||msg[6]=='E')){
  294. sutPocStatus.ListCurOnlineNum=strtol(&msg[13],&pName,16);
  295. if(msg[6]=='E')sutPocStatus.UserOnLineNum=sutPocStatus.ListCurOnlineNum;
  296. sutPocStatus.ListUpdate=1;
  297. return 1;
  298. }
  299. //获取所有组列表,也就是处理+POC:80xxxs
  300. if(GetAllGroups(msg))return 1;
  301. if(GetAllUsers(msg))return 1;
  302. //获取所有成员列表,也就是处理+POC:81XXX
  303. //if(GetAllUsers(msg))return 1;
  304. //+POC:86 00 000000dc a47fc47e3300 0000 进入群组,提示“群组3”(群组ID为000000dc,群组名为“群组3”即a47fc47e3300)
  305. // 86 00 0000009a d89ea48ba47fc47e0000 默认群组
  306. //+POC:86 00 00000366 0000
  307. if(msg[5]=='8' && msg[6]=='6')
  308. {//----获取本机当前群组名及群组ID
  309. //HigosStopCnt();//正常登陆了,停止计数
  310. sutPocStatus.Logined=1;
  311. pocTimeOutTime=30;
  312. if(msg[8] == '0')
  313. {//GB2312
  314. len = strlen(&msg[17])-2;
  315. if(len >= POC_GROUP_NAME_LEN) len = POC_GROUP_NAME_LEN;
  316. memcpy(Groupname,&msg[17],len);
  317. Groupname[len]=0;
  318. msg[17]=0;
  319. sutPocStatus.LocalGroup.ID=strtol(&msg[9],&pName,16);
  320. StrAsciiToHex(Groupname,sutPocStatus.LocalGroup.name);
  321. if(sutPocStatus.FirstLogined==0)
  322. {//登陆成功用户名群组名只播报一次
  323. if(getNameFlag == 0)
  324. snprintf(buf, sizeof(buf), "%s",sutPocStatus.LocalGroup.name);
  325. else
  326. {
  327. getNameFlag=0;
  328. //snprintf(buf, sizeof(buf), "%s2CD2D1B5C7C2BD2C%s",Username,Groupname);
  329. snprintf(buf, sizeof(buf), "%s,已登录,%s",sutPocStatus.LocalUser.name,sutPocStatus.LocalGroup.name);
  330. }
  331. MeSpeak(ENCODE_ASCII, buf);
  332. }else
  333. {//其它形式进入
  334. if(g_ucEnterGroupFlag==1)
  335. {
  336. g_ucEnterGroupFlag=0;
  337. snprintf(buf, sizeof(buf), "进入,%s",sutPocStatus.LocalGroup.name);
  338. MeSpeak(ENCODE_ASCII, buf);
  339. }
  340. }
  341. }
  342. LcdOnTimeCt=0;
  343. sutPocStatus.danHunStatus=0;//收到这个直接设置为非单呼模式,否在会在单呼模式下如果被创建了临时群组,之后会一直显示单呼模式
  344. //if(sutPocStatus.FirstLogined==0) ModemSendAt("AT+CCLK?\r\n");
  345. sutPocStatus.FirstLogined=1;
  346. return 1;
  347. }
  348. //+POC:830000002e650000 对方话语权
  349. //+POC:83000000420c330067004b6dd58b3200f7530000
  350. //+POC:8300000045544800530031003500310057004b6dd58b300033000000
  351. //+POC:83000000D592 303738
  352. if(msg[5]=='8' && msg[6]=='3' && msg[7]=='0' && msg[8]=='0')
  353. {
  354. //最新POC版本快速短按PTT放开会只发这条过来,实际是没有请麦来的
  355. //因此不做灯与喇叭,LCD背光等控制
  356. ReplaceStrWithN(&msg[17]);
  357. //如果他只发ID不发对方名,要记得修改防护
  358. i=strlen(&msg[17]);
  359. if(i>=POC_USER_NAME_LEN) i=POC_USER_NAME_LEN;
  360. else i++;//把0结束也拷过去
  361. StrAsciiToHex(&msg[17], sutPocStatus.Callname);
  362. *(msg+17) = 0;
  363. sutPocStatus.CallID = strtol(&msg[9],&pName,16);
  364. msg[17]=0;
  365. return 1;
  366. }
  367. //+POC:8301ffffffff0000 对方释放话语权
  368. if(msg[5]=='8' && msg[6]=='3' && msg[7]=='0' && msg[8]=='1'){
  369. //最新POC版本目前没有这条指令,也忽视吧
  370. // sutPocStatus.Speaker=0;
  371. // SpeakerDisable();
  372. return 1;
  373. }
  374. //+POC:91010103
  375. if(msg[5]=='9' && msg[6]=='1'){
  376. //PocAddUserStatusToList(&msg[7]);
  377. return 1;
  378. }
  379. //+POC:0E00 0000 0002
  380. if(msg[5]=='0'&& msg[6]=='E'){
  381. msg[17]=0;
  382. StrAsciiToHex(&msg[13], temp);
  383. ds.Data.ucData.b1=temp[1];
  384. ds.Data.ucData.b2=temp[2];
  385. sutPocStatus.UserOnLineNum=ds.Data.usData;
  386. sutPocStatus.UserNum_Update=1;
  387. snprintf(buf, sizeof(buf), "oneLine:%d",sutPocStatus.UserOnLineNum);
  388. SlwTrace(INF, buf, 1);
  389. }
  390. //+POC:84 00 xxx //单呼提示
  391. if(msg[5]=='8' && msg[6]=='4')
  392. {
  393. MakeStrEndByNewLine(msg);
  394. StrAsciiToHex(&msg[9],danhureport);
  395. MeSpeak(ENCODE_ASCII , danhureport);
  396. //MeSpeak(ENCODE_ASCII , &msg[9]);
  397. //检测是哪种单呼
  398. if(memcmp(&msg[9], "C1D9CAB1", 8)==0)
  399. {//临时呼叫xxxx 被呼成功
  400. sutPocStatus.danHunStatus=1;//进入单显示
  401. }else if(memcmp(&msg[9], "CDCBB3F6", 8)==0)
  402. {//退出临时呼叫 退出单呼状态
  403. sutPocStatus.danHunStatus=0;
  404. }else if(memcmp(&msg[9], "BAF4BDD0B3C9B9A6", 16)==0)
  405. {//呼叫成功 主单呼
  406. sutPocStatus.danHunStatus=1;
  407. }
  408. return 1;
  409. }
  410. //+POC:1000000007 0004 00000BF9 0003 D1D0B7A2B2E2CAD4D7E93030
  411. //+POC:1000000008 0004 00000BF9 0003 D1D0B7A2B2E2CAD4D7E93030
  412. // 组索引 组ID 成员数 组名字
  413. //xxxxxxxx 4字节ID
  414. //nnnnnnnn 名称
  415. if(msg[5] == '1' &&
  416. msg[7] == '0' &&
  417. (msg[14] == '7' || msg[14] == '8'))
  418. {
  419. memset(sutPocStatus.GroupIdTemp, 0, POC_USER_ID_LEN);
  420. memcpy(sutPocStatus.GroupIdTemp, &msg[19], POC_USER_ID_LEN-1); //-1
  421. memcpy(sutPocStatus.switchGroupID,&msg[19], 8);
  422. MakeStrEndByNewLine(&msg[31]);
  423. //MeSpeak(ENCODE_GBK, &msg[31]);
  424. g_ucEnterGroupFlag=1;
  425. SpeakerCtrl(1);
  426. snprintf(buf, sizeof(buf),"AT+POC=090000%s\r\n",sutPocStatus.GroupIdTemp);
  427. ModemSendAt(buf);
  428. return 1;
  429. }
  430. //+POC:21 000000 0000D590 B5E7C1BFB2E2CAD432
  431. //+POC:21 000000 0001CC4B BAECC0F0D3E3D3EBC2CCC0F0D3E3D1BD
  432. // 关键字 保留 UID 名称
  433. if(msg[5]=='2' && msg[6]=='1'){
  434. MakeStrEndByNewLine(msg);
  435. //MeSpeak(ENCODE_GBK ,"B5E7C1BFB2E2CAD432",0);
  436. MeSpeak(ENCODE_GBK , &msg[21]);
  437. msg[21]=0;
  438. strncpy(sutPocStatus.UserIdTemp,&msg[13],POC_USER_ID_LEN);
  439. return 1;
  440. }
  441. // if(0==ModemStrCmp(msg,"+POC:naud"))
  442. // {
  443. // if(msg[10]=='1')SpeakerEnable();
  444. // else if(msg[10]=='0')SpeakerDisable();
  445. // return 1;
  446. // }
  447. if(0==ModemStrCmp(msg,"+LSPA:"))
  448. {
  449. if(msg[7]=='1'){
  450. ModemSendAt("AT+LSPA=1,1\r\n");
  451. SpeakerEnable();
  452. ModemSendAt("AT+LSPA=1,2\r\n");
  453. LCDBackLight(1);
  454. LcdOnTimeCt=0;
  455. }
  456. else if(msg[7]=='0'){
  457. ModemSendAt("AT+LSPA=1,3\r\n");
  458. SpeakerDisable();
  459. ModemSendAt("AT+LSPA=1,4\r\n");
  460. }
  461. return 1;
  462. }
  463. if(0==ModemStrCmp(msg,"+POC:nloginstat,2,"))
  464. {
  465. Index=IndexReturnBySymbol(msg,',',2);
  466. sutPocStatus.LocalUser.ID = atoi(&msg[Index]);
  467. Index=IndexReturnBySymbol(msg,',',3);
  468. sutPocStatus.LocalUser.ID = atoi(&msg[Index]);
  469. printf("len====%d\r\n",strlen(&msg[Index])-2);
  470. memset(Username,0,sizeof(Username));
  471. ExchangeHighLowByte(&msg[Index],strlen(&msg[Index])-2);
  472. StrUnicodeToAnsi(Username,strlen(&msg[Index])-2,&msg[Index]);
  473. printf("------%s\r\n",Username);
  474. strcpy(sutPocStatus.LocalUser.name,Username);
  475. return 1;
  476. }
  477. if(0==ModemStrCmp(msg,"+POC:nloginstat,1"))
  478. {
  479. sutPocStatus.Logined=0;
  480. return 1;
  481. }
  482. if(0==ModemStrCmp(msg,"+POC:groupnum,"))
  483. {
  484. Index=IndexReturnBySymbol(msg,',',2);
  485. sutPocStatus.ListCurOnlineNum=atoi(&msg[Index]);
  486. sutPocStatus.ListUpdate=1;
  487. sutPocStatus.UserNum_Update=1;
  488. snprintf(buf, sizeof(buf), "oneLine:%d",sutPocStatus.ListCurOnlineNum);
  489. SlwTrace(INF, buf, 1);
  490. return 1;
  491. }
  492. if(0==ModemStrCmp(msg,"+POC:membernum,"))
  493. {
  494. //+POC:membernum,1,5,3,2 总数 5,在线个数 3,在线且在本组个数 2
  495. Index=IndexReturnBySymbol(msg,',',4);
  496. sutPocStatus.ListCurOnlineNum=atoi(&msg[Index]);
  497. sutPocStatus.ListUpdate=1;
  498. sutPocStatus.UserNum_Update=1;
  499. snprintf(buf, sizeof(buf), "oneLine:%d",sutPocStatus.ListCurOnlineNum);
  500. SlwTrace(INF, buf, 1);
  501. return 1;
  502. }
  503. if(0==ModemStrCmp(msg,"+POC:ncurrgroup,0"))
  504. {
  505. sutPocStatus.Logined=1;
  506. sutPocStatus.FirstLogined=1;
  507. sutPocStatus.danHunStatus=0;
  508. Index=IndexReturnBySymbol(msg,',',2);
  509. sutPocStatus.LocalGroup.ID = atoi(&msg[Index]);
  510. Index=IndexReturnBySymbol(msg,',',3);
  511. printf("len====%d\r\n",strlen(&msg[Index])-2);
  512. printf("content====%s\r\n",&msg[Index]);
  513. memset(Groupname,0,sizeof(Groupname));
  514. /*先高低字节转换*/
  515. ExchangeHighLowByte(&msg[Index],strlen(&msg[Index])-2);
  516. StrUnicodeToAnsi(Groupname,strlen(&msg[Index])-2,&msg[Index]);
  517. //StrUnicodeToAnsi(Groupname,12,"a47fc47e6b51");
  518. for(i=0;i<strlen(Groupname);i++)
  519. {
  520. printf("%02x",Groupname[i]);
  521. }
  522. printf("\r\n");
  523. strcpy(sutPocStatus.LocalGroup.name,Groupname);
  524. return 1;
  525. }
  526. if(0==ModemStrCmp(msg,"+POC:ncurrgroup,2"))sutPocStatus.danHunStatus=1;
  527. /*
  528. //请麦
  529. AT+POC=ptt,1
  530. 请麦成功: +POC: ptt,1,1
  531. 请麦失败: +POC:ptt,0,1
  532. //放麦
  533. AT+POC=ptt,0
  534. 放麦成功: +POC: ptt,1,0
  535. 放麦失败: +POC:ptt,0,0
  536. */
  537. if(0==ModemStrCmp(msg,"+POC:ptt,1")){
  538. Index=IndexReturnBySymbol(msg,',',2);
  539. sutPocStatus.Mic= atoi(&msg[Index]);
  540. }
  541. /*
  542. //+POC:nspk,0,2099357,30003100340031000000
  543. StrAsciiToHex(&msg[17], sutPocStatus.Callname);
  544. *(msg+17) = 0;
  545. sutPocStatus.CallID = strtol(&msg[9],&pName,16);
  546. msg[17]=0;
  547. */
  548. if(0==ModemStrCmp(msg,"+POC:nspk,0")){
  549. Index=IndexReturnBySymbol(msg,',',2);
  550. if(0==atoi(&msg[Index]))return 1;
  551. sutPocStatus.CallID= atoi(&msg[Index]);
  552. Index=IndexReturnBySymbol(msg,',',3);
  553. ExchangeHighLowByte(&msg[Index],strlen(&msg[Index])-2);
  554. StrUnicodeToAnsi(sutPocStatus.Callname,strlen(&msg[Index])-2,&msg[Index]);
  555. sutPocStatus.Speaker=1;
  556. }
  557. if(0==ModemStrCmp(msg,"+POC:nspk,1")){
  558. sutPocStatus.Speaker=0;
  559. }
  560. //+POC:nuserchanged,1880496172,2099354,5
  561. if(0==ModemStrCmp(msg,"+POC:nuserchanged")){
  562. // Index=IndexReturnBySymbol(msg,',',3);
  563. // if(atoi(&msg[Index])==5)sutPocStatus.danHunStatus=1;
  564. // else if(atoi(&msg[Index])==2)sutPocStatus.danHunStatus=0;
  565. }
  566. //+POC:ngps,1,30
  567. // if(0==ModemStrCmp(msg,"+POC:ngps")){
  568. // Index=IndexReturnBySymbol(msg,',',1);
  569. // g_uiGpsStat=atoi(&msg[Index]);
  570. // return 1;
  571. // }
  572. // //ptt,1
  573. // if(0==ModemStrCmp(msg,"ptt,1")){
  574. // SpeakerEnable();
  575. // }
  576. return 0;
  577. }
  578. void ExchangeHighLowByte(char *src,unsigned short lenth)
  579. {
  580. unsigned short i;
  581. unsigned char temp;
  582. for(i=0;i<lenth;i+=4)
  583. {
  584. temp=src[i];
  585. src[i]=src[i+2];
  586. src[i+2]=temp;
  587. temp=src[i+1];
  588. src[i+1]=src[i+3];
  589. src[i+3]=temp;
  590. }
  591. }
  592. char IndexReturnBySymbol(char *src,char Symbol,char num)
  593. {
  594. char i=0;
  595. char index=0;
  596. while(*src){
  597. if(*src==Symbol) i++;
  598. src++;
  599. index++;
  600. if(num==i)return index;
  601. }
  602. return 0;
  603. }
  604. /******************************************************************************
  605. *******************************************************************************/
  606. void TTSdaxieguibi(char *src) //
  607. {
  608. int srclen;
  609. unsigned char *p;
  610. int i,j;
  611. char flag=0;
  612. char buf[300];//100
  613. memset(buf,0,sizeof(buf));
  614. srclen=strlen(src);
  615. p=(unsigned char *)src;
  616. i=0;
  617. j=0;
  618. while(i<(srclen)){
  619. if(*p>0x9f){
  620. if(flag){
  621. buf[j++]=',';
  622. flag=0;
  623. }
  624. buf[j++]=*p;
  625. p+=1;
  626. buf[j++]=*p;
  627. p+=1;
  628. i+=2;
  629. }else{
  630. if((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z')){
  631. flag=1;
  632. }
  633. else flag=0;
  634. buf[j]=*p;
  635. p+=1;
  636. i+=1;
  637. j+=1;
  638. }
  639. }
  640. buf[j]=0;
  641. // printf("buf====%s\r\n",buf);
  642. ModemSendAt(buf);
  643. }