PocTask.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. #include "includes.h"
  2. int g_iModemVer=0;
  3. int g_iPocVer=0;
  4. SUT_POC_STATUS sutPocStatus;
  5. char g_cGroupName[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. if(++sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum)sutPocStatus.ListGetOneFlag=1;
  43. return 1;
  44. }
  45. return 0;
  46. }
  47. int GetAllVoice(char *msg)
  48. {
  49. unsigned short num;
  50. char name[POC_USER_NAME_LEN*2+1];
  51. unsigned long id;
  52. unsigned short index;
  53. char *pTemp;
  54. unsigned char len;
  55. /*+VINFO:A,1,20-08-20 08:55:42 A有效 V无效
  56. +VINFO:V,2
  57. +VINFO:A,3,20-08-20 08:59:46
  58. */
  59. if(ModemStrCmp(msg,"+VINFO:")==0){
  60. if(!uiAssist.status)return 1;
  61. if(msg[7]=='A')strcpy(sutPocStatus.AllVoice[sutPocStatus.ListFillIndex],&msg[14]);
  62. else strcpy(sutPocStatus.AllVoice[sutPocStatus.ListFillIndex],"不可用");
  63. //printf("Username====%s\r\n",sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  64. if(++sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum)sutPocStatus.ListGetOneFlag=1;
  65. return 1;
  66. }
  67. return 0;
  68. }
  69. int GetAllUsers(char *msg)
  70. {
  71. unsigned short num;
  72. char name[POC_USER_NAME_LEN*2+1];
  73. unsigned long id;
  74. unsigned short index;
  75. char *pTemp;
  76. unsigned char len;
  77. //成员查询 当前index 成员ID 成员名
  78. //+POC:1E010000 0000 0001CC49 3237
  79. if(msg[5]=='1' && msg[6]=='E'){
  80. if(!uiAssist.status)return 1;
  81. len = strlen(&msg[25])-2;
  82. if(len >= POC_USER_NAME_LEN*2) len = POC_USER_NAME_LEN*2;
  83. memcpy(name, &msg[25], len);
  84. name[len]=0;
  85. // //
  86. // msg[29]=0;
  87. // num=strtol(&msg[25],&pTemp,16);
  88. //成员ID
  89. msg[25]=0;
  90. id=strtol(&msg[17],&pTemp,16);
  91. //添加
  92. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
  93. //sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].usernum=num;
  94. if(name[0]==0)
  95. {//当模块吐出来的名字为空时,自动添加为空格,防止显示时会死掉
  96. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
  97. sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
  98. }else
  99. StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  100. // printf("Username====%s\r\n",sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
  101. if(++sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum)sutPocStatus.ListGetOneFlag=1;
  102. return 1;
  103. }
  104. return 0;
  105. }
  106. char PocHandle(char *msg)
  107. {
  108. uint8_t temp[4];
  109. SUTDS ds;
  110. SUTDL dl;
  111. char buf[102];//100
  112. char *pName;
  113. unsigned char len,type;
  114. char pGroup[POC_GROUP_NAME_LEN*2]={0};
  115. static int Table[POC_GROUP_NAME_LEN*2]={0};
  116. long l;
  117. int i;
  118. static unsigned char getNameFlag=0;
  119. static char Username[POC_USER_NAME_LEN+1];//因为播报时是先存了用户名,后面才存群组名,然后一起播报,故此值要是静态的,否则有时用户名会播报不出来
  120. char Groupname[POC_GROUP_NAME_LEN+1];
  121. //=============+LSHTTS: END
  122. if(msg[1]=='L' && msg[2]=='S' && msg[3]=='H' && msg[4]=='T' && msg[9]=='E'){
  123. sutPocStatus.TTS=0;
  124. if(sutPocStatus.Speaker==0)SpeakerDisable();
  125. return 1;
  126. }
  127. //+POC:0BXXYYYY
  128. //请求PTT返回
  129. //XX:00请求成功,可以不处理,因为同时有8Bxxyy回来处理打开喇叭
  130. //XX:FF请求失败,播报特tone音,与抢麦失败一样
  131. //YYYY:操作ID,不处理
  132. if(msg[5] == '0' && msg[6] == 'B')
  133. {
  134. if(msg[7] == 'F' && msg[8] == 'F')
  135. {
  136. SpeakerEnable();
  137. SetBeep(1000,10);
  138. }
  139. return 1;
  140. }
  141. //+POC:8bxxyy
  142. //xx--mic控制 01--打开MIC
  143. // 00--关闭MIC
  144. //yy--speaker控制
  145. // 00--关闭speaker并要产生成功的滴音
  146. // 01--对方说话,打开speaker,并产生成功的滴音
  147. // 13--抢麦失败,打开speaker,并产生失败的滴音
  148. if(msg[5]=='8' && msg[6]=='B' && msg[7]=='0')
  149. {
  150. if(msg[8]=='1')//xx == 01
  151. {
  152. enableDataSend();
  153. sutPocStatus.Mic=1;
  154. MicEnable();
  155. sutPocStatus.Speaker=0;
  156. sutPocStatus.PPTpress=1;
  157. SpeakerDisable();
  158. sutPocStatus.Logined=1;
  159. }else if(msg[8]=='0')//xx == 00
  160. {
  161. sutPocStatus.Mic=0;
  162. sutPocStatus.PPTpress=0;
  163. MicDisable();
  164. SpeakerEnable();
  165. if(newPara.KeySound!=0){
  166. printf("start beep-----\r\n");
  167. SetBeep(500,10);
  168. }
  169. }
  170. if(msg[9]=='0' && msg[10] == '0')
  171. {
  172. //yy == 00 对方说话结束或本地讲话开始,滴音
  173. sutPocStatus.Speaker=0;
  174. }else if(msg[9]=='0' && msg[10] == '1')
  175. {
  176. //yy == 00 对方说话开始
  177. enableDataSend();
  178. LCDBackLight(1);
  179. LcdOnTimeCt=0;
  180. ///////////////////
  181. sutPocStatus.Logined=1;
  182. sutPocStatus.Speaker=1;
  183. // sutPocStatus.ToneStart=1;
  184. // SpeakerEnable();
  185. // if(newPara.KeySound!=0){
  186. // SetBeep(500,10);//10
  187. // }
  188. }else if(msg[9]=='1' && msg[10]=='3')
  189. {
  190. //yy == 13 抢麦不成功滴音
  191. sutPocStatus.statusChaned=1;
  192. //sutPocStatus.Speaker=1;//3;//屏蔽掉后:能达到修改记录中的第6点
  193. SpeakerEnable();
  194. SetBeep(1000,10);
  195. }
  196. return 1;
  197. }
  198. //==============+POC:xxxx=============
  199. //+POC:820100000000 +POC:8201ffffffff
  200. //+POC:82 02 00002c8d 4b6dd58b3100300032000000 登陆成功,提示“测试102”
  201. //+POC:82 02 0000D590 B5E7C1BFB2E2CAD432 登陆成功 提示"电量测试2"
  202. if(msg[5]=='8' && msg[6]=='2')
  203. {
  204. buf[0] = msg[7];
  205. buf[1] = msg[8];
  206. buf[2] = 0;
  207. type = atoi(buf);
  208. switch(type)
  209. {
  210. case 0://离线 ID无效
  211. //if(sutPocStatus.Logined) HigosStartCnt(1);
  212. sutPocStatus.danHunStatus=0;//掉线,清单呼显示状态为非单呼状态
  213. sutPocStatus.Logined=0;
  214. sutGpsInfo.isGpsAuthOk=0;
  215. snprintf(buf, sizeof(buf),"[msg]");
  216. if(msg[17] == 'B' && msg[18]== '5' && msg[25] == 'C' && msg[26] == 'A')
  217. {//帐号信息错误
  218. pocTimeOutTime=5;
  219. sutPocStatus.loginResult=1;
  220. strcat(buf, "账号信息错误");
  221. }
  222. else
  223. if(msg[17] == 'C' && msg[18]== 'E' && msg[25] == 'C' && msg[26] == '2')
  224. {//无网络连接
  225. if(sutPocStatus.loginResult != 1)
  226. sutPocStatus.loginResult=2;
  227. strcat(buf, "无网络连接");
  228. }else if(msg[17] == 'C' && msg[18]== 'E' && msg[25] == 'C' && msg[26] == '1'){
  229. sutPocStatus.loginResult=5;
  230. strcat(buf, "无法连接");
  231. }else if(msg[17] == 'C' && msg[18]== '3' && msg[25] == 'B' && msg[26] == '7'){
  232. sutPocStatus.loginResult=6;
  233. strcat(buf, "没有服务");
  234. }
  235. else strcat(buf, "No login");
  236. SlwTrace(INF, buf, 1);
  237. break;
  238. case 1://登陆中 ID无效
  239. SlwTrace(INF, "login ing",1);
  240. break;
  241. case 2://登陆成功 ID为用户ID
  242. len = strlen(&msg[17])-2;
  243. if(len >= POC_USER_NAME_LEN) len = POC_USER_NAME_LEN;
  244. memcpy(Username,&msg[17],len);
  245. Username[len]=0;
  246. StrAsciiToHex(Username,sutPocStatus.LocalUser.name);
  247. msg[17]=0;
  248. sutPocStatus.LocalUser.ID=strtol(&msg[9],&pName,16);
  249. SlwTrace(INF, "login ok",1);
  250. getNameFlag=1;//登陆成功时,获取过了用户名字,后面可以播报了
  251. sutPocStatus.loginResult=3;
  252. break;
  253. case 3://注销中 ID无效
  254. SlwTrace(INF, "logout ing",1);
  255. break;
  256. }
  257. return 1;
  258. }
  259. //+POC:3D000003
  260. if(msg[5]=='3' && (msg[6]=='D'||msg[6]=='E')){
  261. sutPocStatus.ListCurOnlineNum=strtol(&msg[13],&pName,16);
  262. sutPocStatus.ListUpdate=1;
  263. return 1;
  264. }
  265. //获取所有组列表,也就是处理+POC:80xxxs
  266. if(GetAllGroups(msg))return 1;
  267. if(GetAllUsers(msg))return 1;
  268. //获取所有成员列表,也就是处理+POC:81XXX
  269. //if(GetAllUsers(msg))return 1;
  270. //+POC:86 00 000000dc a47fc47e3300 0000 进入群组,提示“群组3”(群组ID为000000dc,群组名为“群组3”即a47fc47e3300)
  271. // 86 00 0000009a d89ea48ba47fc47e0000 默认群组
  272. //+POC:86 00 00000366 0000
  273. if(msg[5]=='8' && msg[6]=='6')
  274. {//----获取本机当前群组名及群组ID
  275. //HigosStopCnt();//正常登陆了,停止计数
  276. sutPocStatus.Logined=1;
  277. pocTimeOutTime=30;
  278. if(msg[8] == '0')
  279. {//GB2312
  280. len = strlen(&msg[17])-2;
  281. if(len >= POC_GROUP_NAME_LEN) len = POC_GROUP_NAME_LEN;
  282. memcpy(Groupname,&msg[17],len);
  283. Groupname[len]=0;
  284. msg[17]=0;
  285. sutPocStatus.LocalGroup.ID=strtol(&msg[9],&pName,16);
  286. StrAsciiToHex(Groupname,sutPocStatus.LocalGroup.name);
  287. if(sutPocStatus.FirstLogined==0)
  288. {//登陆成功用户名群组名只播报一次
  289. if(getNameFlag == 0)
  290. snprintf(buf, sizeof(buf), "%s",Groupname);
  291. else
  292. {
  293. getNameFlag=0;
  294. snprintf(buf, sizeof(buf), "%s2CD2D1B5C7C2BD2C%s",Username,Groupname);
  295. }
  296. MeSpeak(ENCODE_GBK, buf);
  297. }else
  298. {//其它形式进入
  299. // if(g_ucEnterGroupFlag==1)
  300. // {
  301. g_ucEnterGroupFlag=0;
  302. // snprintf(buf, sizeof(buf), "BDF8C8EB2C%s",sutPocStatus.LocalGroup.name);
  303. snprintf(buf, sizeof(buf), "BDF8C8EB2C%s",Groupname);
  304. MeSpeak(ENCODE_GBK, buf);
  305. // }
  306. }
  307. }
  308. LcdOnTimeCt=0;
  309. sutPocStatus.danHunStatus=0;//收到这个直接设置为非单呼模式,否在会在单呼模式下如果被创建了临时群组,之后会一直显示单呼模式
  310. //if(sutPocStatus.FirstLogined==0) ModemSendAt("AT+CCLK?\r\n");
  311. sutPocStatus.FirstLogined=1;
  312. return 1;
  313. }
  314. //+POC:830000002e650000 对方话语权
  315. //+POC:83000000420c330067004b6dd58b3200f7530000
  316. //+POC:8300000045544800530031003500310057004b6dd58b300033000000
  317. //+POC:83000000D592 303738
  318. if(msg[5]=='8' && msg[6]=='3' && msg[7]=='0' && msg[8]=='0')
  319. {
  320. //最新POC版本快速短按PTT放开会只发这条过来,实际是没有请麦来的
  321. //因此不做灯与喇叭,LCD背光等控制
  322. ReplaceStrWithN(&msg[17]);
  323. //如果他只发ID不发对方名,要记得修改防护
  324. i=strlen(&msg[17]);
  325. if(i>=POC_USER_NAME_LEN) i=POC_USER_NAME_LEN;
  326. else i++;//把0结束也拷过去
  327. StrAsciiToHex(&msg[17], sutPocStatus.Callname);
  328. *(msg+17) = 0;
  329. sutPocStatus.CallID = strtol(&msg[9],&pName,16);
  330. msg[17]=0;
  331. return 1;
  332. }
  333. //+POC:8301ffffffff0000 对方释放话语权
  334. if(msg[5]=='8' && msg[6]=='3' && msg[7]=='0' && msg[8]=='1'){
  335. //最新POC版本目前没有这条指令,也忽视吧
  336. // sutPocStatus.Speaker=0;
  337. // SpeakerDisable();
  338. return 1;
  339. }
  340. //+POC:91010103
  341. if(msg[5]=='9' && msg[6]=='1'){
  342. //PocAddUserStatusToList(&msg[7]);
  343. return 1;
  344. }
  345. //+POC:0E00 0000 0002
  346. if(msg[5]=='0'&& msg[6]=='E'){
  347. msg[17]=0;
  348. StrAsciiToHex(&msg[13], temp);
  349. ds.Data.ucData.b1=temp[1];
  350. ds.Data.ucData.b2=temp[2];
  351. sutPocStatus.UserOnLineNum=ds.Data.usData;
  352. sutPocStatus.UserNum_Update=1;
  353. snprintf(buf, sizeof(buf), "oneLine:%d",sutPocStatus.UserOnLineNum);
  354. SlwTrace(INF, buf, 1);
  355. }
  356. //+POC:84 00 xxx //单呼提示
  357. if(msg[5]=='8' && msg[6]=='4')
  358. {
  359. MakeStrEndByNewLine(msg);
  360. MeSpeak(ENCODE_GBK , &msg[9]);
  361. //检测是哪种单呼
  362. if(memcmp(&msg[9], "C1D9CAB1", 8)==0)
  363. {//临时呼叫xxxx 被呼成功
  364. sutPocStatus.danHunStatus=1;//进入单显示
  365. }else if(memcmp(&msg[9], "CDCBB3F6", 8)==0)
  366. {//退出临时呼叫 退出单呼状态
  367. sutPocStatus.danHunStatus=0;
  368. }else if(memcmp(&msg[9], "BAF4BDD0B3C9B9A6", 16)==0)
  369. {//呼叫成功 主单呼
  370. sutPocStatus.danHunStatus=1;
  371. }
  372. return 1;
  373. }
  374. //+POC:21 000000 0000A5AB B8D6CCFACFC0
  375. // 关键字 保留 UID 名称
  376. if(msg[5]=='2' && msg[6]=='1'){
  377. MakeStrEndByNewLine(msg);
  378. memset(sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name,0,POC_ALL_USERS_NUM);
  379. if(msg[21]==0) sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name[0]=' ';
  380. else StrAsciiToHex(&msg[21], sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name);
  381. msg[21]=0;
  382. StrAsciiToHex(&msg[13], temp);
  383. dl.Data.ucData.b4=temp[0];
  384. dl.Data.ucData.b3=temp[1];
  385. dl.Data.ucData.b2=temp[2];
  386. dl.Data.ucData.b1=temp[3];
  387. sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].ID=dl.Data.ulData;
  388. sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].status=3;
  389. sutPocStatus.GetOneUserFlag=1;
  390. return 1;
  391. }
  392. // //+POC:21 000000 0000A5AB B8D6CCFACFC0
  393. // // 关键字 保留 UID 名称
  394. // if(msg[5]=='2' && msg[6]=='1'){
  395. // MakeStrEndByNewLine(msg);
  396. // memset(sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name,0,POC_ALL_USERS_NUM);
  397. // if(msg[21]==0) sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name[0]=' ';
  398. // else StrAsciiToHex(&msg[21], sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name);
  399. // msg[21]=0;
  400. // StrAsciiToHex(&msg[13], temp);
  401. // dl.Data.ucData.b4=temp[0];
  402. // dl.Data.ucData.b3=temp[1];
  403. // dl.Data.ucData.b2=temp[2];
  404. // dl.Data.ucData.b1=temp[3];
  405. // sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].ID=dl.Data.ulData;
  406. // sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].status=3;
  407. // sutPocStatus.GetOneUserFlag=1;
  408. // return 1;
  409. // }
  410. //
  411. //+POC:1000000007 0004 00000BF9 0003 D1D0B7A2B2E2CAD4D7E93030
  412. //+POC:1000000008 0004 00000BF9 0003 D1D0B7A2B2E2CAD4D7E93030
  413. // 组索引 组ID 成员数 组名字
  414. //xxxxxxxx 4字节ID
  415. //nnnnnnnn 名称
  416. if(msg[5] == '1' &&
  417. msg[7] == '0' &&
  418. (msg[14] == '7' || msg[14] == '8'))
  419. {
  420. memcpy(sutPocStatus.switchGroupID,&msg[19], 8);
  421. MakeStrEndByNewLine(&msg[31]);
  422. MeSpeak(ENCODE_GBK, &msg[31]);
  423. return 1;
  424. }
  425. }