Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
40b0782b
Commit
40b0782b
authored
Dec 27, 2020
by
Eric Duminil
Browse files
Adding mqtt::connected? to web-server
parent
df91cd6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
mqtt.cpp
View file @
40b0782b
...
...
@@ -22,6 +22,7 @@ PubSubClient mqttClient(espClient);
namespace
mqtt
{
unsigned
long
last_sent_at
=
0
;
unsigned
long
last_failed_at
=
0
;
bool
connected
=
false
;
String
publish_topic
;
const
char
*
json_sensor_format
;
...
...
@@ -191,8 +192,9 @@ namespace mqtt {
mqttClient
.
connect
(
publish_topic
.
c_str
(),
config
::
mqtt_user
,
config
::
mqtt_password
);
LedEffects
::
onBoardLEDOff
();
if
(
mqttClient
.
connected
())
{
//TODO: Send local IP?
connected
=
mqttClient
.
connected
();
if
(
connected
)
{
if
(
config
::
allow_mqtt_commands
)
{
char
control_topic
[
60
];
// Should be enough for "CO2sensors/ESPd03cc5/control"
snprintf
(
control_topic
,
sizeof
(
control_topic
),
"%s/control"
,
publish_topic
.
c_str
());
...
...
mqtt.h
View file @
40b0782b
...
...
@@ -15,6 +15,7 @@ namespace config {
}
namespace
mqtt
{
extern
String
last_successful_publish
;
extern
bool
connected
;
void
initialize
(
String
&
topic
);
void
keepConnection
();
void
publishIfTimeHasCome
(
const
String
&
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temp
,
const
float
&
hum
);
...
...
web_server.cpp
View file @
40b0782b
...
...
@@ -95,7 +95,7 @@ namespace web_server {
#endif
#ifdef AMPEL_MQTT
"<tr><th colspan='2'>MQTT</th></tr>
\n
"
//TODO: Add connected?
"<tr><td>Connected?</td><td>%s</td></tr>
\n
"
"<tr><td>Last publish</td><td>%s</td></tr>
\n
"
"<tr><td>Timestep</td><td>%5d s</td></tr>
\n
"
#endif
...
...
@@ -225,7 +225,7 @@ namespace web_server {
csv_writer
::
last_successful_write
.
c_str
(),
config
::
csv_interval
,
csv_writer
::
getAvailableSpace
()
/
1024
,
#endif
#ifdef AMPEL_MQTT
mqtt
::
last_successful_publish
.
c_str
(),
config
::
sending_interval
,
mqtt
::
connected
?
"Yes"
:
"No"
,
mqtt
::
last_successful_publish
.
c_str
(),
config
::
sending_interval
,
#endif
#if defined(AMPEL_LORAWAN) && defined(ESP32)
lorawan
::
connected
?
"Yes"
:
"No"
,
LMIC_FREQUENCY_PLAN
,
lorawan
::
last_transmission
.
c_str
(),
...
...
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