firmware wip - add firmware update from web ui
This commit is contained in:
parent
4ad16c97ce
commit
bce55a2632
7 changed files with 76 additions and 93 deletions
|
@ -20,6 +20,8 @@
|
|||
#include <WiFiUdp.h>
|
||||
// https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer
|
||||
#include <ESP8266WebServer.h>
|
||||
// OTA update
|
||||
#include <ESP8266HTTPUpdateServer.h>
|
||||
// https://github.com/adafruit/Adafruit-GFX-Library
|
||||
#include <Adafruit_GFX.h>
|
||||
// https://github.com/adafruit/Adafruit_SSD1306
|
||||
|
@ -46,12 +48,12 @@
|
|||
#include "CanGrow_Logo.h"
|
||||
#include "CanGrow_Sensors.h"
|
||||
|
||||
#include "CanGrow_Version.h"
|
||||
#include "CanGrow_HTML.h"
|
||||
#include "CanGrow_SysFunctions.h"
|
||||
#include "CanGrow_WebFunctions.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Setup
|
||||
*
|
||||
|
@ -89,7 +91,11 @@ void setup() {
|
|||
// Write a line before doing serious output, because before there is some garbage in serial
|
||||
// whats get the cursor somewhere over the place
|
||||
Serial.println("420");
|
||||
Serial.println(".:: CanGrow Start ::.");
|
||||
Serial.print(".:: CanGrow v");
|
||||
Serial.print(CanGrowVer);
|
||||
Serial.print(" build ");
|
||||
Serial.print(CanGrowBuild);
|
||||
Serial.println(" starting ::.");
|
||||
|
||||
Serial.println(":: initialise I2C ::");
|
||||
// initialise Wire for I2C
|
||||
|
@ -232,6 +238,9 @@ void loop() {
|
|||
} else {
|
||||
controlLED();
|
||||
}
|
||||
|
||||
|
||||
|
||||
displayScreens();
|
||||
|
||||
// current time gets previous time for new interval
|
||||
|
|
|
@ -146,7 +146,7 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
|
|||
border-radius: 3px;
|
||||
}
|
||||
|
||||
@media only screen and (min-width: 1280px) {
|
||||
@media only screen and (min-width: 1856px) {
|
||||
.center, .nav {
|
||||
width: 60%; min-width: 420px;
|
||||
}
|
||||
|
@ -470,3 +470,14 @@ const char HTMLgauge[] PROGMEM = R"EOF(
|
|||
</script>
|
||||
|
||||
)EOF";
|
||||
|
||||
|
||||
const char HTMLupdate[] PROGMEM = R"EOF(
|
||||
<p>You find the latest CanGrow firmware version on the <a href='https://git.la10cy.net/DeltaLima/CanGrow/releases' target='_blank'>release page</a> of the git repository.</p>
|
||||
<form method='POST' action='/system/applyUpdate' enctype='multipart/form-data'>
|
||||
<b>Select .bin file:</b><br>
|
||||
<input type='file' accept='.bin,.bin.gz' name='firmware'>
|
||||
<input type='submit' value='Update Firmware' onclick="document.getElementById('divUploading').style.display = '';">
|
||||
</form>
|
||||
<div id='divUploading' style='display: none;' class='warnmsg'>Uploading, please wait...<div>
|
||||
)EOF";
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* Constants
|
||||
*
|
||||
*/
|
||||
const char* CanGrowVer = "0.1";
|
||||
const char* APssid = "CanGrow-unconfigured";
|
||||
/*
|
||||
* TODO - does not work atm. idk why.
|
||||
|
@ -144,6 +143,7 @@ NTPClient timeClient(ntpUDP);
|
|||
*/
|
||||
|
||||
ESP8266WebServer webserver(80);
|
||||
ESP8266HTTPUpdateServer webUpdater;
|
||||
|
||||
/* I2C Stuff
|
||||
*
|
||||
|
|
5
Arduino/CanGrow/CanGrow_Version.h
Normal file
5
Arduino/CanGrow/CanGrow_Version.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
/* CanGrow_Version.h gets generated from cangrow.sh */
|
||||
|
||||
const char* CanGrowVer = "0.1-dev";
|
||||
const char* CanGrowBuild = "4ad16c9";
|
||||
|
|
@ -235,6 +235,22 @@ void SysMaintenance() {
|
|||
webserver.send(200, "text/html", body);
|
||||
}
|
||||
|
||||
void SysUpdate() {
|
||||
String body = returnHTMLheader();
|
||||
|
||||
body += "<h2>🔄 Firmware update</h2>";
|
||||
|
||||
body += "<b>Version:</b> ";
|
||||
body += CanGrowVer;
|
||||
body += "<br><b>Build:</b> ";
|
||||
body += CanGrowBuild;
|
||||
|
||||
body += FPSTR(HTMLupdate);
|
||||
|
||||
body += FPSTR(HTMLfooter);
|
||||
webserver.send(200, "text/html", body);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* DOES NOT WORK WHEN CONNECTED TO EXISTING WIFI
|
||||
|
@ -426,7 +442,7 @@ void WEBgrowSettings() {
|
|||
|
||||
|
||||
|
||||
body += "Grow name: <input type='text' name='GrowName' maxlength='32' value='";
|
||||
body += "Grow name: <input type='text' name='GrowName' maxlength='31' value='";
|
||||
body += GrowName;
|
||||
body+= "' required><br>\n";
|
||||
|
||||
|
@ -487,7 +503,7 @@ void WEBgrowSettings() {
|
|||
body += "'/> %<br>\n";
|
||||
}
|
||||
|
||||
body += "<input type='submit' value='Save'>\n";
|
||||
body += "<input type='submit' value='💾 Save settings'>\n";
|
||||
body += "</form>\n";
|
||||
body += FPSTR(JSconvertDateToEpoch);
|
||||
body += FPSTR(HTMLfooter);
|
||||
|
@ -593,8 +609,9 @@ void WEBsystemSettings() {
|
|||
body += "' ><br>\n";
|
||||
|
||||
|
||||
body += "<input type='submit' value='Save'>\n";
|
||||
body += "</form>\n";
|
||||
body += "<input type='submit' value='💾 Save settings'>\n";
|
||||
body += "</form><br><a class='button' href='/system/update'>🔄 Firmware update</a>\n";
|
||||
|
||||
|
||||
body += FPSTR(HTMLfooter);
|
||||
|
||||
|
@ -659,7 +676,7 @@ void WEBwifiSettings() {
|
|||
body += "Subnet mask: <input type='text' name='WIFInetmask'><br>\n";
|
||||
body += "Gateway: <input type='text' name='WIFIgateway'><br>\n";
|
||||
body += "DNS: <input type='text' name='WIFIdns'><br>\n";
|
||||
body += "<input type='submit' value='Save'>\n";
|
||||
body += "<input type='submit' value='💾 Save settings'>\n";
|
||||
body += "</form>\n";
|
||||
body += FPSTR(HTMLfooter);
|
||||
|
||||
|
@ -1098,6 +1115,11 @@ void WebHandler() {
|
|||
webserver.on("/system/wipe", HTTP_GET, SysWipe);
|
||||
// Maintenance mode
|
||||
webserver.on("/system/maintenance", HTTP_GET, SysMaintenance);
|
||||
// system update with binary
|
||||
// update form
|
||||
webserver.on("/system/update", HTTP_GET, SysUpdate);
|
||||
// update itself
|
||||
webUpdater.setup(&webserver, "/system/applyUpdate");
|
||||
// does not work atm TODO
|
||||
//webserver.on("/logout", [](){ webserver.send(401, "text/html", "logged out!"); });
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
TTY="/dev/ttyUSB0"
|
||||
IP="192.168.30.212"
|
||||
VER="0.1-dev"
|
||||
|
||||
function help() {
|
||||
echo "$0 [build|upload|webupload|monitor]"
|
||||
|
@ -15,7 +16,12 @@ case $1 in
|
|||
b|build)
|
||||
echo "building firmware binary into $(pwd)/build/"
|
||||
test -d build || mkdir build
|
||||
~/.local/bin/arduino-cli --no-color compile -b esp8266:esp8266:d1_mini_clone "Arduino/CanGrow/CanGrow.ino" --output-dir build/
|
||||
echo "/* CanGrow_Version.h gets generated from cangrow.sh */
|
||||
|
||||
const char* CanGrowVer = \"${VER}\";
|
||||
const char* CanGrowBuild = \"$(git rev-parse --short HEAD)\";
|
||||
" > Arduino/CanGrow/CanGrow_Version.h
|
||||
~/.local/bin/arduino-cli --no-color compile -b esp8266:esp8266:d1_mini_clone "Arduino/CanGrow/CanGrow.ino" --output-dir build/ || exit 1
|
||||
;;
|
||||
u|upload)
|
||||
echo "uploading to $TTY"
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>CanGrow - Ruderalis Indica</title>
|
||||
<link rel='stylesheet' type='text/css' href='gauge.css'>
|
||||
<title>CanGrow - Amnesia Haze</title>
|
||||
|
||||
<link rel='icon' href='data:;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAABcElEQVQ4y42TzU/bQBDFf7Nx1qGuAYVgQSuo2khBggPhyIH//9AiJAQ9tEeLqCKiUD6sxF52OMSEBCdW57aa9968fTsr3V5XWVLPO6sANNL7ZRAMNeU6Ea4T1UEI6pr55kcAwhpMrYOpk2/r/yEQmKWkIonf+TZVgex4Fw0bIEtIAALF3gbZ8U5VwKa3PJ18JT9IpiLvyflBwuhLG5veVUM0/0aoCONPa2hQjWZ8uEVeupJnXSBwO8YOH8iTeAKc2Q4Xt2C1VZL93F7MjbK/bxDnp5Zn7b+So+9pdQ+K/Q5qJlrRj5Ts6DM+rK7Ih7Mr3HaM7jYQVZqXQ6Tb6yqBYdTfomhHiFfUyMI3f+01/z7RHNzTGDyWGThP63SA2d8EEfIkrgQpzmOvH0AV+3M4zegNpUwagAYG8Yp4BS0nl4Kz5Mpf0JXJMby6w/66Aa+M+9uE53/Iexsggq4ESOYWC0jmsBfX8xdXhcJjL4cLc3kBl8uJGQ/CrpAAAAAASUVORK5CYII='>
|
||||
<style>
|
||||
body {
|
||||
|
@ -139,93 +139,23 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<ul class='nav'><li><a href='/'>🌱 Ruderalis Indica</a></li>
|
||||
<ul class='nav'><li><a href='/'>🌱 Amnesia Haze</a></li>
|
||||
<li><a href='/growSettings' >🔆 Grow settings</a></li>
|
||||
<li><a href='/systemSettings' >⚙ System settings</a></li>
|
||||
<li><a href='/wifiSettings' >📡 WiFi settings</a></li>
|
||||
<li><a href='/help' >❓ Help</a></li>
|
||||
<li><span class='MenuTime'>01:53:31</span></li>
|
||||
<li><span class='MenuTime'>09:48:27</span></li>
|
||||
<li><a href='https://git.la10cy.net/DeltaLima/CanGrow' target='_blank'>CanGrow v0.1</a></li>
|
||||
</ul><div class='center'><h2>🌱 Ruderalis Indica</h2>
|
||||
</ul><div class='center'><h2>🔄 Firmware update</h2>Version: 0.1<br>Build: 4ad16c9
|
||||
<p>You find the latest CanGrow Firmware Version on the projects <a href='https://git.la10cy.net/DeltaLima/CanGrow/releases' target='_blank'>release page</a></p>
|
||||
<form method='GET' action='' enctype='multipart/form-data'>
|
||||
Firmware .bin file:<br>
|
||||
<input type='file' accept='.bin,.bin.gz' name='firmware'>
|
||||
|
||||
<div class='gaugeWrapper'>
|
||||
<div class='gauge gauge--liveupdate spacer' id='gaugeTemperature' style='float:left; margin-right: 10px;'>
|
||||
<span class='gaugeLabel'>Temperature</span>
|
||||
<div class='gauge__container'>
|
||||
<div class='gauge__background'></div>
|
||||
<div class='gauge__center'></div>
|
||||
<div class='gauge__data'></div>
|
||||
<div class='gauge__needle'></div>
|
||||
</div>
|
||||
<div class='gauge__labels mdl-typography__headline'>
|
||||
<span class='gauge__label--low'></span>
|
||||
<span class='gauge__label--spacer'></span></span>
|
||||
<span class='gauge__label--high'></span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<button onclick="document.getElementById('divUploading').style.display = ''; window.alert('click');">asd</button>
|
||||
<div id='divUploading' style='display: none;' class='warnmsg'>Uploading, please wait...<div>
|
||||
|
||||
<div class='gauge gauge--liveupdate spacer' id='gaugeHumidity' style='float:left; margin-right: 10px;'>
|
||||
<span class='gaugeLabel'>Humidity</span>
|
||||
<div class='gauge__container'>
|
||||
<div class='gauge__background'></div>
|
||||
<div class='gauge__center'></div>
|
||||
<div class='gauge__data'></div>
|
||||
<div class='gauge__needle'></div>
|
||||
</div>
|
||||
<div class='gauge__labels mdl-typography__headline'>
|
||||
<span class='gauge__label--low'></span>
|
||||
<span class='gauge__label--spacer'></span>
|
||||
<span class='gauge__label--high'></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='gauge gauge--liveupdate' id='gaugeSoilmoisture' style='float:left;'>
|
||||
<span class='gaugeLabel'>Soilmoisture</span>
|
||||
<div class='gauge__container'>
|
||||
<div class='gauge__background'></div>
|
||||
<div class='gauge__center'></div>
|
||||
<div class='gauge__data'></div>
|
||||
<div class='gauge__needle'></div>
|
||||
</div>
|
||||
<div class='gauge__labels mdl-typography__headline'>
|
||||
<span class='gauge__label--low'></span>
|
||||
<span class='gauge__label--spacer'></span>
|
||||
<span class='gauge__label--high'></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script src='gauge.js'></script>
|
||||
<script>
|
||||
var gaugeTemperature = new Gauge(document.getElementById('gaugeTemperature'));
|
||||
var gaugeHumidity = new Gauge(document.getElementById('gaugeHumidity'));
|
||||
var gaugeSoilmoisture = new Gauge(document.getElementById('gaugeSoilmoisture'));
|
||||
</script>
|
||||
|
||||
<script>gaugeTemperature.value('21.27', 42, ' °C'); gaugeHumidity.value('61.83'); gaugeSoilmoisture.value('98'); </script><br>
|
||||
<img class='centered' src='http://192.168.30.6/capture' alt='Image capture from ESP32CAM at 192.168.30.6'>
|
||||
<br>
|
||||
Grow started: 2024-04-12<br>
|
||||
Day of Grow: 41<br>
|
||||
Pump water level: <span style='color: red;'>Critical</span><br>
|
||||
Growlight brightness: 100 %<br>
|
||||
<form method='post' action='/switch'>
|
||||
MOSFET<select id='output' name='output' >
|
||||
<option disabled value='' selected hidden>---</option>
|
||||
<option value='1'>LED</option>
|
||||
<option value='2'>FAN</option>
|
||||
<option value='3'>PUMP</option>
|
||||
</select><br>On/Off: <select id='state' name='state' >
|
||||
<option disabled value='' selected hidden>---</option>
|
||||
<option value='1'>On</option>
|
||||
<option value='0'>Off</option>
|
||||
</select><br>
|
||||
Intensity: <input type='range' id='OutputPWM' name='OutputPWM' min='1' max='255' value='255'/><br>
|
||||
<input type='submit' value='Save'>
|
||||
</form><br>
|
||||
<a class='button' href='/system/maintenance'>Maintenance Mode</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue