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
67505912
Commit
67505912
authored
Oct 01, 2021
by
Eric Duminil
Browse files
Display MAC address at startup and in html
parent
95eb0555
Changes
4
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.ino
View file @
67505912
...
...
@@ -70,6 +70,8 @@ void setup() {
Serial
.
println
();
Serial
.
print
(
F
(
"Sensor ID: "
));
Serial
.
println
(
ampel
.
sensorId
);
Serial
.
print
(
F
(
"MAC : "
));
Serial
.
println
(
ampel
.
macAddress
);
Serial
.
print
(
F
(
"Board : "
));
Serial
.
println
(
ampel
.
board
);
Serial
.
print
(
F
(
"Firmware : "
));
...
...
ampel-firmware/util.cpp
View file @
67505912
...
...
@@ -70,9 +70,18 @@ void Ampel::showFreeSpace() {
}
char
sensorId
[
10
];
// e.g "ESPxxxxxx\0"
char
macAddress
[
18
];
// e.g "XX:XX:XX:XX:XX:XX\0"
uint8_t
mac
[
6
];
char
*
getMacString
()
{
WiFi
.
macAddress
(
mac
);
// Get all 6 bytes of ESP MAC
snprintf
(
macAddress
,
sizeof
(
macAddress
),
"%02X:%02X:%02X:%02X:%02X:%02X"
,
mac
[
0
],
mac
[
1
],
mac
[
2
],
mac
[
3
],
mac
[
4
],
mac
[
5
]);
return
macAddress
;
}
char
*
getSensorId
()
{
uint8_t
mac
[
6
];
WiFi
.
macAddress
(
mac
);
// Get last 3 bytes of ESP MAC (worldwide unique)
snprintf
(
sensorId
,
sizeof
(
sensorId
),
"ESP%02x%02x%02x"
,
mac
[
3
],
mac
[
4
],
mac
[
5
]);
...
...
@@ -80,7 +89,7 @@ char* getSensorId() {
}
Ampel
::
Ampel
()
:
board
(
current_board
),
sensorId
(
getSensorId
()),
max_loop_duration
(
0
)
{
board
(
current_board
),
sensorId
(
getSensorId
()),
macAddress
(
getMacString
()),
max_loop_duration
(
0
)
{
sensor_console
::
defineIntCommand
(
"set_time"
,
ntp
::
setLocalTime
,
F
(
"1618829570 (Sets time to the given UNIX time)"
));
sensor_console
::
defineCommand
(
"free"
,
Ampel
::
showFreeSpace
,
F
(
"(Displays available heap space)"
));
sensor_console
::
defineCommand
(
"reset"
,
[]()
{
...
...
ampel-firmware/util.h
View file @
67505912
...
...
@@ -38,9 +38,10 @@ class Ampel {
private:
static
void
showFreeSpace
();
public:
const
char
*
version
=
"v0.2.
2
-DEV"
;
// Update manually after significant changes.
const
char
*
version
=
"v0.2.
3
-DEV"
;
// Update manually after significant changes.
const
char
*
board
;
const
char
*
sensorId
;
const
char
*
macAddress
;
uint32_t
max_loop_duration
;
Ampel
();
};
...
...
ampel-firmware/web_server.cpp
View file @
67505912
...
...
@@ -111,6 +111,7 @@ namespace web_server {
"<tr><td>Auto-calibration?</td><td>%s</td></tr>
\n
"
"<tr><td>Local address</td><td><a href='http://%s.local/'>%s.local</a></td></tr>
\n
"
"<tr><td>Local IP</td><td><a href='http://%s'>%s</a></td></tr>
\n
"
"<tr><td>MAC</td><td>%s</td></tr>
\n
"
"<tr><td>Free heap space</td><td>%6d bytes</td></tr>
\n
"
"<tr><td>Largest heap block</td><td>%6d bytes</td></tr>
\n
"
"<tr><td>Max loop duration</td><td>%5d ms</td></tr>
\n
"
...
...
@@ -239,8 +240,8 @@ namespace web_server {
config
::
lorawan_sending_interval
,
#endif
config
::
temperature_offset
,
config
::
auto_calibrate_sensor
?
"Yes"
:
"No"
,
ampel
.
sensorId
,
ampel
.
sensorId
,
wifi
::
local_ip
,
wifi
::
local_ip
,
ESP
.
getFreeHeap
(),
esp_get_max_free_block_size
(),
ampel
.
max_loop_duration
,
ampel
.
board
,
ampel
.
version
,
dd
,
hh
,
mm
,
ss
);
wifi
::
local_ip
,
wifi
::
local_ip
,
ampel
.
macAddress
,
ESP
.
getFreeHeap
(),
esp_get_max_free_block_size
(),
ampel
.
max_loop_duration
,
ampel
.
board
,
ampel
.
version
,
dd
,
hh
,
mm
,
ss
);
// Serial.print(F(" - Body size : "));
// Serial.print(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