Browse Source

Add timeout return

zack 1 year ago
parent
commit
d41477e316
7 changed files with 3218 additions and 3159 deletions
  1. 2 1
      Core/Inc/interface.h
  2. 5 0
      Core/Src/freertos.c
  3. 26 1
      Core/Src/interface.c
  4. 6 1
      Core/Src/key.c
  5. 1 1
      Core/Src/ml307a.c
  6. 5 0
      MDK-ARM/dtu.uvoptx
  7. 3173 3155
      Output/dtu.hex

+ 2 - 1
Core/Inc/interface.h

@@ -3,12 +3,13 @@
 #include "main.h"
 #include "main.h"
 
 
 
 
-
+extern uint32_t enterInterface_time;
 
 
 
 
 void createString(char* result, char* atcon, char* mac, char* crlf);
 void createString(char* result, char* atcon, char* mac, char* crlf);
 extern bool refresh; 	
 extern bool refresh; 	
 
 
+extern bool returnInterface;
 
 
 extern char Atcon[];
 extern char Atcon[];
 extern char CRLF[];
 extern char CRLF[];

+ 5 - 0
Core/Src/freertos.c

@@ -198,6 +198,11 @@ void StartTestTask(void const * argument)
 		HAL_Delay(1800);//µÈ´ý4GÆô¶¯
 		HAL_Delay(1800);//µÈ´ý4GÆô¶¯
         ML307A_Init(); 
         ML307A_Init(); 
     }	
     }	
+	if(returnInterface)
+	{
+		returnInterface=false;
+		SET_MENU_STATUS(0,0,0,0);
+	}
 		  
 		  
   }
   }
   /* USER CODE END StartTestTask */
   /* USER CODE END StartTestTask */

+ 26 - 1
Core/Src/interface.c

@@ -11,7 +11,7 @@ bool L1bd = false;						//L1
 bool L2bd = false;						//L2°ó¶¨±ê־λ
 bool L2bd = false;						//L2°ó¶¨±ê־λ
 bool L3bd = false;						//L3°ó¶¨±ê־λ
 bool L3bd = false;						//L3°ó¶¨±ê־λ
 bool L4bd = false;						//L4°ó¶¨±ê־λ	
 bool L4bd = false;						//L4°ó¶¨±ê־λ	
-
+bool returnInterface = false;
 unsigned char Mac001[]="101000000001";
 unsigned char Mac001[]="101000000001";
 unsigned char Mac002[]="101000000002";
 unsigned char Mac002[]="101000000002";
 unsigned char Mac003[]="101000000003";
 unsigned char Mac003[]="101000000003";
@@ -62,10 +62,18 @@ void Jump_interface(Menu_table menu)
 		break;
 		break;
 		
 		
 		case 1:
 		case 1:
+			if(HAL_GetTick() - enterInterface_time >= 10000)
+			{
+				returnInterface=true;
+			}
 			mainMenu();
 			mainMenu();
 		break;
 		break;
 		
 		
 		case 2:
 		case 2:
