PocTask.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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'||msg[8]=='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. if(msg[5]=='3' && (msg[6]=='D'||msg[6]=='E')){
  293. sutPocStatus.ListCurOnlineNum=strtol(&msg[13],&pName,16);
  294. sutPocStatus.ListUpdate=1;
  295. return 1;
  296. }
  297. //获取所有组列表,也就是处理+POC:80xxxs
  298. if(GetAllGroups(msg))return 1;
  299. if(GetAllUsers(msg))return 1;
  300. //获取所有成员列表,也就是处理+POC:81XXX
  301. //if(GetAllUsers(msg))return 1;
  302. //+POC:86 00 000000dc a47fc47e3300 0000 进入群组,提示“群组3”(群组ID为000000dc,群组名为“群组3”即a47fc47e3300)
  303. // 86 00 0000009a d89ea48ba47fc47e0000 默认群组
  304. //+POC:86 00 00000366 0000
  305. if(msg[5]=='8' && msg[6]=='6')
  306. {//----获取本机当前群组名及群组ID
  307. //HigosStopCnt();//正常登陆了,停止计数
  308. sutPocStatus.Logined=1;
  309. pocTimeOutTime=30;
  310. if(msg[8] == '0')
  311. {//GB2312
  312. len = strlen(&msg[17])-2;
  313. if(len >= POC_GROUP_NAME_LEN) len = POC_GROUP_NAME_LEN;
  314. memcpy(Groupname,&msg[17],len);
  315. Groupname[len]=0;
  316. msg[17]=0;
  317. sutPocStatus.LocalGroup.ID=strtol(&msg[9],&pName,16);
  318. StrAsciiToHex(Groupname,sutPocStatus.LocalGroup.name);
  319. if(sutPocStatus.FirstLogined==0)
  320. {//登陆成功用户名群组名只播报一次
  321. if(getNameFlag == 0)
  322. snprintf(buf, sizeof(buf), "%s",sutPocStatus.LocalGroup.name);
  323. else
  324. {
  325. getNameFlag=0;
  326. //snprintf(buf, sizeof(buf), "%s2CD2D1B5C7C2BD2C%s",Username,Groupname);
  327. snprintf(buf, sizeof(buf), "%s,已登录,%s",sutPocStatus.LocalUser.name,sutPocStatus.LocalGroup.name);
  328. }
  329. MeSpeak(ENCODE_ASCII, buf);
  330. }else
  331. {//其它形式进入
  332. if(g_ucEnterGroupFlag==1)
  333. {
  334. g_ucEnterGroupFlag=0;
  335. snprintf(buf, sizeof(buf), "进入,%s",sutPocStatus.LocalGroup.name);
  336. MeSpeak(ENCODE_ASCII, buf);
  337. }
  338. }
  339. }
  340. LcdOnTimeCt=0;
  341. sutPocStatus.danHunStatus=0;//收到这个直接设置为非单呼模式,否在会在单呼模式下如果被创建了临时群组,之后会一直显示单呼模式
  342. //if(sutPocStatus.FirstLogined==0) ModemSendAt("AT+CCLK?\r\n");
  343. sutPocStatus.FirstLogined=1;
  344. return 1;
  345. }
  346. //+POC:830000002e650000 对方话语权
  347. //+POC:83000000420c330067004b6dd58b3200f7530000
  348. //+POC:8300000045544800530031003500310057004b6dd58b300033000000
  349. //+POC:83000000D592 303738
  350. if(msg[5]=='8' && msg[6]=='3' && msg[7]=='0' && msg[8]=='0')
  351. {
  352. //最新POC版本快速短按PTT放开会只发这条过来,实际是没有请麦来的
  353. //因此不做灯与喇叭,LCD背光等控制
  354. ReplaceStrWithN(&msg[17]);
  355. //如果他只发ID不发对方名,要记得修改防护
  356. i=strlen(&msg[17]);
  357. if(i>=POC_USER_NAME_LEN) i=POC_USER_NAME_LEN;
  358. else i++;//把0结束也拷过去
  359. StrAsciiToHex(&msg[17], sutPocStatus.Callname);
  360. *(msg+17) = 0;
  361. sutPocStatus.CallID = strtol(&msg[9],&pName,16);
  362. msg[17]=0;
  363. return 1;
  364. }
  365. //+POC:8301ffffffff0000 对方释放话语权
  366. if(msg[5]=='8' && msg[6]=='3' && msg[7]=='0' && msg[8]=='1'){
  367. //最新POC版本目前没有这条指令,也忽视吧
  368. // sutPocStatus.Speaker=0;
  369. // SpeakerDisable();
  370. return 1;
  371. }
  372. //+POC:91010103
  373. if(msg[5]=='9' && msg[6]=='1'){
  374. //PocAddUserStatusToList(&msg[7]);
  375. return 1;
  376. }
  377. //+POC:0E00 0000 0002
  378. if(msg[5]=='0'&& msg[6]=='E'){
  379. msg[17]=0;
  380. StrAsciiToHex(&msg[13], temp);
  381. ds.Data.ucData.b1=temp[1];
  382. ds.Data.ucData.b2=temp[2];
  383. sutPocStatus.UserOnLineNum=ds.Data.usData;
  384. sutPocStatus.UserNum_Update=1;
  385. snprintf(buf, sizeof(buf), "oneLine:%d",sutPocStatus.UserOnLineNum);
  386. SlwTrace(INF, buf, 1);
  387. }
  388. //+POC:84 00 xxx //单呼提示
  389. if(msg[5]=='8' && msg[6]=='4')
  390. {
  391. MakeStrEndByNewLine(msg);
  392. StrAsciiToHex(&msg[9],danhureport);
  393. MeSpeak(ENCODE_ASCII , danhureport);
  394. //MeSpeak(ENCODE_ASCII , &msg[9]);
  395. //检测是哪种单呼
  396. if(memcmp(&msg[9], "C1D9CAB1", 8)==0)
  397. {//临时呼叫xxxx 被呼成功
  398. sutPocStatus.danHunStatus=1;//进入单显示
  399. }else if(memcmp(&msg[9], "CDCBB3F6", 8)==0)
  400. {//退出临时呼叫 退出单呼状态
  401. sutPocStatus.danHunStatus=0;
  402. }else if(memcmp(&msg[9], "BAF4BDD0B3C9B9A6", 16)==0)
  403. {//呼叫成功 主单呼
  404. sutPocStatus.danHunStatus=1;
  405. }
  406. return 1;
  407. }
  408. //+POC:1000000007 0004 00000BF9 0003 D1D0B7A2B2E2CAD4D7E93030
  409. //+POC:1000000008 0004 00000BF9 0003 D1D0B7A2B2E2CAD4D7E93030
  410. // 组索引 组ID 成员数 组名字
  411. //xxxxxxxx 4字节ID
  412. //nnnnnnnn 名称
  413. if(msg[5] == '1' &&
  414. msg[7] == '0' &&
  415. (msg[14] == '7' || msg[14] == '8'))
  416. {
  417. memcpy(sutPocStatus.switchGroupID,&msg[19], 8);
  418. MakeStrEndByNewLine(&msg[31]);
  419. MeSpeak(ENCODE_ASCII, &msg[31]);
  420. return 1;
  421. }
  422. // if(0==ModemStrCmp(msg,"+POC:naud"))
  423. // {
  424. // if(msg[10]=='1')SpeakerEnable();
  425. // else if(msg[10]=='0')SpeakerDisable();
  426. // return 1;
  427. // }
  428. if(0==ModemStrCmp(msg,"+LSPA:"))
  429. {
  430. if(msg[7]=='1'){
  431. ModemSendAt("AT+LSPA=1,1\r\n");
  432. SpeakerEnable();
  433. ModemSendAt("AT+LSPA=1,2\r\n");
  434. LCDBackLight(1);
  435. LcdOnTimeCt=0;
  436. }
  437. else if(msg[7]=='0'){
  438. ModemSendAt("AT+LSPA=1,3\r\n");
  439. SpeakerDisable();
  440. ModemSendAt("AT+LSPA=1,4\r\n");
  441. }
  442. return 1;
  443. }
  444. if(0==ModemStrCmp(msg,"+POC:nloginstat,2,"))
  445. {
  446. Index=IndexReturnBySymbol(msg,',',2);
  447. sutPocStatus.LocalUser.ID = atoi(&msg[Index]);
  448. Index=IndexReturnBySymbol(msg,',',3);
  449. sutPocStatus.LocalUser.ID = atoi(&msg[Index]);
  450. printf("len====%d\r\n",strlen(&msg[Index])-2);
  451. memset(Username,0,sizeof(Username));
  452. ExchangeHighLowByte(&msg[Index],strlen(&msg[Index])-2);
  453. StrUnicodeToAnsi(Username,strlen(&msg[Index])-2,&msg[Index]);
  454. printf("------%s\r\n",Username);
  455. strcpy(sutPocStatus.LocalUser.name,Username);
  456. return 1;
  457. }
  458. if(0==ModemStrCmp(msg,"+POC:nloginstat,1"))
  459. {
  460. sutPocStatus.Logined=0;
  461. return 1;
  462. }
  463. if(0==ModemStrCmp(msg,"+POC:groupnum,"))
  464. {
  465. Index=IndexReturnBySymbol(msg,',',2);
  466. sutPocStatus.ListCurOnlineNum=atoi(&msg[Index]);
  467. sutPocStatus.ListUpdate=1;
  468. sutPocStatus.UserNum_Update=1;
  469. snprintf(buf, sizeof(buf), "oneLine:%d",sutPocStatus.ListCurOnlineNum);
  470. SlwTrace(INF, buf, 1);
  471. return 1;
  472. }
  473. if(0==ModemStrCmp(msg,"+POC:membernum,"))
  474. {
  475. //+POC:membernum,1,5,3,2 总数 5,在线个数 3,在线且在本组个数 2
  476. Index=IndexReturnBySymbol(msg,',',4);
  477. sutPocStatus.ListCurOnlineNum=atoi(&msg[Index]);
  478. sutPocStatus.ListUpdate=1;
  479. sutPocStatus.UserNum_Update=1;
  480. snprintf(buf, sizeof(buf), "oneLine:%d",sutPocStatus.ListCurOnlineNum);
  481. SlwTrace(INF, buf, 1);
  482. return 1;
  483. }
  484. if(0==ModemStrCmp(msg,"+POC:ncurrgroup,0"))
  485. {
  486. sutPocStatus.Logined=1;
  487. sutPocStatus.FirstLogined=1;
  488. sutPocStatus.danHunStatus=0;
  489. Index=IndexReturnBySymbol(msg,',',2);
  490. sutPocStatus.LocalGroup.ID = atoi(&msg[Index]);
  491. Index=IndexReturnBySymbol(msg,',',3);
  492. printf("len====%d\r\n",strlen(&msg[Index])-2);
  493. printf("content====%s\r\n",&msg[Index]);
  494. memset(Groupname,0,sizeof(Groupname));
  495. /*先高低字节转换*/
  496. ExchangeHighLowByte(&msg[Index],strlen(&msg[Index])-2);
  497. StrUnicodeToAnsi(Groupname,strlen(&msg[Index])-2,&msg[Index]);
  498. //StrUnicodeToAnsi(Groupname,12,"a47fc47e6b51");
  499. for(i=0;i<strlen(Groupname);i++)
  500. {
  501. printf("%02x",Groupname[i]);
  502. }
  503. printf("\r\n");
  504. strcpy(sutPocStatus.LocalGroup.name,Groupname);
  505. return 1;
  506. }
  507. if(0==ModemStrCmp(msg,"+POC:ncurrgroup,2"))sutPocStatus.danHunStatus=1;
  508. /*
  509. //请麦
  510. AT+POC=ptt,1
  511. 请麦成功: +POC: ptt,1,1
  512. 请麦失败: +POC:ptt,0,1
  513. //放麦
  514. AT+POC=ptt,0
  515. 放麦成功: +POC: ptt,1,0
  516. 放麦失败: +POC:ptt,0,0
  517. */
  518. if(0==ModemStrCmp(msg,"+POC:ptt,1")){
  519. Index=IndexReturnBySymbol(msg,',',2);
  520. sutPocStatus.Mic= atoi(&msg[Index]);
  521. }
  522. /*抢麦失败*/
  523. if(0==ModemStrCmp(msg,"+POC:ptt,0")){
  524. //Index=IndexReturnBySymbol(msg,',',2);
  525. sutPocStatus.Mic=0;
  526. //sutPocStatus.Speaker=0;
  527. }
  528. /*
  529. //+POC:nspk,0,2099357,30003100340031000000
  530. StrAsciiToHex(&msg[17], sutPocStatus.Callname);
  531. *(msg+17) = 0;
  532. sutPocStatus.CallID = strtol(&msg[9],&pName,16);
  533. msg[17]=0;
  534. */
  535. if(0==ModemStrCmp(msg,"+POC:nspk")){
  536. Index=IndexReturnBySymbol(msg,',',2);
  537. //if(0==atoi(&msg[Index]))return 1;
  538. sutPocStatus.CallID= atoi(&msg[Index]);
  539. Index=IndexReturnBySymbol(msg,',',3);
  540. //printf("msg===%s\r\n",&msg[Index]);
  541. if((0==ModemStrCmp(&msg[Index],"dd8b43677a7af2950000"))||(0==ModemStrCmp(&msg[Index],"2c673a670000"))){
  542. sutPocStatus.Speaker=0;
  543. //printf("Speaker==%d,MIC===%d\r\n",sutPocStatus.Speaker,sutPocStatus.Mic);
  544. }else if(0!=ModemStrCmp(sutPocStatus.Callname,&msg[Index])){
  545. ExchangeHighLowByte(&msg[Index],strlen(&msg[Index])-2);
  546. StrUnicodeToAnsi(sutPocStatus.Callname,strlen(&msg[Index])-2,&msg[Index]);
  547. // printf("sutPocStatus.Speaker==1\r\n");
  548. sutPocStatus.Mic=0;
  549. sutPocStatus.Speaker=1;
  550. }
  551. }
  552. //+POC:nuserchanged,1880496172,2099354,5
  553. if(0==ModemStrCmp(msg,"+POC:nuserchanged")){
  554. // Index=IndexReturnBySymbol(msg,',',3);
  555. // if(atoi(&msg[Index])==5)sutPocStatus.danHunStatus=1;
  556. // else if(atoi(&msg[Index])==2)sutPocStatus.danHunStatus=0;
  557. }
  558. //+POC:ngps,1,30
  559. // if(0==ModemStrCmp(msg,"+POC:ngps")){
  560. // Index=IndexReturnBySymbol(msg,',',1);
  561. // g_uiGpsStat=atoi(&msg[Index]);
  562. // return 1;
  563. // }
  564. // //ptt,1
  565. // if(0==ModemStrCmp(msg,"ptt,1")){
  566. // SpeakerEnable();
  567. // }
  568. return 0;
  569. }
  570. void ExchangeHighLowByte(char *src,unsigned short lenth)
  571. {
  572. unsigned short i;
  573. unsigned char temp;
  574. for(i=0;i<lenth;i+=4)
  575. {
  576. temp=src[i];
  577. src[i]=src[i+2];
  578. src[i+2]=temp;
  579. temp=src[i+1];
  580. src[i+1]=src[i+3];
  581. src[i+3]=temp;
  582. }
  583. }
  584. char IndexReturnBySymbol(char *src,char Symbol,char num)
  585. {
  586. char i=0;
  587. char index=0;
  588. while(*src){
  589. if(*src==Symbol) i++;
  590. src++;
  591. index++;
  592. if(num==i)return index;
  593. }
  594. return 0;
  595. }
  596. /******************************************************************************
  597. *******************************************************************************/
  598. void TTSdaxieguibi(char *src) //
  599. {
  600. int srclen;
  601. unsigned char *p;
  602. int i,j;
  603. char flag=0;
  604. char buf[300];//100
  605. memset(buf,0,sizeof(buf));
  606. srclen=strlen(src);
  607. p=(unsigned char *)src;
  608. i=0;
  609. j=0;
  610. while(i<(srclen)){
  611. if(*p>0x9f){
  612. if(flag){
  613. buf[j++]=',';
  614. flag=0;
  615. }
  616. buf[j++]=*p;
  617. p+=1;
  618. buf[j++]=*p;
  619. p+=1;
  620. i+=2;
  621. }else{
  622. if((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z')){
  623. flag=1;
  624. }
  625. else flag=0;
  626. buf[j]=*p;
  627. p+=1;
  628. i+=1;
  629. j+=1;
  630. }
  631. }
  632. buf[j]=0;
  633. // printf("buf====%s\r\n",buf);
  634. ModemSendAt(buf);
  635. }