Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
16536c99
Commit
16536c99
authored
Feb 13, 2022
by
Eric Duminil
Browse files
Debug
parent
db032606
Changes
3
Show whitespace changes
Inline
Side-by-side
ampel-firmware/src/lib/NTPClient/NTPClient.h
View file @
16536c99
...
@@ -20,7 +20,7 @@ class NTPClient {
...
@@ -20,7 +20,7 @@ class NTPClient {
unsigned
long
_updateInterval
=
60000
;
// In ms
unsigned
long
_updateInterval
=
60000
;
// In ms
unsigned
long
_currentEpoc
=
1640995200
;
// NOTE: Custom code for ampel-firmware : Default is 1st January 2020. Better than 1970
unsigned
long
_currentEpoc
=
0
;
// In ms
unsigned
long
_lastUpdate
=
0
;
// In ms
unsigned
long
_lastUpdate
=
0
;
// In ms
byte
_packetBuffer
[
NTP_PACKET_SIZE
];
byte
_packetBuffer
[
NTP_PACKET_SIZE
];
...
...
ampel-firmware/web_server.cpp
View file @
16536c99
...
@@ -29,6 +29,7 @@ namespace web_server {
...
@@ -29,6 +29,7 @@ namespace web_server {
void
handleWebServerCSV
();
void
handleWebServerCSV
();
void
definePages
()
{
void
definePages
()
{
//TODO: Remove all "\n" to save some space
header_template
=
header_template
=
PSTR
(
"<!doctype html><html lang=en>"
PSTR
(
"<!doctype html><html lang=en>"
"<head>
\n
"
"<head>
\n
"
...
@@ -140,10 +141,13 @@ namespace web_server {
...
@@ -140,10 +141,13 @@ namespace web_server {
"n=lines.length;
\n
"
"n=lines.length;
\n
"
"lines.forEach((line,i)=>{
\n
"
"lines.forEach((line,i)=>{
\n
"
"fields=line.split(';');
\n
"
"fields=line.split(';');
\n
"
//Don't display points without time
"if (!fields[0].includes('1970-')){"
"xs.push(fields[0]);
\n
"
"xs.push(fields[0]);
\n
"
"data[0]['y'].push(fields[1]);
\n
"
"data[0]['y'].push(fields[1]);
\n
"
"data[1]['y'].push(fields[2]);
\n
"
"data[1]['y'].push(fields[2]);
\n
"
"data[2]['y'].push(fields[3]);
\n
"
"data[2]['y'].push(fields[3]);
\n
"
"};"
"if(i>4 && i<n-12){if(i==5){fields=['...','...','...','...']}else{return;}}
\n
"
"if(i>4 && i<n-12){if(i==5){fields=['...','...','...','...']}else{return;}}
\n
"
"row=document.createElement('tr');
\n
"
"row=document.createElement('tr');
\n
"
"fields.forEach((field,index)=>{
\n
"
"fields.forEach((field,index)=>{
\n
"
...
@@ -171,10 +175,6 @@ namespace web_server {
...
@@ -171,10 +175,6 @@ namespace web_server {
}
}
void
handleWebServerRoot
()
{
void
handleWebServerRoot
()
{
// if (web_config::handleCaptivePortal()) {
// // -- Captive portal requests were already served.
// return;
// }
if
(
!
shouldBeAllowed
())
{
if
(
!
shouldBeAllowed
())
{
return
web_config
::
http
.
requestAuthentication
(
DIGEST_AUTH
);
return
web_config
::
http
.
requestAuthentication
(
DIGEST_AUTH
);
}
}
...
@@ -194,8 +194,8 @@ namespace web_server {
...
@@ -194,8 +194,8 @@ namespace web_server {
snprintf_P
(
content
,
sizeof
(
content
),
header_template
,
sensor
::
co2
,
ampel
.
sensorId
,
wifi
::
local_ip
,
snprintf_P
(
content
,
sizeof
(
content
),
header_template
,
sensor
::
co2
,
ampel
.
sensorId
,
wifi
::
local_ip
,
csv_writer
::
filename
);
csv_writer
::
filename
);
//
Serial.print(F("INFO - Header size : "));
Serial
.
print
(
F
(
"INFO - Header size : "
));
//
Serial.print(strlen(content));
Serial
.
print
(
strlen
(
content
));
web_config
::
http
.
setContentLength
(
CONTENT_LENGTH_UNKNOWN
);
web_config
::
http
.
setContentLength
(
CONTENT_LENGTH_UNKNOWN
);
web_config
::
http
.
send_P
(
200
,
PSTR
(
"text/html"
),
content
);
web_config
::
http
.
send_P
(
200
,
PSTR
(
"text/html"
),
content
);
...
@@ -212,15 +212,15 @@ namespace web_server {
...
@@ -212,15 +212,15 @@ namespace web_server {
wifi
::
local_ip
,
wifi
::
local_ip
,
ampel
.
macAddress
,
ESP
.
getFreeHeap
(),
esp_get_max_free_block_size
(),
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
.
version
,
dd
,
hh
,
mm
,
ss
);
esp_get_heap_fragmentation
(),
ampel
.
max_loop_duration
,
ampel
.
board
,
ampel
.
version
,
dd
,
hh
,
mm
,
ss
);
//
Serial.print(F(" - Body size : "));
Serial
.
print
(
F
(
" - Body size : "
));
//
Serial.print(strlen(content));
Serial
.
print
(
strlen
(
content
));
web_config
::
http
.
sendContent
(
content
);
web_config
::
http
.
sendContent
(
content
);
// Script
// Script
snprintf_P
(
content
,
sizeof
(
content
),
script_template
,
csv_writer
::
filename
,
ampel
.
sensorId
);
snprintf_P
(
content
,
sizeof
(
content
),
script_template
,
csv_writer
::
filename
,
ampel
.
sensorId
);
//
Serial.print(F(" - Script size : "));
Serial
.
print
(
F
(
" - Script size : "
));
//
Serial.println(strlen(content));
Serial
.
println
(
strlen
(
content
));
web_config
::
http
.
sendContent
(
content
);
web_config
::
http
.
sendContent
(
content
);
}
}
...
...
ampel-firmware/wifi_util.cpp
View file @
16536c99
...
@@ -25,12 +25,14 @@ namespace wifi {
...
@@ -25,12 +25,14 @@ namespace wifi {
web_config
::
update
();
web_config
::
update
();
if
(
connected
())
{
if
(
connected
())
{
break
;
break
;
}
else
if
(
WiFi
.
status
()
==
WL_NO_SHIELD
)
{
// Access point, apparently
}
else
if
(
WiFi
.
status
()
==
WL_NO_SHIELD
)
{
// Access point, apparently
FIXME: This doesn'T work for ESP826clipse6
led_effects
::
showKITTWheel
(
0xFF0015
,
1
);
led_effects
::
showKITTWheel
(
0xFF0015
,
1
);
}
else
{
}
else
{
led_effects
::
showRainbowWheel
();
led_effects
::
showRainbowWheel
();
}
}
Serial
.
print
(
"."
);
Serial
.
print
(
"Status : "
);
Serial
.
println
(
WiFi
.
status
());
// Serial.print(".");
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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