123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464 |
- #include "includes.h"
- int g_iModemVer=0;
- int g_iPocVer=0;
- SUT_POC_STATUS sutPocStatus;
- char g_cGroupName[POC_GROUP_NAME_LEN];
- unsigned long g_ulGroupID;
- //+POC:1D00000000000000539B000BC4ACC8CFC8BAD7E9
- int GetAllGroups(char *msg)
- {
- unsigned short num;
- char name[POC_GROUP_NAME_LEN*2+1];
- unsigned long id;
- unsigned short index;
- char *pTemp;
- unsigned char len;
- // 当前index 组ID 组内成员个数 组名
- //+POC:1D000000 0001 0000539C 000B B2E2CAD4D7E931
-
- //成员查询 当前index 成员ID 成员名
- //+POC:1E010000 0000 0001CC49 3237
- if(msg[5]=='1' && msg[6]=='D'){
- if(!uiAssist.status)return 1;
- len = strlen(&msg[29])-2;
- if(len >= POC_GROUP_NAME_LEN*2) len = POC_GROUP_NAME_LEN*2;
- memcpy(name, &msg[29], len);
- name[len]=0;
- //组内成员个数
- msg[29]=0;
- num=strtol(&msg[25],&pTemp,16);
- //组ID
- msg[25]=0;
- id=strtol(&msg[17],&pTemp,16);
- //添加
- sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].ID=id;
- sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].usernum=num;
- if(name[0]==0)
- {//当模块吐出来的名字为空时,自动添加为空格,防止显示时会死掉
- sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[0]=' ';
- sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name[1]=0;
- }else
- StrAsciiToHex(name, sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
-
- //printf("name====%s\r\n",sutPocStatus.AllGroups[sutPocStatus.ListFillIndex].name);
-
- if(++sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum)sutPocStatus.ListGetOneFlag=1;
-
- return 1;
- }
- return 0;
- }
- int GetAllVoice(char *msg)
- {
- unsigned short num;
- char name[POC_USER_NAME_LEN*2+1];
- unsigned long id;
- unsigned short index;
- char *pTemp;
- unsigned char len;
- /*+VINFO:A,1,20-08-20 08:55:42 A有效 V无效
- +VINFO:V,2
- +VINFO:A,3,20-08-20 08:59:46
- */
- if(ModemStrCmp(msg,"+VINFO:")==0){
- if(!uiAssist.status)return 1;
- if(msg[7]=='A')strcpy(sutPocStatus.AllVoice[sutPocStatus.ListFillIndex],&msg[14]);
- else strcpy(sutPocStatus.AllVoice[sutPocStatus.ListFillIndex],"不可用");
- //printf("Username====%s\r\n",sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
- if(++sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum)sutPocStatus.ListGetOneFlag=1;
- return 1;
- }
- return 0;
- }
- int GetAllUsers(char *msg)
- {
- unsigned short num;
- char name[POC_USER_NAME_LEN*2+1];
- unsigned long id;
- unsigned short index;
- char *pTemp;
- unsigned char len;
- //成员查询 当前index 成员ID 成员名
- //+POC:1E010000 0000 0001CC49 3237
- if(msg[5]=='1' && msg[6]=='E'){
- if(!uiAssist.status)return 1;
- len = strlen(&msg[25])-2;
- if(len >= POC_USER_NAME_LEN*2) len = POC_USER_NAME_LEN*2;
- memcpy(name, &msg[25], len);
- name[len]=0;
- // //
- // msg[29]=0;
- // num=strtol(&msg[25],&pTemp,16);
- //成员ID
- msg[25]=0;
- id=strtol(&msg[17],&pTemp,16);
- //添加
- sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id;
- //sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].usernum=num;
- if(name[0]==0)
- {//当模块吐出来的名字为空时,自动添加为空格,防止显示时会死掉
- sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[0]=' ';
- sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name[1]=0;
- }else
- StrAsciiToHex(name, sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
- // printf("Username====%s\r\n",sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].name);
- if(++sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum)sutPocStatus.ListGetOneFlag=1;
- return 1;
- }
- return 0;
- }
- char PocHandle(char *msg)
- {
- uint8_t temp[4];
- SUTDS ds;
- SUTDL dl;
- char buf[102];//100
- char *pName;
- unsigned char len,type;
- char pGroup[POC_GROUP_NAME_LEN*2]={0};
- static int Table[POC_GROUP_NAME_LEN*2]={0};
- long l;
- int i;
- static unsigned char getNameFlag=0;
- static char Username[POC_USER_NAME_LEN+1];//因为播报时是先存了用户名,后面才存群组名,然后一起播报,故此值要是静态的,否则有时用户名会播报不出来
- char Groupname[POC_GROUP_NAME_LEN+1];
- //=============+LSHTTS: END
- if(msg[1]=='L' && msg[2]=='S' && msg[3]=='H' && msg[4]=='T' && msg[9]=='E'){
- sutPocStatus.TTS=0;
- if(sutPocStatus.Speaker==0)SpeakerDisable();
- return 1;
- }
-
- //+POC:0BXXYYYY
- //请求PTT返回
- //XX:00请求成功,可以不处理,因为同时有8Bxxyy回来处理打开喇叭
- //XX:FF请求失败,播报特tone音,与抢麦失败一样
- //YYYY:操作ID,不处理
- if(msg[5] == '0' && msg[6] == 'B')
- {
- if(msg[7] == 'F' && msg[8] == 'F')
- {
- SpeakerEnable();
- SetBeep(1000,10);
- }
- return 1;
- }
- //+POC:8bxxyy
- //xx--mic控制 01--打开MIC
- // 00--关闭MIC
- //yy--speaker控制
- // 00--关闭speaker并要产生成功的滴音
- // 01--对方说话,打开speaker,并产生成功的滴音
- // 13--抢麦失败,打开speaker,并产生失败的滴音
- if(msg[5]=='8' && msg[6]=='B' && msg[7]=='0')
- {
- if(msg[8]=='1')//xx == 01
- {
- enableDataSend();
- sutPocStatus.Mic=1;
- MicEnable();
- sutPocStatus.Speaker=0;
- sutPocStatus.PPTpress=1;
- SpeakerDisable();
- sutPocStatus.Logined=1;
- }else if(msg[8]=='0')//xx == 00
- {
- sutPocStatus.Mic=0;
- sutPocStatus.PPTpress=0;
- MicDisable();
- SpeakerEnable();
- if(newPara.KeySound!=0){
- printf("start beep-----\r\n");
- SetBeep(500,10);
- }
- }
-
- if(msg[9]=='0' && msg[10] == '0')
- {
- //yy == 00 对方说话结束或本地讲话开始,滴音
- sutPocStatus.Speaker=0;
-
-
-
- }else if(msg[9]=='0' && msg[10] == '1')
- {
-
- //yy == 00 对方说话开始
- enableDataSend();
- LCDBackLight(1);
- LcdOnTimeCt=0;
- ///////////////////
- sutPocStatus.Logined=1;
- sutPocStatus.Speaker=1;
- // sutPocStatus.ToneStart=1;
- // SpeakerEnable();
- // if(newPara.KeySound!=0){
- // SetBeep(500,10);//10
- // }
-
- }else if(msg[9]=='1' && msg[10]=='3')
- {
- //yy == 13 抢麦不成功滴音
- sutPocStatus.statusChaned=1;
- //sutPocStatus.Speaker=1;//3;//屏蔽掉后:能达到修改记录中的第6点
- SpeakerEnable();
- SetBeep(1000,10);
- }
- return 1;
- }
-
- //==============+POC:xxxx=============
- //+POC:820100000000 +POC:8201ffffffff
- //+POC:82 02 00002c8d 4b6dd58b3100300032000000 登陆成功,提示“测试102”
- //+POC:82 02 0000D590 B5E7C1BFB2E2CAD432 登陆成功 提示"电量测试2"
- if(msg[5]=='8' && msg[6]=='2')
- {
- buf[0] = msg[7];
- buf[1] = msg[8];
- buf[2] = 0;
- type = atoi(buf);
- switch(type)
- {
- case 0://离线 ID无效
- //if(sutPocStatus.Logined) HigosStartCnt(1);
- sutPocStatus.danHunStatus=0;//掉线,清单呼显示状态为非单呼状态
- sutPocStatus.Logined=0;
- sutGpsInfo.isGpsAuthOk=0;
- snprintf(buf, sizeof(buf),"[msg]");
- if(msg[17] == 'B' && msg[18]== '5' && msg[25] == 'C' && msg[26] == 'A')
- {//帐号信息错误
- pocTimeOutTime=5;
- sutPocStatus.loginResult=1;
- strcat(buf, "账号信息错误");
- }
- else
- if(msg[17] == 'C' && msg[18]== 'E' && msg[25] == 'C' && msg[26] == '2')
- {//无网络连接
-
- if(sutPocStatus.loginResult != 1)
- sutPocStatus.loginResult=2;
- strcat(buf, "无网络连接");
- }else if(msg[17] == 'C' && msg[18]== 'E' && msg[25] == 'C' && msg[26] == '1'){
- sutPocStatus.loginResult=5;
- strcat(buf, "无法连接");
- }else if(msg[17] == 'C' && msg[18]== '3' && msg[25] == 'B' && msg[26] == '7'){
- sutPocStatus.loginResult=6;
- strcat(buf, "没有服务");
- }
- else strcat(buf, "No login");
- SlwTrace(INF, buf, 1);
- break;
- case 1://登陆中 ID无效
- SlwTrace(INF, "login ing",1);
- break;
- case 2://登陆成功 ID为用户ID
- len = strlen(&msg[17])-2;
- if(len >= POC_USER_NAME_LEN) len = POC_USER_NAME_LEN;
- memcpy(Username,&msg[17],len);
- Username[len]=0;
- StrAsciiToHex(Username,sutPocStatus.LocalUser.name);
- msg[17]=0;
- sutPocStatus.LocalUser.ID=strtol(&msg[9],&pName,16);
- SlwTrace(INF, "login ok",1);
- getNameFlag=1;//登陆成功时,获取过了用户名字,后面可以播报了
- sutPocStatus.loginResult=3;
- break;
- case 3://注销中 ID无效
- SlwTrace(INF, "logout ing",1);
- break;
- }
- return 1;
- }
-
- //+POC:3D000003
- if(msg[5]=='3' && (msg[6]=='D'||msg[6]=='E')){
- sutPocStatus.ListCurOnlineNum=strtol(&msg[13],&pName,16);
- sutPocStatus.ListUpdate=1;
- return 1;
- }
-
- //获取所有组列表,也就是处理+POC:80xxxs
- if(GetAllGroups(msg))return 1;
- if(GetAllUsers(msg))return 1;
-
- //获取所有成员列表,也就是处理+POC:81XXX
- //if(GetAllUsers(msg))return 1;
- //+POC:86 00 000000dc a47fc47e3300 0000 进入群组,提示“群组3”(群组ID为000000dc,群组名为“群组3”即a47fc47e3300)
- // 86 00 0000009a d89ea48ba47fc47e0000 默认群组
- //+POC:86 00 00000366 0000
- if(msg[5]=='8' && msg[6]=='6')
- {//----获取本机当前群组名及群组ID
- //HigosStopCnt();//正常登陆了,停止计数
- sutPocStatus.Logined=1;
- pocTimeOutTime=30;
- if(msg[8] == '0')
- {//GB2312
- len = strlen(&msg[17])-2;
- if(len >= POC_GROUP_NAME_LEN) len = POC_GROUP_NAME_LEN;
- memcpy(Groupname,&msg[17],len);
- Groupname[len]=0;
- msg[17]=0;
- sutPocStatus.LocalGroup.ID=strtol(&msg[9],&pName,16);
- StrAsciiToHex(Groupname,sutPocStatus.LocalGroup.name);
- if(sutPocStatus.FirstLogined==0)
- {//登陆成功用户名群组名只播报一次
- if(getNameFlag == 0)
- snprintf(buf, sizeof(buf), "%s",Groupname);
- else
- {
- getNameFlag=0;
- snprintf(buf, sizeof(buf), "%s2CD2D1B5C7C2BD2C%s",Username,Groupname);
- }
- MeSpeak(ENCODE_GBK, buf);
-
- }else
- {//其它形式进入
- // if(g_ucEnterGroupFlag==1)
- // {
- g_ucEnterGroupFlag=0;
- // snprintf(buf, sizeof(buf), "BDF8C8EB2C%s",sutPocStatus.LocalGroup.name);
- snprintf(buf, sizeof(buf), "BDF8C8EB2C%s",Groupname);
- MeSpeak(ENCODE_GBK, buf);
- // }
- }
- }
- LcdOnTimeCt=0;
- sutPocStatus.danHunStatus=0;//收到这个直接设置为非单呼模式,否在会在单呼模式下如果被创建了临时群组,之后会一直显示单呼模式
- //if(sutPocStatus.FirstLogined==0) ModemSendAt("AT+CCLK?\r\n");
- sutPocStatus.FirstLogined=1;
- return 1;
- }
-
- //+POC:830000002e650000 对方话语权
- //+POC:83000000420c330067004b6dd58b3200f7530000
- //+POC:8300000045544800530031003500310057004b6dd58b300033000000
- //+POC:83000000D592 303738
- if(msg[5]=='8' && msg[6]=='3' && msg[7]=='0' && msg[8]=='0')
- {
- //最新POC版本快速短按PTT放开会只发这条过来,实际是没有请麦来的
- //因此不做灯与喇叭,LCD背光等控制
- ReplaceStrWithN(&msg[17]);
- //如果他只发ID不发对方名,要记得修改防护
- i=strlen(&msg[17]);
- if(i>=POC_USER_NAME_LEN) i=POC_USER_NAME_LEN;
- else i++;//把0结束也拷过去
- StrAsciiToHex(&msg[17], sutPocStatus.Callname);
- *(msg+17) = 0;
- sutPocStatus.CallID = strtol(&msg[9],&pName,16);
- msg[17]=0;
- return 1;
- }
- //+POC:8301ffffffff0000 对方释放话语权
- if(msg[5]=='8' && msg[6]=='3' && msg[7]=='0' && msg[8]=='1'){
- //最新POC版本目前没有这条指令,也忽视吧
- // sutPocStatus.Speaker=0;
- // SpeakerDisable();
- return 1;
- }
- //+POC:91010103
- if(msg[5]=='9' && msg[6]=='1'){
- //PocAddUserStatusToList(&msg[7]);
- return 1;
- }
- //+POC:0E00 0000 0002
- if(msg[5]=='0'&& msg[6]=='E'){
- msg[17]=0;
- StrAsciiToHex(&msg[13], temp);
- ds.Data.ucData.b1=temp[1];
- ds.Data.ucData.b2=temp[2];
- sutPocStatus.UserOnLineNum=ds.Data.usData;
- sutPocStatus.UserNum_Update=1;
- snprintf(buf, sizeof(buf), "oneLine:%d",sutPocStatus.UserOnLineNum);
- SlwTrace(INF, buf, 1);
- }
-
- //+POC:84 00 xxx //单呼提示
- if(msg[5]=='8' && msg[6]=='4')
- {
- MakeStrEndByNewLine(msg);
- MeSpeak(ENCODE_GBK , &msg[9]);
- //检测是哪种单呼
- if(memcmp(&msg[9], "C1D9CAB1", 8)==0)
- {//临时呼叫xxxx 被呼成功
- sutPocStatus.danHunStatus=1;//进入单显示
- }else if(memcmp(&msg[9], "CDCBB3F6", 8)==0)
- {//退出临时呼叫 退出单呼状态
- sutPocStatus.danHunStatus=0;
- }else if(memcmp(&msg[9], "BAF4BDD0B3C9B9A6", 16)==0)
- {//呼叫成功 主单呼
- sutPocStatus.danHunStatus=1;
- }
- return 1;
- }
-
- //+POC:21 000000 0000A5AB B8D6CCFACFC0
- // 关键字 保留 UID 名称
- if(msg[5]=='2' && msg[6]=='1'){
- MakeStrEndByNewLine(msg);
- memset(sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name,0,POC_ALL_USERS_NUM);
- if(msg[21]==0) sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name[0]=' ';
- else StrAsciiToHex(&msg[21], sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name);
- msg[21]=0;
- StrAsciiToHex(&msg[13], temp);
- dl.Data.ucData.b4=temp[0];
- dl.Data.ucData.b3=temp[1];
- dl.Data.ucData.b2=temp[2];
- dl.Data.ucData.b1=temp[3];
- sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].ID=dl.Data.ulData;
- sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].status=3;
- sutPocStatus.GetOneUserFlag=1;
- return 1;
- }
-
- // //+POC:21 000000 0000A5AB B8D6CCFACFC0
- // // 关键字 保留 UID 名称
- // if(msg[5]=='2' && msg[6]=='1'){
- // MakeStrEndByNewLine(msg);
- // memset(sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name,0,POC_ALL_USERS_NUM);
- // if(msg[21]==0) sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name[0]=' ';
- // else StrAsciiToHex(&msg[21], sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].name);
- // msg[21]=0;
- // StrAsciiToHex(&msg[13], temp);
- // dl.Data.ucData.b4=temp[0];
- // dl.Data.ucData.b3=temp[1];
- // dl.Data.ucData.b2=temp[2];
- // dl.Data.ucData.b1=temp[3];
- // sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].ID=dl.Data.ulData;
- // sutPocStatus.AllUsers[sutPocStatus.FillUserIndex].status=3;
- // sutPocStatus.GetOneUserFlag=1;
- // return 1;
- // }
- //
-
-
- //+POC:1000000007 0004 00000BF9 0003 D1D0B7A2B2E2CAD4D7E93030
- //+POC:1000000008 0004 00000BF9 0003 D1D0B7A2B2E2CAD4D7E93030
- // 组索引 组ID 成员数 组名字
- //xxxxxxxx 4字节ID
- //nnnnnnnn 名称
- if(msg[5] == '1' &&
- msg[7] == '0' &&
- (msg[14] == '7' || msg[14] == '8'))
- {
- memcpy(sutPocStatus.switchGroupID,&msg[19], 8);
- MakeStrEndByNewLine(&msg[31]);
- MeSpeak(ENCODE_GBK, &msg[31]);
- return 1;
- }
- }
|