/******************************************************************************** * File Name: TestTask.c * Function Describe:The test task for the system * Relate Module: * Explain: Hardware version is HS121 * Writer: ShiLiangWen * Date: 2015.7.14 *******************************************************************************/ #define THIS_FILE_ID 16 //--------------------------------------------------------------------------------- #include "includes.h" //OS ID OS_TID idTestTask; unsigned char g_ucTestId;//测试账号ID 0未选,1~5分别代表Test001~Test005 unsigned char g_ucTestIdSel;//测试账号选择 0--正常模式 1--选择模式 void ReportTestId(void); void SendTestIdToModem(unsigned char id); void TestModeEncodeKeyProcess(void); void TestModeKeyPress(void); void TestModeKeyFree(void); /************************************************************************************* * **************************************************************************************/ int IsTestMode(void) { int i,KeyFlag; g_ulKeyValue=0; for(i=0;i<50;i++){//wait 500ms for getkey if(0!=(KeyFlag=GetKey())){ if(1==KeyFlag){ //按键按下 if(KEY_DOWN==g_ulKeyValue){ return 1; } } } os_dly_wait(1); } return 0; } /************************************************************************************* *TestTask **************************************************************************************/ __task void TestTask(void) { int KeyFlag; char *msg; INT8U err; char buf[30]; unsigned char ucIsModemOk=0; RunMake(THIS_FILE_ID); //Begin MainTask loop SlwTrace(INF,"Test Mode Start...\r\n"); //Wait NetTask running and modem init Completed g_ucTestIdSel=1;//选择账号模式未开启 g_ucTestId=0; //默认测试账号Test001 while(1){ if(OS_R_TMO!=os_evt_wait_or(0x0001, 1))break; //处理UART3接收缓冲区数据 Uart3RecvProcess(); IWDG_ReloadCounter();//喂狗 } ModemSendAT("AT+ZTTS=1,\"F78B0990E9624B6DD58B268DF753\"\r"); //请选择测试账号 SpeakerEnable(); os_itv_set (1); while(1) { os_itv_wait ();//wait 1 tick IWDG_ReloadCounter();//喂狗 //处理UART3接收缓冲区数据 Uart3RecvProcess(); //键盘处理 if(0!=(KeyFlag=GetKey())){ //printf("Key F=%d,V=%04x\r\n",KeyFlag,g_ulKeyValue); //按键处理 if(1==KeyFlag){ //按键按下 TestModeKeyPress(); }else{ //按键释放 TestModeKeyFree(); } } RunMake(THIS_FILE_ID); TestModeEncodeKeyProcess(); RunMake(THIS_FILE_ID); if(OnOffCheck()){ PWR_EN_LOW; } } } void ReportTestId(void) { SpeakerEnable(); switch(g_ucTestId){ case 1: ModemSendAT("AT+ZTTS=1,\"4B6DD58B3100\"\r");//测试1 break; case 2: ModemSendAT("AT+ZTTS=1,\"4B6DD58B3200\"\r");//测试1 break; case 3: ModemSendAT("AT+ZTTS=1,\"4B6DD58B3300\"\r");//测试1 break; case 4: ModemSendAT("AT+ZTTS=1,\"4B6DD58B3400\"\r");//测试1 break; case 5: ModemSendAT("AT+ZTTS=1,\"4B6DD58B3500\"\r");//测试1 break; } } void TestModeEncodeKeyProcess(void) { if(0==g_iEncode)return; if(g_iEncode>0){//====================顺时针旋转 SlwTrace(DEBUG,"[+]\r\n"); if(g_ucTestIdSel){ if(++g_ucTestId>5)g_ucTestId=1; ReportTestId(); } }else{//==============================逆时针旋转 SlwTrace(DEBUG,"[-]\r\n"); if(g_ucTestIdSel){ if(g_ucTestId>1)g_ucTestId--; else g_ucTestId=5; ReportTestId(); } } g_iEncode=0; } void SendTestIdToModem(unsigned char id) { char buf[50]; char buf1[100]; char strAccount[10]; if(id>=10)return; strcpy(strAccount,"PTest001"); strAccount[7]=0x30+id; //send to modem SpeakerEnable(); sprintf(buf,"ip=%s;id=%s;pwd=111111;",POC_TEST_SERVER_IP,strAccount); AscStrToHexStr(buf,buf1); ModemSendAT("AT+POC=120000"); ModemSendAT(buf1); ModemSendAT("\r\n"); //send to pc SlwTrace(INF,"AT+POC=120000"); SlwTrace(INF,buf1); SlwTrace(INF,"\r\n"); } /*********************************************************************** *按键按下事件 ************************************************************************/ void TestModeKeyPress(void) { static unsigned char sucReportFlag=0; switch(g_ulKeyValue){ //------------------------------------------------------------------- case KEY_PPT://=====================PPT KEY Press==================== //------------------------------------------------------------------- SlwTrace(DEBUG,"[PPT Press]\r\n"); if(g_ucTestIdSel){ if(g_ucTestId>0 && g_ucTestId<6){ SpeakerEnable(); sutPocStatus.PPTpress=1; MODEM_DTR_LOW; }else{ SpeakerEnable(); ModemSendAT("AT+ZTTS=1,\"F78B0990E9624B6DD58B268DF753\"\r"); //请选择测试账号 } }else{ SpeakerEnable(); sutPocStatus.PPTpress=1; MODEM_DTR_LOW; } break; //------------------------------------------------------------------- case KEY_UP://=====================FUN1 KEY Press================== //------------------------------------------------------------------- SlwTrace(DEBUG,"[KEY1 Press]\r\n"); if(0==g_ucTestIdSel){ g_ucTestIdSel=1; SpeakerEnable(); ModemSendAT("AT+ZTTS=1,\"F78B0990E9624B6DD58B268DF753\"\r"); //请选择测试账号 }else{ g_ucTestIdSel=0; SpeakerEnable(); ModemSendAT("AT+ZTTS=1,\"0090FA510990E962\"\r"); //退出选择 } break; //------------------------------------------------------------------- case KEY_DOWN://=====================FUN2 KEY Press================= break; } } /*********************************************************************** *按键释放事件 ************************************************************************/ void TestModeKeyFree(void) { //------------------------------------------------------------------- if(KEY_PPT==g_ulKeyValue) {//===============PPT KEY Free============= //------------------------------------------------------------------- SlwTrace(DEBUG,"[PPT Free]\r\n"); sutPocStatus.PPTpress=0; MODEM_DTR_HIGH; //------------------------------------------------------------------- }else if(KEY_UP==g_ulKeyValue){//=========FUN1 KEY Free============== //------------------------------------------------------------------- //------------------------------------------------------------------- }else if(KEY_DOWN==g_ulKeyValue){//=========FUN1 KEY Free============ //------------------------------------------------------------------- ReportUserGroupName(); //------------------------------------------------------------------- } }