maintenance mode (1st full version)
This commit is contained in:
		
							parent
							
								
									e864977b0d
								
							
						
					
					
						commit
						88774d13e9
					
				| @ -148,6 +148,6 @@ extern SemaphoreHandle_t I2Caccess; | |||||||
| extern TaskHandle_t irqHandlerTask, ClockTask, macProcessTask; | extern TaskHandle_t irqHandlerTask, ClockTask, macProcessTask; | ||||||
| extern TimerHandle_t WifiChanTimer; | extern TimerHandle_t WifiChanTimer; | ||||||
| extern Timezone myTZ; | extern Timezone myTZ; | ||||||
| extern RTC_DATA_ATTR runmode_t RTC_runmode; | extern RTC_NOINIT_ATTR runmode_t RTC_runmode; | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
							
								
								
									
										55
									
								
								src/boot.cpp
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								src/boot.cpp
									
									
									
									
									
								
							| @ -34,12 +34,25 @@ void start_boot_menu(void) { | |||||||
| 
 | 
 | ||||||
|   WebServer server(80); |   WebServer server(80); | ||||||
| 
 | 
 | ||||||
|   /*
 |   const char *loginMenu = | ||||||
|     const char *serverIndex = |       "<form name='loginForm'>" | ||||||
|         "<form method='POST' action='/update' " |       "<table width='20%' bgcolor='A09F9F' align='center'>" | ||||||
|         "enctype='multipart/form-data'><input type='file' name='update'><input " |       "<tr>" | ||||||
|         "type='submit' value='Update'></form>"; |       "<td colspan=2>" | ||||||
|   */ |       "<center><font size=4><b>Maintenance Menu</b></font></center>" | ||||||
|  |       "<br>" | ||||||
|  |       "</td>" | ||||||
|  |       "<br>" | ||||||
|  |       "<br>" | ||||||
|  |       "</tr>" | ||||||
|  |       "<tr>" | ||||||
|  |       "<td><input type='submit' onclick='start(this.form)' value='Start'></td>" | ||||||
|  |       "</tr>" | ||||||
|  |       "</table>" | ||||||
|  |       "</form>" | ||||||
|  |       "<script>" | ||||||
|  |       "function start(form) {window.open('/serverIndex')}" | ||||||
|  |       "</script>"; | ||||||
| 
 | 
 | ||||||
|   const char *serverIndex = |   const char *serverIndex = | ||||||
|       "<script " |       "<script " | ||||||
| @ -82,7 +95,7 @@ void start_boot_menu(void) { | |||||||
|       "</script>"; |       "</script>"; | ||||||
| 
 | 
 | ||||||
|   // Connect to WiFi network
 |   // Connect to WiFi network
 | ||||||
|   // WiFi.mode(WIFI_STA);
 |   WiFi.mode(WIFI_STA); | ||||||
|   WiFi.begin(ssid, password); |   WiFi.begin(ssid, password); | ||||||
| 
 | 
 | ||||||
|   // Wait for connection
 |   // Wait for connection
 | ||||||
| @ -92,7 +105,13 @@ void start_boot_menu(void) { | |||||||
| 
 | 
 | ||||||
|   MDNS.begin(host); |   MDNS.begin(host); | ||||||
| 
 | 
 | ||||||
|   server.on("/", HTTP_GET, [&server, &serverIndex]() { |   server.on("/", HTTP_GET, [&server, &loginMenu]() { | ||||||
|  |     server.sendHeader("Connection", "close"); | ||||||
|  |     server.send(200, "text/html", loginMenu); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   server.on("/serverIndex", HTTP_GET, [&server, &serverIndex, &timer]() { | ||||||
|  |     timerAlarmWrite(timer, BOOTTIMEOUT * 1000000, false); | ||||||
|     server.sendHeader("Connection", "close"); |     server.sendHeader("Connection", "close"); | ||||||
|     server.send(200, "text/html", serverIndex); |     server.send(200, "text/html", serverIndex); | ||||||
|   }); |   }); | ||||||
| @ -107,10 +126,17 @@ void start_boot_menu(void) { | |||||||
|       [&server, &timer]() { |       [&server, &timer]() { | ||||||
|         HTTPUpload &upload = server.upload(); |         HTTPUpload &upload = server.upload(); | ||||||
|         if (upload.status == UPLOAD_FILE_START) { |         if (upload.status == UPLOAD_FILE_START) { | ||||||
|           timerAlarmWrite(timer, BOOTTIMEOUT * 1000000, false); |  | ||||||
|           ESP_LOGI(TAG, "Update: %s\n", upload.filename.c_str()); |           ESP_LOGI(TAG, "Update: %s\n", upload.filename.c_str()); | ||||||
|           if (!Update.begin( | #if (HAS_LED != NOT_A_PIN) | ||||||
|                   UPDATE_SIZE_UNKNOWN)) { // start with max available size
 | #ifndef LED_ACTIVE_LOW | ||||||
|  |           if (!Update.begin(UPDATE_SIZE_UNKNOWN, U_FLASH, HAS_LED, HIGH)) { | ||||||
|  | #else | ||||||
|  |           if (!Update.begin(UPDATE_SIZE_UNKNOWN, U_FLASH, HAS_LED, LOW)) { | ||||||
|  | #endif | ||||||
|  | #else | ||||||
|  |           if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|             ESP_LOGE(TAG, "Error: %s", Update.errorString()); |             ESP_LOGE(TAG, "Error: %s", Update.errorString()); | ||||||
|           } |           } | ||||||
|         } else if (upload.status == UPLOAD_FILE_WRITE) { |         } else if (upload.status == UPLOAD_FILE_WRITE) { | ||||||
| @ -134,12 +160,13 @@ void start_boot_menu(void) { | |||||||
| 
 | 
 | ||||||
|   server.begin(); |   server.begin(); | ||||||
|   MDNS.addService("http", "tcp", 80); |   MDNS.addService("http", "tcp", 80); | ||||||
|   ESP_LOGI(TAG, "WiFi connected to '%s', open http://%s in your browser", |   ESP_LOGI(TAG, | ||||||
|            WiFi.SSID().c_str(), WiFi.localIP().toString().c_str()); |            "WiFi connected to '%s', open http://%s.local or http://%s in your " | ||||||
|  |            "browser", | ||||||
|  |            WiFi.SSID().c_str(), clientId, WiFi.localIP().toString().c_str()); | ||||||
| 
 | 
 | ||||||
|   while (1) { |   while (1) { | ||||||
|     server.handleClient(); |     server.handleClient(); | ||||||
|     timerWrite(timer, 0); // reset timer (feed watchdog)
 |  | ||||||
|     delay(1); |     delay(1); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -156,9 +156,11 @@ void dp_init(bool verbose) { | |||||||
| 
 | 
 | ||||||
|       // give user some time to read or take picture
 |       // give user some time to read or take picture
 | ||||||
|       dp_dump(displaybuf); |       dp_dump(displaybuf); | ||||||
|  | #if !(BOOTMENU) | ||||||
|       delay(8000); |       delay(8000); | ||||||
|  | #endif | ||||||
|       dp_contrast(DISPLAYCONTRAST); |       dp_contrast(DISPLAYCONTRAST); | ||||||
|       dp_clear(); |       //dp_clear();
 | ||||||
| #endif // HAS_LORA
 | #endif // HAS_LORA
 | ||||||
| 
 | 
 | ||||||
|     } // verbose
 |     } // verbose
 | ||||||
|  | |||||||
| @ -8,9 +8,9 @@ | |||||||
| 
 | 
 | ||||||
| // Device options | // Device options | ||||||
| #define VERBOSE                         1       // set to 0 to silence the device, 1 enables additional debug output | #define VERBOSE                         1       // set to 0 to silence the device, 1 enables additional debug output | ||||||
| #define BOOTMENU                        1       // 0 = no bootmenu, 1 = device brings up boot menu before starting application | #define BOOTMENU                        0       // 0 = no bootmenu, 1 = device brings up boot menu before starting application | ||||||
| #define BOOTDELAY                       10      // time [seconds] while devices waits in boot menue for input | #define BOOTDELAY                       30      // time [seconds] while devices waits in boot menue for input | ||||||
| #define BOOTTIMEOUT                     300     //  time [seconds] while devices waits to finish upload a firmware file | #define BOOTTIMEOUT                     300     // time [seconds] while devices waits to finish upload a firmware file | ||||||
| 
 | 
 | ||||||
| // Payload send cycle and encoding | // Payload send cycle and encoding | ||||||
| #define SENDCYCLE                       30      // payload send cycle [seconds/2], 0 .. 255 | #define SENDCYCLE                       30      // payload send cycle [seconds/2], 0 .. 255 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user