#include "includes.h" #include "lsapi_tts.h" #include "osi_api.h" //#define ANT_TEST #define APP_IDLE_TIME 3 //如果POC已休眿APP没有操作一定秒数后休眠 int keyNum=0; APP_DEF sutApp; static void appDataInit(void){ memset((unsigned char *)&sutApp, 0, sizeof(APP_DEF)); sutApp.pcant=4; sutApp.enableKey=1; //appSleepCtl(ASLEEP_POC, 1); appSleepCtl(ASLEEP_LCD, 1); readInfoNow(); sysIniRead(); } void dataInit(void){ appDataInit(); pocDataInit(); gpsDataInit(); uiDataInit(); } static void ledsProCtl(void){ if(sutApp.gtMode!=0) return; if(0==sutPocStatus.logined) uioStatusSet(UIO_INDOFFLINE); else if(sutPocStatus.spk>0)uioStatusSet(UIO_INDRX); else if(sutPocStatus.mic>0 )uioStatusSet(UIO_INDTX); else uioStatusSet(UIO_INDONLINE); } static void KeyToneDly(); static void adcRead(unsigned int interval); char isKeyPress(void){ if(keyNum) return keyNum--; else return 0; } /*APP休眠处理接口 ctlType, 操作对象 status,操作值,0 清除 else 设置 */ void appSleepCtl(ASLEEP_ENUM ctlType, char status){ if(status==0) sutApp.appSleepStatus &= ~(1<=(APP_IDLE_TIME*1000/APP_SUB_DIV_TIME)){ idleCnt=0; return 1; }else return 0; } void usbCmdHandler(const char *data,unsigned int length){ static char buf[256]; static int len=0; static char lach; char ch; int i; if(sutApp.authReady==0){ authRecvPro(data, length); return; } for(i=0;i=(1000/KEY_TIMER_TICK)){//每秒产生持续倿 keyCnt=0; needSendKey=1; } } } if(needSendKey){ if(sutApp.enableKey!=0)//延时期间不检测按锿 keySendEvent(lkey,keyType); } } void pwrDetRead(char type){ static char cnt=0; if(type==0){ if(++cnt>=5){ MSG_INFO(1, "Power is off!"); appSleepCtl(ASLEEP_PWR, 1); } }else{ cnt=0; } } static void lockProcess(void){ if(sutApp.keyLock==0){ sutApp.keyLock=1; appSleepCtl(ASLEEP_GGROUP, 0); appSleepCtl(ASLEEP_GUSER, 0); uISetNextStatus(UIS_STANDBY); }else{ sutApp.keyLock=0; sutApp.lockShow=0; } } //key:1 跳过 void keyToneStart(char type){ //return; if(newPara.KeySound==0&&type==0) return; if(sutPocStatus.TTS)return; if(type==2)sutPocStatus.beep=2; else sutPocStatus.beep=1; paControl(true); MSG_INFO(1, "Ptt:%d\r\n",sutPocStatus.PttFail); if(ToneThreadPtr!=NULL)threadSendEvent(ToneThreadPtr,OHPOC_EVENT_MAIN,NULL,NULL,NULL);//0702 } void quickUiSwitch(int uistatus){ uISetNextStatus(uistatus); getStackStruct()->FastUiChange=1; } /*进入GT模式*/ static void enterGTMode(void){ #ifndef ENABLE_PWM_BEEP msgAtSend("AT+TONES=1\r\n"); #endif sutApp.gtMode=1; uioStatusSet(UIO_INDGT); paControl(true);//GT下常开喇叭 #ifdef ENABLE_PWM_BEEP pwmBeepStart(868,50); LSAPI_OSI_ThreadSleep(100); pwmBeepStart(500,50); LSAPI_OSI_ThreadSleep(100); pwmBeepStart(868,50); #else msgAtSend("AT+TONE\r\n"); LSAPI_OSI_ThreadSleep(200); msgAtSend("AT+TONE\r\n"); #endif MSG_WARN(1, "Enter GT Mode"); } void micPttHandler(char status){ keySendEvent(MKEY_VALUE_MIC_PTT,status); } void keyHandler(unsigned short key,unsigned char status){//普通按键值处琿 static unsigned char gtModeCnt=0; static unsigned char lockCnt=0; if(sutApp.keyLock!=0 && MKEY_VALUE_ESC!=key){ sutApp.lockShow=1; return; } showKeyMessage(key,status); if(status==0){//key free switch(key){ case MKEY_VALUE_MIC_PTT: pttHandler(0,0); break; case MKEY_VALUE_PTT: pttHandler(1,0); break; case MKEY_VALUE_PWR: //pwrDetRead(1); break; case MKEY_VALUE_ESC: //sutApp.LightStatus=1; pwrDetRead(1); lockCnt=0; if(sutUIstatus.Status==UIS_STANDBY){ if(sutApp.LightStatus==0){ if(!sutApp.cardStatus)return; if(lockCnt>1)return; if(sutPocStatus.danHuStatus)return; if(sutApp.MenuToStandby){ sutApp.MenuToStandby=0; return; } startBackLightTimer(100); sutApp.LightStatus=1; }else { tryWakeupApp(); backLightReset(); sutApp.LightStatus=0; } } break; case MKEY_VALUE_F1: if(sutApp.key_f1_cnt==1 && sutUIstatus.Status!=UIS_MENU_SYS_SERVERPASS) sutApp.voluemUpdate=1; sutApp.key_f1_cnt=0; break; case MKEY_VALUE_F2: if(sutApp.key_f2_cnt==1 && sutUIstatus.Status!=UIS_MENU_SYS_SERVERPASS) sutApp.voluemUpdate=2; sutApp.key_f2_cnt=0; break; case MKEY_VALUE_CB_GT: gtModeCnt=0; break; default: break; } keyInArow=0; appSleepCtl(ASLEEP_MKEY, 0); }else{//key press //if(key!=MKEY_VALUE_PTT && key!=MKEY_VALUE_CB_GT&&key!=MKEY_VALUE_MIC_PTT) keyToneStart(); if(key!=MKEY_VALUE_PTT && key!=MKEY_VALUE_CB_GT&&key!=MKEY_VALUE_MIC_PTT) keyToneStart(0); backLightReset(); appSleepCtl(ASLEEP_MKEY, 1); keyNum++; switch(key){ case MKEY_VALUE_MIC_PTT: pttHandler(0,1); break; case MKEY_VALUE_PTT: pttHandler(1,1); break; case MKEY_VALUE_PWR: keyInArow=1; //pwrDetRead(0); break; case MKEY_VALUE_ESC: keyInArow=1; lockCnt++; if(lockCnt==3){ keyToneStart(0); // lockProcess(); //舍弃加锁功能 } pwrDetRead(0); break; case MKEY_VALUE_F1: //sutApp.key_f1_cnt++; keyInArow=1; if(++sutApp.key_f1_cnt==3) quickUiSwitch(UIS_MENU_INFO_SEL); break; case MKEY_VALUE_F2: keyInArow=1; if(++sutApp.key_f2_cnt==3) quickUiSwitch(UIS_MENU_SYS_SIM); break; case MKEY_VALUE_CB_GT: keyInArow=1; if(++gtModeCnt==3){ if(sutApp.gtMode==0){ enterGTMode(); } } break; case MKEY_VALUE_CB_IP: keyInArow=1; break; default: break; } } } /////////////////////////////事件发送接叿////////////////////////// void threadSendEvent(LSAPI_OSI_Thread_t *threadID, unsigned int id, unsigned int param1,unsigned int param2,unsigned int param3){ LSAPI_OSI_Event_t pEventSend; pEventSend.id=id; pEventSend.param1=param1; pEventSend.param2=param2; pEventSend.param3=param3; osiEventTrySend(threadID,&pEventSend,0); } //////////////////////////////其它处理接口////////////////////////// static void adcRead(unsigned int interval){ static unsigned int siVbat=0,laSiVbat; static unsigned char MIC_ptt=0; static unsigned char LastMIC_ptt=0; static unsigned short cnt=0,lcnt=0; unsigned int adcValueTmp; if(++cnt<(1000/interval)) return;//1秒读一次ADC即可 cnt=0; LSAPI_SYS_BattGetVol(&adcValueTmp); //MSG_WARN(1,"Low power:%d mv",adcValueTmp/10 ); if(sutApp.g_iBAT<=MIN_PWR_LEVEL){ MSG_WARN(1,"Low power:%d", lcnt++); if(lcnt>=10){ MSG_INFO(1, "Low power ,shut"); sutApp.lowPwrMsg=1; appSleepCtl(ASLEEP_PWR, 1); } }else lcnt=0; sutApp.g_iBAT=adcValueTmp/10; if(sutApp.g_iBAT != laSiVbat){ laSiVbat=sutApp.g_iBAT; } /* ***************EAR PTTdet ADC**************************/ //通道3 范围3V if(LSAPI_Device_AdcGetChannelVolt(3,3)<1000)MIC_ptt=1; else MIC_ptt=0; if(LastMIC_ptt!=MIC_ptt){ if(MIC_ptt==1)micPttHandler(1); else micPttHandler(0); LastMIC_ptt=MIC_ptt; } //MSG_WARN(1,"Low power:%d mv", LSAPI_Device_AdcGetChannelVolt(3,3)); /******************************判断TTS 是否结束************************************************/ if(false==LSAPI_TTS_IsPlaying())sutPocStatus.TTS=0; /**********************应用播放TONE2秒后关闭喇叭************************************/ KeyToneDly(); } /*处理UI操作*/ static void uiProcess(unsigned int exeInterval){ if(getAppObjStatus(ASLEEP_PWR) != 0) return;//关机后,不切换菜单,只显示关机页靿 uiLoop(exeInterval); uiResponse(exeInterval); } /*触发关机操作*/ static void pwrShutPro(void){ static char shutFlag=0; if(getAppObjStatus(ASLEEP_PWR) == 0) return; CTL_LCD_BL(1); //msgAtSend("AT+POC=050000\r\n"); msgToModem("AT+CFUN=0\r\n"); if(shutFlag==0){ //显示关机界面 if(sutApp.lowPwrMsg==0){ guiShowMessageBox("正在关机"); }else guiShowMessageBox("低压关机"); shutFlag=1; LSAPI_OSI_ThreadSleep(1000); } MSG_INFO(1, "Normal PwrOff"); //msgAtSend("AT+TRB=1\r\n");//normal power off 当前固件先不发模块关机指令,否则断电再上电有可能是起不来皿 //LSAPI_OSI_ThreadSleep(1000);//一秒后释放电源锿防止软关机不成功 CTL_LCD_BL(0); MSG_INFO(1, "Release pwr"); guiFillRect(0,0,GLCD_WIDTH-1,GLCD_HEIGHT-1,guiGetBackColor());//防止下次开机能看到残留 CTL_POWER_HOLD(0); msgToModem("AT+CPOF\r\n");//软件关机模块 LSAPI_OSI_ThreadSleep(100); } static void NoteCheck(int interval){ int dlyMs; const char *lowVbat="E8AFB7E58585E794B5"; char ttsbuf[40]; StrAsciiToHex(lowVbat,ttsbuf); if(sutApp.lowPwrWarn!=0){ sutApp.lowPwrCnt += interval; if(sutApp.lowPwrCnt>=WARN_TTS_INTERVAL){ sutApp.lowPwrCnt=0; //broad_play_tts(ttsbuf,true); } } } void AntModeRun(void){ #ifdef ENABLE_ANT_MODE guiShowMessageBox("调天线模式"); for(;;){ LSAPI_OSI_ThreadSleep(2000); } #endif } static void paProCtl(void); static void subTimerCtl(unsigned char sleep_or_not); static void startPocLogin(void){ if(sutApp.startPoc==0) return; MSG_INFO(1, "Start poc"); sutApp.startPoc=0; msgAtSend("AT+POC=0000000001\r\n");//打开对讲,关闭POC播放TTS //msgAtSend("AT+POC=0000000101\r\n"); } void pocSetDomain(void){//设置域名前缀 // const char platform[]="platform2"; // const char pFormatMark[]="chn-gwsd-"; char info[100]="AT+POC=120000"; char tbuf[50]; char* platform=0; char* pFormatMark=0; platform=sutApp.UserInfo.platform; pFormatMark=sutApp.UserInfo.pFormatMark; snprintf(tbuf, sizeof(tbuf), "%s,%s", platform,pFormatMark); AscStrTurnHexStr(tbuf, info+strlen(info)); strcat(info, "00\r\n"); msgAtSend(info); MSG_INFO(0, "**%s",info); } void ShouHuProcess(int interva) { static char nRet=0; static char regcnt=0; //static int LastAtt_state=0; int tmepAtt_state=0; static int cnt=0; if(sutApp.gtMode!=0)return; if(++cnt<(1000/interva)) return; cnt=0; nRet=LSAPI_NET_GetGprsAttState(&tmepAtt_state); if(nRet!=0){ MSG_WARN(1,"Get REG status failed"); return; } if(tmepAtt_state!=1){ //if(LastAtt_state!=tmepAtt_state)MSG_WARN(1,"REG off"); if(regcnt==60){ MSG_WARN(1,"!!!!CFUN=0"); msgAtSend("AT+CFUN=0\r\n"); backLightReset(); sutPocStatus.firstLogin=0; }else if(regcnt>=61){ MSG_WARN(1,"!!!!CFUN=1"); msgAtSend("AT+CFUN=1\r\n"); regcnt=0; } ++regcnt; }else { regcnt=0; } } #define APP_NEED_SLEEP OSI_MAKE_TAG('S', 'E', 'L', 'P') void ls_suspend(void *ctx, osiSuspendMode_t mode) { MSG_INFO(1,"\n\r ls_suspend mode:%d\n",mode); } void ls_resume(void *ctx, osiSuspendMode_t mode, uint32_t source) { MSG_INFO(1,"\n\r ls_resume mode:%d,source:%d\n",mode,source); } osiPmSourceOps_t sleep_ops = { ls_suspend, ls_resume, NULL, NULL }; void appRun(void){ char cnt=0; char printfbuf[20]={0}; LSAPI_OSI_Event_t event={0}; osiPmSource_t*App_osiPmSource_t=NULL; App_osiPmSource_t=osiPmSourceCreate(APP_NEED_SLEEP, &sleep_ops, NULL); osiPmWakeLock(App_osiPmSource_t); //拿住资源不让系统休眠 //等待lcd初始化完房 MSG_INFO(1, "wait lcd init"); while(sutApp.guiStatus==0){LSAPI_OSI_ThreadSleep(50);}//是否检测超时? AntModeRun(); localAuthNow(); while(sutApp.pocInitStatus==0){ msgAtSend("AT+POC=version\r\n");//发指令后等待POC启动 LSAPI_OSI_ThreadSleep(1000); }//是否检测超时? msgToModem("AT+SIMCROSS?\r\n"); adcRead(APP_SUB_DIV_TIME);//在开机播放前设置下SPK backLightReset(); //LSAPI_TTS_Play msgToModem("ATI\r\n"); while(sutApp.Get_MicLv==0){ msgToModem("AT+CACCP=0,0,1,\"\"\r\n"); LSAPI_OSI_ThreadSleep(1000); if(++cnt>=5){ MSG_INFO(1, "get MicLv timeout"); break; } } msgToModem("AT+GMR\r\n");//查询模块版本 while(sutApp.pocParaDone==0){ msgAtSend("AT+POC=020000\r\n"); LSAPI_OSI_ThreadSleep(1000); if(++cnt>=5){ MSG_INFO(1, "read pocPara erro"); break; } } pwrModeSetCmd(newPara.pwrMode);//设置功耗模式 voiceModeSet(newPara.voiceSel);//设置音质 while(sutApp.startPoc==1){ LSAPI_OSI_ThreadSleep(1000); startPocLogin(); } while(sutApp.cardStatus==0){ //msgToModem("AT+CCID\r\n"); msgToModem("AT+CPIN?\r\n"); LSAPI_OSI_ThreadSleep(1000); if(++cnt>=10){ MSG_INFO(1, "Check card timeout"); if(newPara.ChangeCard==0){ MSG_INFO(1, "REsel card "); newPara.ChangeCard=1; snprintf(printfbuf, sizeof(printfbuf), "AT+SIMCROSS=%d\r\n",sutApp.simSel); msgToModem(printfbuf); MSG_INFO(1, printfbuf); guiShowMessageBox("正在切卡"); sysIniSave(); LSAPI_OSI_ThreadSleep(1000); msgToModem("AT+TRB\r\n"); LSAPI_OSI_ThreadSleep(1000); while(1); } break; } } newPara.ChangeCard=0; sysIniSave(); //msgAtSend("AT+POC=7B00000064\r\n"); msgToModem("ATE0\r\n"); msgToModem("AT+AUDCH=0,0\r\n");//TEST 因为模块默认 通道为2,0 pocSetDomain(); //msgAtSend("AT+POC=0000000101\r\n"); //osiPmWakeUnlock(App_osiPmSource_t); for(;;){ // MS5700_Networking(APP_SUB_DIV_TIME); //网络监测 // Domain_Process(APP_SUB_DIV_TIME); // // FOTA_Process(APP_SUB_DIV_TIME); volUpdateNeed(); ledsProCtl(); adcRead(APP_SUB_DIV_TIME); uiProcess(APP_SUB_DIV_TIME); if(GPS_HADRENABLE==1){ gpsProCtl(APP_SUB_DIV_TIME); GpsInternalChange(APP_SUB_DIV_TIME); } #ifndef ANT_TEST pocProCtl(APP_SUB_DIV_TIME); #endif NoteCheck(APP_SUB_DIV_TIME); //GpsInternalChange(APP_SUB_DIV_TIME); ShouHuProcess(APP_SUB_DIV_TIME); //HookGroupUserInfo(); HookVolToutCheck(); //IncomingSMS(); if(isSleepReady()==0) LSAPI_OSI_ThreadSleep(APP_TASK_SLEEP_TIME); else if(sutApp.gtMode==0){//正常模式下可以休眿 MSG_WARN(1, "APP SLEEP"); stopKeyTimer(); subTimerCtl(1);//切换为休眠状态定时器 sutApp.appStatus=1; redLedCtl(false);//休眠后保证灯没亮,否则有可能灯亮10ms,按理10ms后灯能灭,然后10ms时休眠了,应用就短时间内不会灭灯 greenLedCtl(false);//休眠后保证灯没亮 LSAPI_OSI_EventWait(LSAPI_OSI_ThreadCurrent(), &event); lcdDrv_Init(1);//深度休眠唤醒后重新初始化SPI-LCD if(sutApp.lcdDlyLightUp){ sutApp.lcdDlyLightUp=0; CTL_LCD_BL(1); } sutApp.forceUiFlash=1; sutApp.appStatus=0; subTimerCtl(0);//切换为唤醒状态定时器 MSG_WARN(1, "APP WAKEUP"); } //检测是否关机,这里要放在唤醒后操作 pwrShutPro(); } } unsigned int subTimerInterval=100;//定时器定时的时间 LSAPI_OSI_Timer_t *pSubtimer_t = NULL; /* 为了做低功耗,此定时器在休眠时,设置为长时间定旿 非休眠时,设置为短时间定旿 sleep_or_not:0 未休眠, else 休眠 */ static void subTimerCtl(unsigned char sleep_or_not){ if(NULL==pSubtimer_t){ MSG_WARN(1, "subTimer null"); return; } LSAPI_OSI_TimerStop(pSubtimer_t); //打开定时噿 if(sleep_or_not==0) subTimerInterval=100;//未休眠时_00ms else subTimerInterval=5000;//休眠旿5000ms LSAPI_OSI_TimerStart(pSubtimer_t,subTimerInterval); } static void subTimeroutcallback(void *param){ unsigned int *dlyTime=(unsigned int *)param; //处理灯的显示 uioProctl(*dlyTime); //控制功放的关闿 paProCtl(); if(NULL!=pSubtimer_t) LSAPI_OSI_TimerStart(pSubtimer_t,subTimerInterval); } void subTask(void *param){ LSAPI_OSI_Event_t event={0}; if(NULL==pSubtimer_t) pSubtimer_t = LSAPI_OSI_TimerCreate(LSAPI_OSI_ThreadCurrent(), subTimeroutcallback, (void *)&subTimerInterval); if(NULL==pSubtimer_t) MSG_WARN(1,"sub timer init failed"); else LSAPI_OSI_TimerStart(pSubtimer_t,subTimerInterval); for(;;){LSAPI_OSI_EventWait(LSAPI_OSI_ThreadCurrent(), &event);} } static void paProCtl(void){ //会被定时调用 if(sutPocStatus.TTS!=0) return; if(sutPocStatus.spk!=0) return; if(sutPocStatus.TONE!=0) return; if(sutPocStatus.beep!=0) return; if(sutApp.gtMode!=0) return; paControl(false); //测试版本 //MSG_INFO(1,"spk off"); } void tryWakeupApp(void){ if(sutApp.appStatus!=0){ if(mainThreadPtr!=NULL){ threadSendEvent(mainThreadPtr,OHPOC_EVENT_MAIN,NULL,NULL,NULL); } } } void ttsPlay(ENCODE_USER_ENUM type, char *tts){ int len,i; char ttsMessage[20*4]; char Playbuf[100]={0}; unsigned char codeType=ENCODE_USER_GBK; if(newPara.ttsMessage[0]==0) return; len=strlen(newPara.ttsMessage); len = len+(8-len%8);// MSG_INFO(1,"tts->"); if(type==ENCODE_USER_UNICODE_BE) { codeType=LSAPI_TTS_UNICODE_BIG; for(i=0;i 0x31,0x32 void StrAsciiToHex(char *src, unsigned char *des){ unsigned char temp[2],i; if(strlen(src)%2) return; while(0!=*src) { for(i=0;i<2;i++) { temp[i] = *src++; if(temp[i] >= '0' && temp[i] <= '9') temp[i] -= 0x30; else if(temp[i] >= 'A' && temp[i] <= 'F') temp[i] -= 0x37; else temp[i] -= 0x57; } temp[0] <<= 4; temp[0] &= 0xf0; *des++=temp[0]|temp[1]; } *des=0; } void splVolumeSet(unsigned char level){ char info[30]; #ifdef ANT_TEST return; #endif // memset(info, 0, sizeof(info)); snprintf(info, sizeof(info), "AT+CLVL=%d\r\n", level); msgToModem(info); snprintf(info, sizeof(info), "AT+CRSL=%d\r\n", level); msgToModem(info); //// broad_set_vol(BND_VOICE, level/10); // broad_set_vol(BND_TTS, level/12);//10 // broad_set_vol(BND_TONE, level/12); //MSG_INFO(1,"#############################################"); } /*调节音量,刷新音量进度条*/ /*调节音量,刷新音量进度条*/ void volAdjAction(char direction,unsigned char UIStatus){ int vol; #ifdef ANT_TEST return; #endif if(direction==0){ if(newPara.spkVol0) newPara.spkVol--; else goto FLASH; } splVolumeSet(newPara.spkVol*10); MSG_INFO(1,"SPK_VOL:%d",newPara.spkVol*10); // vol=broad_get_vol(BND_VOICE); // MSG_INFO(1,"voice_VO1L:%d",vol); // vol=broad_get_vol(BND_TTS); // MSG_INFO(1,"tts_VOL2:%d",vol); // vol=broad_get_vol(BND_TONE); // MSG_INFO(1,"tone_VOL3:%d",vol); sysIniSave(); //刷新进度条 FLASH: if(UIS_STANDBY==UIStatus)volUiFlash(newPara.spkVol); } void volUpdateNeed(void){ if(sutApp.voluemUpdate==0) return; if(sutApp.voluemUpdate==1) volAdjAction(0, sutUIstatus.Status); else if(sutApp.voluemUpdate==2) volAdjAction(1, sutUIstatus.Status); sutApp.voluemUpdate=0; } /* //对都使用主音频通道设计来说,耳机模式时,需要按比例降低输入输出增益 unsigned char micGainTable[MIC_GAIN_NUM][2]={ {3,10},{4,2},{4,10},{5,2},{5,10},{6,2},{6,10} }; void VolMicUpdate(void){ unsigned char tableIndex; char cmd[50]; int vol=newPara.spkVol*10; splVolumeSet(vol); if(sutApp.earLev==0){//耳机拔掉,恢复正常MIC增益 tableIndex=newPara.micGain_onspk; //msgAtSend("AT+CACCP=0,0,0,\"04000a00\"\r\n"); }else{//耳机接入 tableIndex=newPara.micGain_onear; //msgAtSend("AT+CACCP=0,0,0,\"02000f00\"\r\n"); } if(tableIndex>=MIC_GAIN_NUM){ MSG_WARN(1, "Index invalid:%d", tableIndex); return; } snprintf(cmd, sizeof(cmd), "AT+CACCP=0,0,0,\"%02x00%02x00\"\r\n", micGainTable[tableIndex][0],micGainTable[tableIndex][1]); msgAtSend(cmd); } */ static void KeyToneDly() { static unsigned char Cnt=0; if(sutPocStatus.beep){ if(++Cnt>1){ Cnt=0; sutPocStatus.beep=0; } }else Cnt=0; }