mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-04-24 19:40:33 +00:00
Enable config page on runtime with populated form
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -27,6 +27,7 @@
|
|||||||
class HanConfigAp {
|
class HanConfigAp {
|
||||||
public:
|
public:
|
||||||
void setup(int accessPointButtonPin, Stream* debugger);
|
void setup(int accessPointButtonPin, Stream* debugger);
|
||||||
|
void enableWeb();
|
||||||
bool loop();
|
bool loop();
|
||||||
bool hasConfig();
|
bool hasConfig();
|
||||||
configuration config;
|
configuration config;
|
||||||
@@ -46,6 +47,7 @@ private:
|
|||||||
|
|
||||||
// Web server
|
// Web server
|
||||||
static void handleRoot();
|
static void handleRoot();
|
||||||
|
static void handleStyle();
|
||||||
static void handleSave();
|
static void handleSave();
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
static ESP8266WebServer server;
|
static ESP8266WebServer server;
|
||||||
|
|||||||
72
lib/HanConfigAp/src/config_html.h
Normal file
72
lib/HanConfigAp/src/config_html.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
const char CONFIG_HTML[] PROGMEM = R"=="==(
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||||
|
|
||||||
|
<title>AMS2MQTT - configuration</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form method='post' action='/save'>
|
||||||
|
<div class="wrapper">
|
||||||
|
<div class="inner-wrapper">
|
||||||
|
<div>
|
||||||
|
<h2>WiFi</h2>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type='text' name='ssid' value="${config.ssid}" placeholder="SSID">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type='password' name='ssidPassword' value="${config.ssidPassword}" placeholder="Password">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inner-wrapper">
|
||||||
|
<div>
|
||||||
|
<h2>Meter Type</h2>
|
||||||
|
</div>
|
||||||
|
<div class="select-style">
|
||||||
|
<select name="meterType">
|
||||||
|
<option value="0" ${config.meterType0} disabled class="disabled-option"> SELECT TYPE </option>
|
||||||
|
<option value="1" ${config.meterType1}>Kaifa</option>
|
||||||
|
<option value="2" ${config.meterType2}>Aidon</option>
|
||||||
|
<option value="3" ${config.meterType3}>Kamstrup</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inner-wrapper">
|
||||||
|
<div>
|
||||||
|
<h2>MQTT</h2>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Server & port:</label>
|
||||||
|
<input type='text' name='mqtt' value="${config.mqtt}" placeholder="server">
|
||||||
|
<input type='number' name='mqttPort' value="${config.mqttPort}" placeholder="port">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Client ID:</label>
|
||||||
|
<input type='text' name='mqttClientID' value="${config.mqttClientID}" placeholder="client id">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Publish topic: </label>
|
||||||
|
<input type='text' name='mqttPublishTopic' value="${config.mqttPublishTopic}" placeholder="topic">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Username:</label>
|
||||||
|
<input type='text' name='mqttUser' value="${config.mqttUser}" placeholder="Blank for insecure">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Password:</label>
|
||||||
|
<input type='password' name='mqttPass' value="${config.mqttPass}" placeholder="Blank for insecure">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input class="submit-button" type='submit' value='save'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<body>
|
||||||
|
</html>
|
||||||
|
)=="==";
|
||||||
135
lib/HanConfigAp/src/style_css.h
Normal file
135
lib/HanConfigAp/src/style_css.h
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
const char STYLE_CSS[] PROGMEM = R"=="==(
|
||||||
|
body,div,input {
|
||||||
|
font-family: "Roboto", Arial, Lucida Grande;
|
||||||
|
}
|
||||||
|
.wrapper {
|
||||||
|
width: 500px;
|
||||||
|
position: absolute;
|
||||||
|
padding: 30px;
|
||||||
|
background-color: #FFF;
|
||||||
|
border-radius: 1px;
|
||||||
|
color: #333;
|
||||||
|
border-color: rgba(0, 0, 0, 0.03);
|
||||||
|
box-shadow: 0 2px 2px rgba(0, 0, 0, .24), 0 0 2px rgba(0, 0, 0, .12);
|
||||||
|
margin-left: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
font-family: "Roboto", "Helvetica Neue", sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 16px;
|
||||||
|
width: 100px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
font-family: "Roboto", "Helvetica Neue", sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 16px;
|
||||||
|
bottom: 30px;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid #d4d4d4;
|
||||||
|
padding: 10px;
|
||||||
|
background: transparent;
|
||||||
|
transition: all .25s ease;
|
||||||
|
}
|
||||||
|
input[type=number] {
|
||||||
|
width: 70px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-bottom: 1px solid #3f51b5;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
text-align: left;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
letter-spacing: 3px;
|
||||||
|
line-height: 28px;
|
||||||
|
}
|
||||||
|
.submit-button {
|
||||||
|
position: absolute;
|
||||||
|
text-align: right;
|
||||||
|
border-radius: 20px;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
background-color: #3f51b5;
|
||||||
|
color: #FFF;
|
||||||
|
padding: 12px 25px;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: bold;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
right: 0px;
|
||||||
|
bottom: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all .25s ease;
|
||||||
|
box-shadow: 0 2px 2px rgba(0, 0, 0, .24), 0 0 2px rgba(0, 0, 0, .12);
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
.select-style {
|
||||||
|
border-top: 10px solid white;
|
||||||
|
border-bottom: 1px solid #d4d4d4;
|
||||||
|
color: #ffffff;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
font-family: Roboto, "Helvetica Neue", sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
height: 16px;
|
||||||
|
line-height: 14px;
|
||||||
|
min-width: 200px;
|
||||||
|
padding-bottom: 7px;
|
||||||
|
padding-left: 0px;
|
||||||
|
padding-right: 0px;
|
||||||
|
position: relative;
|
||||||
|
text-align: left;
|
||||||
|
width: 80%;
|
||||||
|
-webkit-box-direction: normal;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #ffffff url("data:image/png;base64,R0lGODlhDwAUAIABAAAAAP///yH5BAEAAAEALAAAAAAPABQAAAIXjI+py+0Po5wH2HsXzmw//lHiSJZmUAAAOw==") no-repeat 98% 50%;
|
||||||
|
}
|
||||||
|
.disabled-option {
|
||||||
|
color: #d4d4d4;
|
||||||
|
}
|
||||||
|
.select-style select {
|
||||||
|
padding: 5px 8px;
|
||||||
|
width: 100%;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
background: transparent;
|
||||||
|
background-image: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
}
|
||||||
|
.select-style select:focus {
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 1000px) {
|
||||||
|
.wrapper {
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 300px) {
|
||||||
|
.wrapper {
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 600px) {
|
||||||
|
.wrapper {
|
||||||
|
width: 80%;
|
||||||
|
margin-left: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
.submit-button {
|
||||||
|
bottom: 0px;
|
||||||
|
width: 70px;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)=="==";
|
||||||
@@ -59,10 +59,11 @@ HardwareSerial* debugger = NULL;
|
|||||||
HanReader hanReader;
|
HanReader hanReader;
|
||||||
|
|
||||||
// the setup function runs once when you press reset or power the board
|
// the setup function runs once when you press reset or power the board
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
// Uncomment to debug over the same port as used for HAN communication
|
#if DEBUG_MODE
|
||||||
//debugger = &Serial;
|
debugger = &Serial;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (debugger) {
|
if (debugger) {
|
||||||
// Setup serial port for debugging
|
// Setup serial port for debugging
|
||||||
@@ -100,6 +101,8 @@ void setup()
|
|||||||
// Compensate for the known Kaifa bug
|
// Compensate for the known Kaifa bug
|
||||||
hanReader.compensateFor09HeaderBug = (ap.config.meterType == 1);
|
hanReader.compensateFor09HeaderBug = (ap.config.meterType == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ap.enableWeb();
|
||||||
}
|
}
|
||||||
|
|
||||||
// the loop function runs over and over again until power down or reset
|
// the loop function runs over and over again until power down or reset
|
||||||
|
|||||||
Reference in New Issue
Block a user