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
060b4069
Commit
060b4069
authored
May 15, 2021
by
Eric Duminil
Browse files
NTP & MQTT?
parent
c4c4d856
Changes
3
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.h
View file @
060b4069
...
...
@@ -20,12 +20,6 @@
# ifdef AMPEL_HTTP
# include "web_server.h"
# endif
# if defined(ESP8266)
//allows sensor to be seen as SENSOR_ID.local, from the local network. For example : espd03cc5.local
# include <ESP8266mDNS.h>
# elif defined(ESP32)
# include <ESPmDNS.h>
# endif
#endif
#ifdef AMPEL_LORAWAN
...
...
ampel-firmware/ampel-firmware.ino
View file @
060b4069
...
...
@@ -85,8 +85,9 @@ void setup() {
csv_writer
::
initialize
(
ampel
.
sensorId
);
#endif
#ifdef AMPEL_WIFI
#ifdef AMPEL_WIFI
// Structure doesn't make sense anymore
# ifdef AMPEL_HTTP
//TODO: Rename. Not just web_server
web_server
::
initialize
();
# endif
#endif
...
...
@@ -184,7 +185,18 @@ void checkFlashButton() {
void
keepServicesAlive
()
{
#ifdef AMPEL_WIFI
# ifdef AMPEL_HTTP
web_server
::
update
();
web_server
::
update
();
//FIXME: Weird structure
# endif
if
(
WiFi
.
status
()
==
WL_CONNECTED
)
{
# if defined(ESP8266)
//NOTE: Sadly, there seems to be a bug in the current MDNS implementation.
// It stops working after 2 minutes. And forcing a restart leads to a memory leak.
MDNS
.
update
();
# endif
ntp
::
update
();
// NTP client has its own timer. It will connect to NTP server every 60s.
# ifdef AMPEL_MQTT
mqtt
::
keepConnection
();
// MQTT client has its own timer. It will keep alive every 15s.
# endif
}
#endif
}
ampel-firmware/web_server.cpp
View file @
060b4069
...
...
@@ -2,8 +2,10 @@
#if defined(ESP8266)
# include <ESP8266WebServer.h>
# include <ESP8266mDNS.h> //allows sensor to be seen as SENSOR_ID.local, from the local network. For example : espd03cc5.local
#elif defined(ESP32)
# include <WebServer.h>
# include <ESPmDNS.h>
#endif
#include "config.h"
...
...
@@ -83,6 +85,21 @@ namespace web_server {
Serial
.
print
(
F
(
"WiFi - Connected! IP address: "
));
IPAddress
address
=
WiFi
.
localIP
();
snprintf
(
wifi
::
local_ip
,
sizeof
(
wifi
::
local_ip
),
"%d.%d.%d.%d"
,
address
[
0
],
address
[
1
],
address
[
2
],
address
[
3
]);
ntp
::
initialize
();
//FIXME: Somehow already started
// if (MDNS.begin(ampel.sensorId)) { // Start the mDNS responder for SENSOR_ID.local
// MDNS.addService("http", "tcp", 80);
// Serial.println(F("mDNS responder started"));
// } else {
// Serial.println(F("Error setting up MDNS responder!"));
// }
# ifdef AMPEL_MQTT
mqtt
::
initialize
(
ampel
.
sensorId
);
# endif
Serial
.
println
(
wifi
::
local_ip
);
Serial
.
print
(
F
(
"You can access this sensor via http://"
));
Serial
.
print
(
ampel
.
sensorId
);
...
...
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