Added /reboot URI

parent 388ad1ac
......@@ -112,7 +112,7 @@ static int selected_boot_partition(const bootloader_state_t *bs)
// Check for reset to the factory firmware or for launch OTA[x] firmware.
// Customer implementation.
if ( REG_GET_BIT(GPIO_IN_REG, BIT26) == BIT26) {
ESP_LOGE(TAG, "GPIO 26 PRESSED: Booting on FACTORY_INDEX\n");
ESP_LOGW(TAG, "GPIO 26 PRESSED: Booting on FACTORY_INDEX\n");
boot_index = FACTORY_INDEX;
}
#endif
......
......@@ -52,7 +52,54 @@ unsigned char index_html[] = {
0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74,
0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x75, 0x70, 0x6c,
0x6f, 0x61, 0x64, 0x22, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x66, 0x6f,
0x72, 0x6d, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64,
0x79, 0x3e, 0x0a, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a, 0x0a
0x72, 0x6d, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x62,
0x72, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x64, 0x69,
0x76, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x2f, 0x72,
0x65, 0x62, 0x6f, 0x6f, 0x74, 0x3e, 0x52, 0x45, 0x42, 0x4f, 0x4f, 0x54,
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x20,
0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0a, 0x3c, 0x2f,
0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a, 0x0a
};
unsigned int index_html_len = 660;
unsigned int index_html_len = 715;
unsigned char reboot_html[] = {
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x68, 0x74,
0x6d, 0x6c, 0x3e, 0x0a, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a, 0x20,
0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x20, 0x6e, 0x61, 0x6d,
0x65, 0x3d, 0x22, 0x76, 0x69, 0x65, 0x77, 0x70, 0x6f, 0x72, 0x74, 0x22,
0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x3d, 0x22, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x77,
0x69, 0x64, 0x74, 0x68, 0x2c, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61,
0x6c, 0x2d, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x3d, 0x31, 0x22, 0x3e, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x20,
0x68, 0x74, 0x74, 0x70, 0x2d, 0x65, 0x71, 0x75, 0x69, 0x76, 0x3d, 0x22,
0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x22, 0x20, 0x63, 0x6f, 0x6e,
0x74, 0x65, 0x6e, 0x74, 0x3d, 0x22, 0x31, 0x30, 0x3b, 0x75, 0x72, 0x6c,
0x3d, 0x2f, 0x22, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c,
0x73, 0x74, 0x79, 0x6c, 0x65, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22,
0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x74, 0x6d, 0x6c,
0x2c, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x2c, 0x20, 0x69, 0x66, 0x72, 0x61,
0x6d, 0x65, 0x20, 0x7b, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a,
0x20, 0x30, 0x3b, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a,
0x20, 0x30, 0x3b, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x20,
0x31, 0x30, 0x30, 0x25, 0x3b, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x20,
0x7b, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3a, 0x20, 0x62,
0x6c, 0x6f, 0x63, 0x6b, 0x3b, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a,
0x20, 0x31, 0x30, 0x30, 0x25, 0x3b, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65,
0x72, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x65, 0x3b, 0x20, 0x7d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65,
0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74,
0x6c, 0x65, 0x3e, 0x4e, 0x65, 0x78, 0x62, 0x6f, 0x6f, 0x74, 0x20, 0x4e,
0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x42, 0x6f, 0x6f, 0x74, 0x6c,
0x6f, 0x61, 0x64, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x45, 0x53,
0x50, 0x33, 0x32, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a,
0x20, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x0a, 0x20,
0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x52, 0x65, 0x62, 0x6f, 0x6f,
0x74, 0x69, 0x6e, 0x67, 0x2e, 0x2e, 0x2e, 0x3c, 0x2f, 0x68, 0x31, 0x3e,
0x0a, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0a,
0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a, 0x0a
};
unsigned int reboot_html_len = 465;
......@@ -175,6 +175,12 @@ static void mg_ev_handler(struct mg_connection *nc, int ev, void *p) {
mg_send_head(nc, 200, index_html_len, "Content-Type: text/html");
mg_send(nc, index_html, index_html_len);
}
} else if(strcmp(uri, "/reboot") == 0) {
mg_send_head(nc, 200, reboot_html_len, "Content-Type: text/html");
mg_send(nc, reboot_html, reboot_html_len);
ESP_LOGI(TAG,"Rebooting... ");
esp_restart();
} else {
mg_send_head(nc, 404, 0, "Content-Type: text/plain");
}
......
......@@ -15,6 +15,8 @@
<input type="file" name="fw">
<input type="submit" value="upload">
</form>
<br>
<div><a href=/reboot>REBOOT</a></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="refresh" content="10;url=/">
<style type="text/css">
html, body, iframe { margin: 0; padding: 0; height: 100%; }
iframe { display: block; width: 100%; border: none; }
</style>
<title>Nexboot Network Bootloader for ESP32</title>
</head>
<body>
<h1>Rebooting...</h1>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment