Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
81dc2d70
Commit
81dc2d70
authored
Feb 14, 2022
by
Eric Duminil
Browse files
Configurable name
parent
55b95e1e
Pipeline
#5811
passed with stage
in 2 minutes and 43 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.ino
View file @
81dc2d70
...
...
@@ -76,6 +76,8 @@ void setup() {
Serial
.
println
();
Serial
.
print
(
F
(
"Sensor ID: "
));
Serial
.
println
(
ampel
.
sensorId
);
Serial
.
print
(
F
(
"Name : "
));
Serial
.
println
(
config
::
ampel_name
());
Serial
.
print
(
F
(
"MAC : "
));
Serial
.
println
(
ampel
.
macAddress
);
Serial
.
print
(
F
(
"Board : "
));
...
...
@@ -87,7 +89,7 @@ void setup() {
sensor
::
initialize
();
csv_writer
::
initialize
(
ampel
.
sensorId
);
csv_writer
::
initialize
(
config
::
ampel_name
()
);
if
(
config
::
wifi_active
)
{
wifi
::
defineCommands
();
...
...
@@ -171,7 +173,7 @@ void wifiConnected() {
}
Serial
.
print
(
F
(
"You can access this sensor via http://"
));
Serial
.
print
(
ampel
.
sensorId
);
Serial
.
print
(
config
::
ampel_name
()
);
Serial
.
print
(
F
(
".local (might be unstable) or http://"
));
Serial
.
println
(
WiFi
.
localIP
());
}
...
...
ampel-firmware/csv_writer.cpp
View file @
81dc2d70
...
...
@@ -79,14 +79,14 @@ namespace csv_writer {
}
#endif
char
filename
[
15
];
// "/ESPxxxxxx.csv\0"
char
filename
[
20
];
// "/ESPxxxxxx.csv\0"
int
getAvailableSpace
()
{
return
getTotalSpace
()
-
getUsedSpace
();
}
void
initialize
(
const
char
*
sensorId
)
{
snprintf
(
filename
,
sizeof
(
filename
),
"/%s.csv"
,
sensorId
);
snprintf
(
filename
,
sizeof
(
filename
),
"/%
.15
s.csv"
,
sensorId
);
Serial
.
println
();
Serial
.
print
(
F
(
"Initializing FS..."
));
...
...
ampel-firmware/web_config.cpp
View file @
81dc2d70
...
...
@@ -287,6 +287,10 @@ namespace web_config {
*/
namespace
config
{
char
*
ampel_name
()
{
return
web_config
::
iotWebConf
->
getThingName
();
}
char
*
selected_ssid
()
{
return
web_config
::
iotWebConf
->
getWifiSsidParameter
()
->
valueBuffer
;
}
...
...
ampel-firmware/web_config.h
View file @
81dc2d70
...
...
@@ -10,6 +10,7 @@
namespace
config
{
void
save
();
// Save config to EEPROM
char
*
ampel_name
();
// WiFi
char
*
selected_ssid
();
char
*
ap_password
();
...
...
ampel-firmware/web_server.cpp
View file @
81dc2d70
...
...
@@ -191,7 +191,7 @@ namespace web_server {
char
content
[
2000
];
// Update if needed
// INFO - Header size : 1767 - Body size : 1991 - Script size : 1909
snprintf_P
(
content
,
sizeof
(
content
),
header_template
,
sensor
::
co2
,
ampel
.
sensorId
,
wifi
::
local_ip
,
snprintf_P
(
content
,
sizeof
(
content
),
header_template
,
sensor
::
co2
,
config
::
ampel_name
()
,
wifi
::
local_ip
,
csv_writer
::
filename
);
Serial
.
print
(
F
(
"INFO - Header size : "
));
...
...
@@ -200,7 +200,7 @@ namespace web_server {
web_config
::
http
.
send_P
(
200
,
PSTR
(
"text/html"
),
content
);
// Body
snprintf_P
(
content
,
sizeof
(
content
),
body_template
,
ampel
.
sensorId
,
sensor
::
co2
,
sensor
::
temperature
,
snprintf_P
(
content
,
sizeof
(
content
),
body_template
,
config
::
ampel_name
()
,
sensor
::
co2
,
sensor
::
temperature
,
sensor
::
humidity
,
sensor
::
timestamp
,
config
::
measurement_timestep
,
csv_writer
::
last_successful_write
,
config
::
csv_interval
,
csv_writer
::
getAvailableSpace
()
/
1024
,
mqtt
::
connected
?
"Yes"
:
"No"
,
mqtt
::
last_successful_publish
,
config
::
mqtt_sending_interval
,
...
...
@@ -208,7 +208,7 @@ namespace web_server {
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"
,
ampel
.
sensorId
,
ampel
.
sensorId
,
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
.
version
,
dd
,
hh
,
mm
,
ss
);
...
...
@@ -217,7 +217,7 @@ namespace web_server {
web_config
::
http
.
sendContent
(
content
);
// Script
snprintf_P
(
content
,
sizeof
(
content
),
script_template
,
csv_writer
::
filename
,
ampel
.
sensorId
);
snprintf_P
(
content
,
sizeof
(
content
),
script_template
,
csv_writer
::
filename
,
config
::
ampel_name
()
);
Serial
.
print
(
F
(
" - Script size : "
));
Serial
.
println
(
strlen
(
content
));
...
...
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