ESPHome
2023.5.5
esphome
esphome
core
util.cpp
Go to the documentation of this file.
1
#include "
esphome/core/util.h
"
2
#include "
esphome/core/defines.h
"
3
#include "
esphome/core/application.h
"
4
#include "
esphome/core/version.h
"
5
#include "
esphome/core/log.h
"
6
7
#ifdef USE_API
8
#include "
esphome/components/api/api_server.h
"
9
#endif
10
11
#ifdef USE_MQTT
12
#include "
esphome/components/mqtt/mqtt_client.h
"
13
#endif
14
15
namespace
esphome
{
16
17
bool
api_is_connected
() {
18
#ifdef USE_API
19
if
(
api::global_api_server
!=
nullptr
) {
20
return
api::global_api_server
->
is_connected
();
21
}
22
#endif
23
return
false
;
24
}
25
26
bool
mqtt_is_connected
() {
27
#ifdef USE_MQTT
28
if
(
mqtt::global_mqtt_client
!=
nullptr
) {
29
return
mqtt::global_mqtt_client
->
is_connected
();
30
}
31
#endif
32
return
false
;
33
}
34
35
bool
remote_is_connected
() {
return
api_is_connected
() ||
mqtt_is_connected
(); }
36
37
}
// namespace esphome
esphome::api::APIServer::is_connected
bool is_connected() const
Definition:
api_server.cpp:422
application.h
mqtt_client.h
esphome::api_is_connected
bool api_is_connected()
Return whether the node has at least one client connected to the native API.
Definition:
util.cpp:17
esphome::mqtt::global_mqtt_client
MQTTClientComponent * global_mqtt_client
defines.h
esphome::remote_is_connected
bool remote_is_connected()
Return whether the node has any form of "remote" connection via the API or to an MQTT broker...
Definition:
util.cpp:35
version.h
esphome
Definition:
a4988.cpp:4
util.h
api_server.h
log.h
esphome::mqtt_is_connected
bool mqtt_is_connected()
Return whether the node has an active connection to an MQTT broker.
Definition:
util.cpp:26
esphome::api::global_api_server
APIServer * global_api_server
Definition:
api_server.cpp:286
esphome::mqtt::MQTTClientComponent::is_connected
bool is_connected()
Generated by
1.8.13