| 
					
				 | 
			
			
				@@ -24,7 +24,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #include "sdkconfig.h"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #include "../../main/user_sleep.h"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #include "esp_sleep.h"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include "SPIFFS.h"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 QueueHandle_t lora_receiveQueue;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -656,7 +656,7 @@ uint8_t set_lora(uint8_t new_channel,uint8_t eflag) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     gpio_set_level(LORA_SET_PIN, 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return ret;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void reset_lora(void)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void reset_lora(uint8_t new_channel)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -682,19 +682,20 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           y_ringbuf_read_clear(lora_ringbuf, data, user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              printf("rsp len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     printf("lora_set_config_mode len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     printf("\n\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          lora_set_channel(LORA_CHANENL);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          lora_set_channel(new_channel);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           vTaskDelay(100/ portTICK_PERIOD_MS);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           user_size = y_ringbuf_get_used_size(lora_ringbuf);
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -702,6 +703,7 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           y_ringbuf_read_clear(lora_ringbuf, data, user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           if(data[1] == 0xee)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            printf("->err\n\n\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             lora_set_channel(LORA_CHANENL);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             vTaskDelay(100/ portTICK_PERIOD_MS);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             user_size = y_ringbuf_get_used_size(lora_ringbuf);
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -709,9 +711,10 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           if(user_size!=0 )
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                printf("rsp len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                printf("lora_set_channel len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              printf("\n\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -724,12 +727,13 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           y_ringbuf_read_clear(lora_ringbuf, data, user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                printf("rsp len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("lora_set_bps len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     printf("\n\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -741,12 +745,13 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           y_ringbuf_read_clear(lora_ringbuf, data, user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                printf("rsp len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("lora_set_device_id len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     printf("\n\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           lora_set_dst_device_id(0xFFFFFFFF);
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -757,13 +762,14 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           y_ringbuf_read_clear(lora_ringbuf, data, user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                printf("rsp len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("lora_set_dst_device_id len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     printf("\n\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           lora_get_rssi(0x07);
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -774,13 +780,14 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           y_ringbuf_read_clear(lora_ringbuf, data, user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                printf("rsp len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("lora_get_rssi len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //       printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     printf("\n\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -794,13 +801,13 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           y_ringbuf_read_clear(lora_ringbuf, data, user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                printf("rsp len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // if(user_size!=0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //   printf("lora_set_config_mode len = %d\r\n",user_size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //   for(int i = 0;i<user_size;i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //     printf("%02x",data[i]);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //   printf("\n\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -820,9 +827,9 @@ void reset_lora(void) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 static void tx_task(void *arg)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	//Cmd_t cmd;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	int index = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	unsigned char receivedMessage[30];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// //Cmd_t cmd;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// int index = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// unsigned char receivedMessage[30];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //发送lora初始化AT指令
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #if HPD_LORA_ENABLE
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -833,7 +840,7 @@ lora_sendData((unsigned char*)lora_cmd[lora.cmd_index].cmd,strlen((char *)lora_c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #if VJ_LORA_ENABLE
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #if 1
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  reset_lora();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  reset_lora(LORA_CHANENL);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //lora_sendData((unsigned char*)lora_cmd[lora.cmd_index].cmd,4);
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1992,7 +1999,7 @@ void lora_set_exit_config_mode() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void lora_set_channel(uint8_t channel)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //printf("%s\r\n",__FUNCTION__);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ESP_LOGW(LOG_TAG," ------>%s channel = %d\r\n",__FUNCTION__,channel);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #if 1
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    uint8_t lorabuf[4];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    lorabuf[0]=0x03;
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2472,8 +2479,16 @@ int  reson = is_wake_up_reson();  //返回唤醒的原因 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER)/*&& (reson != ESP_SLEEP_WAKEUP_EXT0)*/) //ota完后软件复位,重新配置lora
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     printf("lora cmd init start\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    extern Machine_info_t Machine_info;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(Machine_info.lora_new_channel == LORA_CHANENL)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      xTaskCreate(tx_task, "uart_tx_task", 1024*3, NULL, configMAX_PRIORITIES-1, &lora_uart_tx_handle);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ESP_LOGE(LOG_TAG,"不设置LORA_CHANENL");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    xTaskCreate(tx_task, "uart_tx_task", 1024*2, NULL, configMAX_PRIORITIES-1, &lora_uart_tx_handle);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   lora.lora_mode = Lora_UART_Mode;   //复位直接进入透传模式
 
			 |