mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-15 20:30:01 +03:00
added get_ip_or_hostname()
This commit is contained in:
@@ -1789,6 +1789,28 @@ std::string System::get_metrics_prometheus() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return IP or hostname of the EMS-ESP device
|
||||||
|
String System::get_ip_or_hostname() {
|
||||||
|
String result = "ems-esp";
|
||||||
|
EMSESP::esp32React.getNetworkSettingsService()->read([&](NetworkSettings & settings) {
|
||||||
|
if (settings.enableMDNS) {
|
||||||
|
if (EMSESP::system_.ethernet_connected()) {
|
||||||
|
result = ETH.getHostname();
|
||||||
|
} else if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
result = WiFi.getHostname();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// no DNS, use the IP
|
||||||
|
if (EMSESP::system_.ethernet_connected()) {
|
||||||
|
result = ETH.localIP().toString();
|
||||||
|
} else if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
result = WiFi.localIP().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// export status information including the device information
|
// export status information including the device information
|
||||||
// http://ems-esp/api/system/info
|
// http://ems-esp/api/system/info
|
||||||
bool System::command_info(const char * value, const int8_t id, JsonObject output) {
|
bool System::command_info(const char * value, const int8_t id, JsonObject output) {
|
||||||
@@ -2356,7 +2378,6 @@ String System::getBBQKeesGatewayDetails(uint8_t detail) {
|
|||||||
// This is to avoid timeouts in callback functions, like calling from a web hook.
|
// This is to avoid timeouts in callback functions, like calling from a web hook.
|
||||||
bool System::uploadFirmwareURL(const char * url) {
|
bool System::uploadFirmwareURL(const char * url) {
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
|
|
||||||
static String saved_url;
|
static String saved_url;
|
||||||
|
|
||||||
if (url && strlen(url) > 0) {
|
if (url && strlen(url) > 0) {
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ class System {
|
|||||||
static bool command_response(const char * value, const int8_t id, JsonObject output);
|
static bool command_response(const char * value, const int8_t id, JsonObject output);
|
||||||
static bool command_service(const char * cmd, const char * value);
|
static bool command_service(const char * cmd, const char * value);
|
||||||
|
|
||||||
static bool get_value_info(JsonObject root, const char * cmd);
|
static bool get_value_info(JsonObject root, const char * cmd);
|
||||||
static void get_value_json(JsonObject output, const std::string & circuit, const std::string & name, JsonVariant val);
|
static void get_value_json(JsonObject output, const std::string & circuit, const std::string & name, JsonVariant val);
|
||||||
static std::string get_metrics_prometheus();
|
static std::string get_metrics_prometheus();
|
||||||
|
|
||||||
#if defined(EMSESP_TEST)
|
#if defined(EMSESP_TEST)
|
||||||
@@ -151,6 +151,8 @@ class System {
|
|||||||
|
|
||||||
static bool readCommand(const char * data);
|
static bool readCommand(const char * data);
|
||||||
|
|
||||||
|
static String get_ip_or_hostname();
|
||||||
|
|
||||||
void dallas_gpio(uint8_t gpio) {
|
void dallas_gpio(uint8_t gpio) {
|
||||||
dallas_gpio_ = gpio;
|
dallas_gpio_ = gpio;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user