Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
e7a53dfc
Commit
e7a53dfc
authored
3 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Redistributing HTML parts
parent
f25fcc79
Pipeline
#5879
passed with stage
in 2 minutes and 29 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ampel-firmware/web_server.cpp
+50
-48
ampel-firmware/web_server.cpp
with
50 additions
and
48 deletions
+50
-48
ampel-firmware/web_server.cpp
+
50
-
48
View file @
e7a53dfc
...
...
@@ -52,10 +52,10 @@ namespace web_server {
"<div class='pure-u-1'><ul class='pure-menu pure-menu-horizontal pure-menu-list'>"
"<li class='pure-menu-item'><a href='/config' class='pure-menu-link'>Config</a></li>"
"<li class='pure-menu-item'><a href='#table' class='pure-menu-link'>Info</a></li>"
"<li class='pure-menu-item'><a href='#graph' class='pure-menu-link'>Graph</a></li>"
);
"<li class='pure-menu-item'><a href='#graph' class='pure-menu-link'>Graph</a></li>"
"<li class='pure-menu-item'><a href='#log' class='pure-menu-link'>Log</a></li>"
);
body1_template
=
PSTR
(
"<li class='pure-menu-item'><a href='#log' class='pure-menu-link'>Log</a></li>"
"<li class='pure-menu-item'><a href='%s' class='pure-menu-link'>Download CSV</a></li>"
body1_template
=
PSTR
(
"<li class='pure-menu-item'><a href='%s' class='pure-menu-link'>Download CSV</a></li>"
"<li class='pure-menu-item' id='led'>⬤</li>"
// LED
"</ul></div></div>"
"<script>"
...
...
@@ -85,10 +85,7 @@ namespace web_server {
"<tr><td>Connected?</td><td>%s</td></tr>"
"<tr><td>Last publish</td><td>%s</td></tr>"
"<tr><td>Interval</td><td>%5d s</td></tr>"
"</tbody>"
);
body2_template
=
PSTR
(
"</tbody>"
#if defined(ESP32)
"<tbody %s>"
"<tr><th colspan='2'>LoRaWAN</th></tr>"
...
...
@@ -98,6 +95,10 @@ namespace web_server {
"<tr><td>Interval</td><td>%5d s</td></tr>"
"</tbody>"
#endif
);
body2_template
=
PSTR
(
"<tr><th colspan='2'>Sensor</th></tr>"
"<tr><td>Temperature offset</td><td>%.1fK</td></tr>"
"<tr><td>Auto-calibration?</td><td>%s</td></tr>"
...
...
@@ -201,9 +202,9 @@ namespace web_server {
ss
-=
mm
*
60
;
//NOTE: Splitting in multiple parts in order to use less RAM. Higher than 2000 apparently crashes the ESP8266
char
content
[
1
7
00
];
char
content
[
1
6
00
];
// Current size (with Lorawan, timesteps and long thing name):
// INFO - Header size : 1
269
- Body1 size : 1
259
- Body2 size : 1
620
- Script size : 1
496
// INFO - Header size : 1
347
- Body1 size : 1
448
- Body2 size : 1
475
- Script size : 1
507
snprintf_P
(
content
,
sizeof
(
content
),
header_template
,
sensor
::
co2
,
config
::
ampel_name
(),
wifi
::
local_ip
);
...
...
@@ -217,21 +218,22 @@ namespace web_server {
sensor
::
temperature
,
sensor
::
humidity
,
sensor
::
timestamp
,
config
::
measurement_timestep
,
config
::
is_csv_active
()
?
""
:
"hidden"
,
csv_writer
::
last_successful_write
,
config
::
csv_interval
,
csv_writer
::
getAvailableSpace
()
/
1024
,
config
::
is_mqtt_active
()
?
""
:
"hidden"
,
mqtt
::
connected
?
"Yes"
:
"No"
,
mqtt
::
last_successful_publish
,
config
::
mqtt_sending_interval
);
mqtt
::
connected
?
"Yes"
:
"No"
,
mqtt
::
last_successful_publish
,
config
::
mqtt_sending_interval
#if defined(ESP32)
,
config
::
is_lorawan_active
()
?
""
:
"hidden"
,
lorawan
::
connected
?
"Yes"
:
"No"
,
config
::
lorawan_frequency_plan
,
lorawan
::
last_transmission
,
config
::
lorawan_sending_interval
#endif
);
Serial
.
print
(
F
(
" - Body1 size : "
));
Serial
.
print
(
strlen
(
content
));
web_config
::
http
.
sendContent
(
content
);
snprintf_P
(
content
,
sizeof
(
content
),
body2_template
,
#if defined(ESP32)
config
::
is_lorawan_active
()
?
""
:
"hidden"
,
lorawan
::
connected
?
"Yes"
:
"No"
,
config
::
lorawan_frequency_plan
,
lorawan
::
last_transmission
,
config
::
lorawan_sending_interval
,
#endif
config
::
temperature_offset
,
config
::
auto_calibrate_sensor
?
"Yes"
:
"No"
,
config
::
ampel_name
(),
config
::
ampel_name
(),
wifi
::
local_ip
,
wifi
::
local_ip
,
ampel
.
macAddress
,
ESP
.
getFreeHeap
(),
esp_get_max_free_block_size
(),
esp_get_heap_fragmentation
(),
ampel
.
max_loop_duration
,
ampel
.
board
,
ampel
.
sensorId
,
ampel
.
version
,
dd
,
hh
,
mm
,
ss
,
wifi
::
isAccessPoint
()
?
""
:
"hidden"
);
snprintf_P
(
content
,
sizeof
(
content
),
body2_template
,
config
::
temperature_offset
,
config
::
auto_calibrate_sensor
?
"Yes"
:
"No"
,
config
::
ampel_name
(),
config
::
ampel_name
(),
wifi
::
local_ip
,
wifi
::
local_ip
,
ampel
.
macAddress
,
ESP
.
getFreeHeap
(),
esp_get_max_free_block_size
(),
esp_get_heap_fragmentation
(),
ampel
.
max_loop_duration
,
ampel
.
board
,
ampel
.
sensorId
,
ampel
.
version
,
dd
,
hh
,
mm
,
ss
,
wifi
::
isAccessPoint
()
?
""
:
"hidden"
);
Serial
.
print
(
F
(
" - Body2 size : "
));
Serial
.
print
(
strlen
(
content
));
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets