#include "includes.h" POC_DEF sutPocStatus; void pocDataInit(void){ memset((unsigned char *)&sutPocStatus, 0, sizeof(POC_DEF)); } /*控制查询POC设置状? dly:接口被调用的频率,单位ms*/ void pocProCtl(int dly){ static unsigned short cnt=0; static unsigned char cnt2=0; if(sutApp.gtMode!=0) return;//GT模式后不再查? if(++cnt<(5*1000/dly)) return; cnt=0; if(cnt2<3)cnt2++; if(cnt2==3){ //晚一点查LBS if(sutApp.weather[0]==0&&newPara.newold_plam)broad_request_weather_info((double)0, (double)0); } if(getAppObjStatus(ASLEEP_LCD)==0) return;//POC休眠时,不发指令 //用于检测并设置POC参数 msgAtSend("AT+COPS?\r\n"); msgAtSend("AT+CTEC?\r\n");//查询当前网络制式 msgAtSend("AT+CSQ\r\n");//查询信号强度 } static void micPro(int mic); static void spkPro(int spk); static void pocStartMsg(void); static void pro80Msg(char *msg); static void pro81Msg(char *msg); static void pro82Msg(char *msg); static void pro83Msg(char *msg); static void pro84Msg(char *msg); static void pro86Msg(char *msg); static void pro3dMsg(char *msg); static void pro3eMsg(char *msg); static void pro0eMsg(char *msg); static void pro1eMsg(char *msg); static void pro1dMsg(char *msg); static void pocGetVer(char *msg); static void pocGetPpp(char *msg); static void proGauthMsg(char *msg); static void proNoteMsg(char *msg); static void proNetMode(char *msg); static void proSimMode(char *msg); static void proPwrMode(char *msg); static void proFotaMsg(char *msg); static void proGmrMsg(char *msg); static void proSmsMsg(char *msg); static void proAlarmMsg(void); static void proPendMsg(void); static void proToneMsg(char *msg); static void proGPIPMsg(char *msg); static void proGGIPMsg(char *msg); static void proCsqMsg(char *msg); static void proMicSpk(int mic, int spk); static void proCopsMsg(char *msg); static void proHeadSet(char *msg); static void proApnCopy(char *msg); void proCCIDMsg(char *msg); void cmdsProcess(char *msg, int len){//已去掉回车换? int i,j; char buf[10]; if(sutApp.pocInitStatus==0) sutApp.pocInitStatus=1; if(sutApp.gtMode==0){ //appSleepCtl(ASLEEP_POC, 1); tryWakeupApp(); MSG_INFO(1,"POC:%s",msg); if(msgCmp(msg, "PocSleep")){//POC休眠? appSleepCtl(ASLEEP_POC, 0); }else if(msgCmp(msg, "+POC:WAKEUP")){//POC唤醒? }else if(msgCmp(msg, "+POC:8B")){ buf[0]=msg[7];buf[1]=msg[8];buf[2]=0; i=atoi(buf); buf[0]=msg[9];buf[1]=msg[10];buf[2]=0; j=atoi(buf); proMicSpk(i, j); }else if(msgCmp(msg, "+LSHTTS: END")){ sutPocStatus.TTS=0; }else if(msgCmp(msg, "+HTTS: START")){ paControl(true); sutPocStatus.TTS=1; } else if(msgCmp(msg, "+CTEC:")) proNetMode(msg+7); else if(msgCmp(msg, "+CSQ: ")) proCsqMsg(msg+6); else if(msgCmp(msg, "+COPS:")) proCopsMsg(msg); else if(msgCmp(msg, "+CPIN: READY")) sutApp.cardStatus=1; else if(msgCmp(msg, "+CCID: ")) proCCIDMsg(msg+7); else if(msgCmp(msg, "+SIMCROSS"))proSimMode(msg+10); else if(msgCmp(msg, "SV")) strcpy(sutApp.modemVer, msg); else if(msgCmp(msg, "+CGDCONT"))proApnCopy(msg); else MSG_INFO(1, "skip:%d,%s", len,msg); } } //处理POC模块信息 void pocCmdHandler(unsigned char *msg, int len){ //有消息进来,如果不是+POC:SLEEP,POC都唤醒了 static char tmp[300],ch; static int k=0; unsigned int j; if(sutApp.authReady==0) return; if(sutApp.gtMode !=0 && sutApp.gtTMode != 0){ //MSG_INFO(1,"stop USBsend"); usbOutPut(msg, len);//TM TRACE return; } for(j=0;j=sizeof(tmp)) k=0; tmp[k++]=msg[j]; if(ch=='\r' && msg[j]=='\n'){ if(k!=2){ //处理 k -=2;tmp[k]=0;//去掉回车换行 cmdsProcess(tmp,k); } k=0; } ch=msg[j]; } } static void proApnCopy(char *msg){ static char str1[128]={0}; static char cnt=0; char info[64]; int ret=0; //+CGDCONT: 0,"IPV4V6","","IPV4:0.0.0.0 IPV6:::" //+CGDCONT: 1,"IPV4V6","","IPV4:0.0.0.0 IPV6:::" //提取第1个逗号与第3个逗号的索引 int dou_first=findByteFromStr(msg, strlen(msg),',',1); //int dou_two=findByteFromStr(msg, strlen(msg),',',2); int dou_three=findByteFromStr(msg, strlen(msg),',',3); if(dou_first<0 || dou_three<0) return; if(msg[10]=='0'){ if(str1[0]=='\0' && cnt==0){ cnt++; return; }else{ msg[dou_three-1]=0; snprintf(info, sizeof(info), "%s", msg+dou_first); if(strcmp(info, str1)==0){ sutApp.apnCopyDone=1; return; } //if(cnt==1){ msgAtSend("AT+CGACT=0\r\n"); LSAPI_OSI_ThreadSleep(500); snprintf(str1, sizeof(str1), "AT+CGDCONT=1,%s\r\n", info); MSG_INFO(1,"%s",str1); msgAtSend(str1); //} } }else if(msg[10]=='1'){ msg[dou_three-1]=0; snprintf(str1, sizeof(str1), "%s", msg+dou_first); } } static void proMicSpk(int mic, int spk){ if(mic==0 && spk==0){//0000 if(newPara.KeySound!=0) pttBeepStart(false); sutPocStatus.spk=0; sutPocStatus.mic=0; sutPocStatus.TONE=0; }else if(mic==1 && spk==0){//0100 if(newPara.KeySound!=0) pttBeepStart(false); sutPocStatus.mic=1; }else if(mic==0 && spk==1){//0001 if(newPara.KeySound!=0) paControl(true);//pttBeepStart(false); else paControl(true);//关闭提示音时,也要打开喇叭 sutPocStatus.spk=1; sutPocStatus.mic=0; }else if(mic==0 && spk==13){//0013 if(newPara.KeySound!=0) beepStart(TONE_SPECIAL); }else if(mic==0 && spk==2){ paControl(true); sutPocStatus.TONE=1; } } static void micPro(int mic){ switch(mic){ case 0://关闭mic sutPocStatus.mic=0; break; case 1://打开mic if(newPara.KeySound!=0) beepStart(TONE_NORMAL); sutPocStatus.mic=1; //sutPocStatus.spk=0; break; } } static void spkPro(int spk){ switch(spk){ case 0://tone音后关闭spk if(newPara.KeySound!=0) beepStart(TONE_NORMAL); sutPocStatus.spk=0; break; case 1://tone音后保持spk打开 if(newPara.KeySound!=0) beepStart(TONE_NORMAL); paControl(true); sutPocStatus.spk=1; sutPocStatus.mic=0; break; case 2://播放TTS paControl(true); sutPocStatus.TTS=1; break; case 13://抢麦失败,可以tone特殊? if(newPara.KeySound!=0) beepStart(TONE_SPECIAL); break; } } /*POC已启动成?*/ static void pocStartMsg(void){ sutApp.pocInitStatus=1; } /*当前账号所属群组列表信?一次性获取所? 不同应用采用不同需求指? 从不在线到登录会主动上报一次列? 发AT+POC=0D0000也会上报一次列? msg:000000,iiii(组列表索?,dddddddd(组ID),nnnn(组成员数),mmmmmm(组名?*/ static void pro80Msg(char *msg){ } /*所在组成员信息列表 发AT+POC=0E0000xxxxxxxx查询 msg:010000,iiii(成员列表索引),dddddddd(成员ID),mmmmmmmm(成员名称)*/ static void pro81Msg(char *msg){ } /*登录状态信? msg:ss(00未登?02已登?,dddddddd(成员id),mmmmmmmm(状态信息内? 00 CEDECDF8C2E7C1ACBDD3 表示不在线,输出信息?无网络连?拨号?成功) 00 CEDEB7A8C1ACBDD3 表示不在线,输出信息?无法连接(IP 不对或定 向卡) 00 C3BBD3D0B7FECEF1 表示不在线,输出信息?没有服务(没注? 00 B5C7C2BDCAA7B0DC 表示不在线,输出信息?登陆失败(账号错误) 00 0D5CBBAC5D0C5CFA2B4EDCEF3 账号信息错误 02 0001A750 B2E2CAD431BAC5(测试 1 ?,*/ static void pro82Msg(char *msg){ char buf[3],*pName; int type,len; char Username[POC_GROUP_USER_NAME_LEN*2]; buf[0]=msg[0];buf[1]=msg[1];buf[2]=0; type=atoi(buf); switch(type){ case 0: sutPocStatus.logined=0; if(0==memcmp(msg+10, "CEDECDF8C2E7C1ACBDD3",20)) sutPocStatus.PocLineOffReason=1; else if(0==memcmp(msg+10, "CEDEB7A8C1ACBDD3",16)) sutPocStatus.PocLineOffReason=2; else if(0==memcmp(msg+10, "C3BBD3D0B7FECEF1",16)) sutPocStatus.PocLineOffReason=3; else if(0==memcmp(msg+10, "B5C7C2BDCAA7B0DC",16)) sutPocStatus.PocLineOffReason=4; break; case 2: sutPocStatus.PocLineOffReason=0; len=strlen(msg+10); if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN; memcpy(Username, msg+10,len); Username[len]=0; StrAsciiToHex(Username, sutPocStatus.LocalUser.name); msg[10]=0; sutPocStatus.LocalUser.ID=strtol(&msg[2], &pName, 16); MSG_INFO(1, "Login ok"); sutPocStatus.loginResult=3; break; } } /*有人说话 msg:00,dddddddd(成员id),nnnnnnnn(成员名称)*/ static void pro83Msg(char *msg){ int len; char callerName[POC_GROUP_USER_NAME_LEN*2]; backLightReset();//鏀跺埌鏈変汉璇磋瘽 len=strlen(msg+10); if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN; memcpy(callerName, msg+10,len); callerName[len]=0; if(0!=memcmp(callerName, sutPocStatus.CallName,len)) StrAsciiToHex(callerName, sutPocStatus.CallName); } /*单呼响应信息 msg:00,mmmmmmmmmm(单呼结果信息) BAF4BDD0B3C9B9A6 表示 呼叫成功 BAF4BDD0CAA7B0DC 表示 呼叫失败 CDCBB3F6C1D9CAB1BAF4BDD0 表示 退出临时呼? C1D9CAB1BAF4BDD031BAC5BBFA 表示 临时呼叫 1 号机*/ static void pro84Msg(char *msg){ //unsigned char danhureport[POC_GROUP_USER_NAME_LEN+1]; //StrAsciiToHex(msg+2, danhureport); ttsPlay(ENCODE_USER_GBK, msg+2); if(0==memcmp(msg+2, "C1D9CAB1", 8)) sutPocStatus.danHuStatus=1; else if(0==memcmp(msg+2, "CDCBB3F6", 8)) sutPocStatus.danHuStatus=0; else if(0==memcmp(msg+2, "BAF4BDD0B3C9B9A6", 16)) sutPocStatus.danHuStatus=1; } /*切换群组完成指令(表示已登? msg:00,dddddddd(组id),nnnnnnnn(组名?*/ static void pro86Msg(char *msg){ char buf[POC_GROUP_USER_NAME_LEN*4+40],*pName; int len,i; char GroupName[POC_GROUP_USER_NAME_LEN*2]; char tmp[POC_GROUP_USER_NAME_LEN*2+20]; char needTTs=0; sutPocStatus.logined=1; len=strlen(msg+10); if(len>POC_GROUP_USER_NAME_LEN) len=POC_GROUP_USER_NAME_LEN; memcpy(GroupName, msg+10,len); GroupName[len]=0; msg[10]=0; sutPocStatus.LocalGroup.ID=strtol(msg+2, &pName,16); StrAsciiToHex(GroupName, sutPocStatus.LocalGroup.name); if(sutPocStatus.firstLogin==0){ snprintf(tmp, sizeof(tmp), "%s,ѵ¼,%s", sutPocStatus.LocalUser.name,sutPocStatus.LocalGroup.name); backLightReset();//第一次登录时,保持屏亮起? needTTs=1; }else{ snprintf(tmp, sizeof(tmp), ",%s",sutPocStatus.LocalGroup.name); if(sutApp.groupTTSEnable!=0){ needTTs=1; sutApp.groupTTSEnable=0; } } if(needTTs!=0){ memset(buf, 0, sizeof(buf)); for(i=0;i= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2; memcpy(name, &msg[18], len); name[len]=0; msg[18]=0; id=strtol(&msg[10],&pTemp,16); sutPocStatus.AllUsers[sutPocStatus.ListFillIndex].ID=id; 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); sutPocStatus.ListFillIndex++; if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){ sutPocStatus.ListGetOneFlag=1; sutPocStatus.ListDetailValid=1; } } /*定时查询所属组信息 发AT+POC=1D0000xxxxx获得 msg:000000,iiii(组列表索?,dddddddd(组ID),nnnn(成员个数),mmmmmmmmm(名称)*/ static void pro1dMsg(char *msg){ unsigned short num; char name[POC_GROUP_USER_NAME_LEN*2+1]; unsigned long id; unsigned short index; char *pTemp; int len; if(!uiAssist.status)return ; len = strlen(&msg[22]);//已去掉回车换? if(len >= POC_GROUP_USER_NAME_LEN*2) len = POC_GROUP_USER_NAME_LEN*2; memcpy(name, &msg[22], len); name[len]=0; msg[22]=0; num=strtol(&msg[18],&pTemp,16); msg[18]=0; id=strtol(&msg[10],&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); sutPocStatus.ListFillIndex++; if(sutPocStatus.ListFillIndex==sutPocStatus.ExceptionReadNum){ sutPocStatus.ListGetOneFlag=1; sutPocStatus.ListDetailValid=1; } } /* +POC_VER:01027 msg=01027 */ static void pocGetVer(char *msg){ snprintf(sutApp.pocVersion, sizeof(sutApp.pocVersion), "%s",msg); } static void pocGetPpp(char *msg){ if(msg[0]=='1') sutApp.pocPpp=1; else sutApp.pocPpp=0; } /* +GAUTH:AD86EBCCECC4 msg=AD86EBCCECC4+回车 */ static void proGauthMsg(char *msg){ #if 1 unsigned char newAuthTable[10]={0x50,0x28,0xaf,0x6d,0x08,0x9c,0x1b,0xe4,0x23,0x77}; unsigned char randBuf[100]; char buf[3]; int len,i,j; len=0; for(i=0;isizeof(imei)){ MSG_ERR(1, "imei buffer overflow:%d",i); return; } memcpy(imei, imeiPtr,i);//得到IMEI数据:长度为i的imei //组织协议数据 memset(tmp, 0,sizeof(tmp)); memcpy(tmp,FACTORY_MARK,strlen(FACTORY_MARK)); memcpy(tmp+16, MODULE_MARK,strlen(MODULE_MARK)); tmp[32]=i; memcpy(tmp+33,imei,i); i=32+1+i; //使用长度为len的randBuf加密串对长度为i的tmp进行加密 extCodeBuffer(randBuf, len, tmp, i); //将长度为i的tmp内存以十六进制串打包发? for(j=0;j'9') return; netModeValue=atoi(msg); ctecCurrentSet=netModeValue; if(ctecCurrentSet != newPara.netMode){ snprintf(cmd, sizeof(cmd),"AT+CTEC=%d,%d\r\n", ctecCurrentSet, newPara.netMode); msgAtSend(cmd); } } /* +COPS: 0,2,"46000",7 msg=+COPS: 0,2,"46000",7 */ static void proCopsMsg(char *msg){ int i,j=0,codeType; char w=0; unsigned char netModeValue; MSG_INFO(1,"enter PORCOPS"); for(i=0;i0 && codeType != sutApp.copstype) sutApp.copstype=codeType; } */ } } } /* +SIMCROSS:0 msg=0/1 */ static void proSimMode(char *msg){ unsigned char tmpSim; tmpSim=msg[0]-0x30; if(tmpSim!=0 && tmpSim!=1) return; sutApp.simSel=tmpSim; } /* +UDP:0,5,30 msg=0,5,30 */ static void proPwrMode(char *msg){ int seg1,seg2; short i; char buf[15]; for(i=2;i