+			if(HAL_GetTick() - enterInterface_time >= 10000)
+			{
+				returnInterface=true;
+			}
 			if(menu.up==0)
 			if(menu.up==0)
 			{
 			{
 				clearSn();
 				clearSn();
@@ -79,6 +87,10 @@ void Jump_interface(Menu_table menu)
 		
 		
 		
 		
 		case 3:
 		case 3:
+			if(HAL_GetTick() - enterInterface_time >= 10000)
+			{
+				returnInterface=true;
+			}
 			setLock();
 			setLock();
 		break;
 		break;
 			
 			
@@ -86,15 +98,28 @@ void Jump_interface(Menu_table menu)
 		case 5:
 		case 5:
 		case 6:
 		case 6:
 		case 7:
 		case 7:
+			if(HAL_GetTick() - enterInterface_time >= 20000)//Ê©½â·âÑÓ³¤ÖÁ20s
+			{
+				sendCmd_BT("AT+DISCONN=0\r\n","ERROR",1,1);//¶Ï¿ªÁ¬½Ó
+				returnInterface=true;
+			}
 			workSet(menu);
 			workSet(menu);
 		break;
 		break;
 		
 		
 		
 		
 		case 0xA1:
 		case 0xA1:
+			if(HAL_GetTick() - enterInterface_time >= 10000)
+			{
+				returnInterface=true;
+			}
 			Macbinding();
 			Macbinding();
 		break;
 		break;
 		
 		
 		case 0xBB:
 		case 0xBB:
+			if(HAL_GetTick() - enterInterface_time >= 10000)
+			{
+				returnInterface=true;
+			}
 			WarningTip();
 			WarningTip();
 		break;
 		break;
 		
 		

+ 6 - 1
Core/Src/key.c

@@ -15,6 +15,8 @@ uint16_t S1 = 0;
 uint16_t S2 = 0;
 uint16_t S2 = 0;
 uint16_t S3 = 0;
 uint16_t S3 = 0;
 uint16_t S4 = 0;
 uint16_t S4 = 0;
+uint32_t enterInterface_time = 0;
+
 uint8_t KEY_1_Scan(void)
 uint8_t KEY_1_Scan(void)
 {
 {
     static uint8_t key_state = 0;
     static uint8_t key_state = 0;
@@ -36,6 +38,7 @@ uint8_t KEY_1_Scan(void)
             {
             {
 				if(!sent1_key)
 				if(!sent1_key)
 				{
 				{
+					enterInterface_time = HAL_GetTick();
 					switch(menu.current)
 					switch(menu.current)
 					{
 					{
 							case 0:
 							case 0:
@@ -153,12 +156,13 @@ uint8_t KEY_2_Scan(void)
     }
     }
     else
     else
     {
     {
-        if (HAL_GetTick() - debounce_time > 30) // 去抖时间大于50ms
+        if (HAL_GetTick() - debounce_time > 30) // 去抖时间大于30ms
         {
         {
             if (key_state == GPIO_PIN_RESET) // 按键按下
             if (key_state == GPIO_PIN_RESET) // 按键按下
             {
             {
 				if (!sent2_key)
 				if (!sent2_key)
 				{
 				{
+					enterInterface_time = HAL_GetTick();
 					switch (menu.current)
 					switch (menu.current)
 					{
 					{
 						case 0:
 						case 0:
@@ -280,6 +284,7 @@ uint8_t KEY_3_Scan(void)
             if (key_state == GPIO_PIN_RESET) // 按键按下
             if (key_state == GPIO_PIN_RESET) // 按键按下
             {
             {
 				if (!sent3_key) {
 				if (!sent3_key) {
+					enterInterface_time = HAL_GetTick();
 					switch (menu.current) {
 					switch (menu.current) {
 						case 0://跳转到菜单界面
 						case 0://跳转到菜单界面
 						{
 						{

+ 1 - 1
Core/Src/ml307a.c

@@ -55,7 +55,7 @@ void ML307A_Init(void)
 					sendCmd_4G("AT+CEREG?\r\n", 	"ERROR", 1, 1);// 02查询附着成功(驻网:<*,@> @为1或5表示附着成功) <+CEREG: 0,1\r\nOK>
 					sendCmd_4G("AT+CEREG?\r\n", 	"ERROR", 1, 1);// 02查询附着成功(驻网:<*,@> @为1或5表示附着成功) <+CEREG: 0,1\r\nOK>
 					//sendCmd_4G("AT+MIPCALL?\r\n", 	"ERROR", 1, 1);// 03查询PDP激活状态 <+MIPCALL: 1,1,"10.94.99.162"\r\nOK>
 					//sendCmd_4G("AT+MIPCALL?\r\n", 	"ERROR", 1, 1);// 03查询PDP激活状态 <+MIPCALL: 1,1,"10.94.99.162"\r\nOK>
 					//sendCmd_4G("AT+MQTTCFG=?\r\n",	"ERROR", 1, 1);// 04查询MQTT
 					//sendCmd_4G("AT+MQTTCFG=?\r\n",	"ERROR", 1, 1);// 04查询MQTT
-					printf("init_success");
+					printf("init_success\r\n");
 				}
 				}
 			}
 			}
 
 

+ 5 - 0
MDK-ARM/dtu.uvoptx

@@ -160,6 +160,11 @@
           <WinNumber>1</WinNumber>
           <WinNumber>1</WinNumber>
           <ItemText>menu</ItemText>
           <ItemText>menu</ItemText>
         </Ww>
         </Ww>
+        <Ww>
+          <count>2</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>enterInterface_time</ItemText>
+        </Ww>
       </WatchWindow1>
       </WatchWindow1>
       <MemoryWindow1>
       <MemoryWindow1>
         <Mm>
         <Mm>

File diff suppressed because it is too large
+ 3173 - 3155
Output/dtu.hex