mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Text localization information webpage
This commit is contained in:
parent
642f6f67e6
commit
b60d76bef4
@ -581,13 +581,13 @@ void hasp_get_info(JsonDocument& doc)
|
|||||||
JsonObject info = doc.createNestedObject(F(D_MANUFACTURER));
|
JsonObject info = doc.createNestedObject(F(D_MANUFACTURER));
|
||||||
|
|
||||||
haspGetVersion(size_buf, sizeof(size_buf));
|
haspGetVersion(size_buf, sizeof(size_buf));
|
||||||
info[F("Version")] = size_buf;
|
info[F(D_INFO_VERSION)] = size_buf;
|
||||||
|
|
||||||
buffer = __DATE__;
|
buffer = __DATE__;
|
||||||
buffer += (" ");
|
buffer += (" ");
|
||||||
buffer += __TIME__;
|
buffer += __TIME__;
|
||||||
buffer += (" UTC"); // Github buildservers are in UTC
|
buffer += (" UTC"); // Github buildservers are in UTC
|
||||||
info[F("Build DateTime")] = buffer;
|
info[F(D_INFO_BUILD_DATETIME)] = buffer;
|
||||||
|
|
||||||
unsigned long time = millis() / 1000;
|
unsigned long time = millis() / 1000;
|
||||||
uint16_t day = time / 86400;
|
uint16_t day = time / 86400;
|
||||||
@ -617,21 +617,21 @@ void hasp_get_info(JsonDocument& doc)
|
|||||||
itoa(sec, size_buf, DEC);
|
itoa(sec, size_buf, DEC);
|
||||||
buffer += size_buf;
|
buffer += size_buf;
|
||||||
buffer += "s";
|
buffer += "s";
|
||||||
info[F("Uptime")] = buffer;
|
info[F(D_INFO_UPTIME)] = buffer;
|
||||||
|
|
||||||
info = doc.createNestedObject(F("Device Memory"));
|
info = doc.createNestedObject(F("Device Memory"));
|
||||||
Parser::format_bytes(haspDevice.get_free_heap(), size_buf, sizeof(size_buf));
|
Parser::format_bytes(haspDevice.get_free_heap(), size_buf, sizeof(size_buf));
|
||||||
info[F("Free Heap")] = size_buf;
|
info[F(D_INFO_FREE_HEAP)] = size_buf;
|
||||||
Parser::format_bytes(haspDevice.get_free_max_block(), size_buf, sizeof(size_buf));
|
Parser::format_bytes(haspDevice.get_free_max_block(), size_buf, sizeof(size_buf));
|
||||||
info[F("Free Block")] = size_buf;
|
info[F(D_INFO_FREE_BLOCK)] = size_buf;
|
||||||
info[F("Fragmentation")] = haspDevice.get_heap_fragmentation();
|
info[F(D_INFO_FRAGMENTATION)] = haspDevice.get_heap_fragmentation();
|
||||||
|
|
||||||
#if ARDUINO_ARCH_ESP32
|
#if ARDUINO_ARCH_ESP32
|
||||||
if(psramFound()) {
|
if(psramFound()) {
|
||||||
Parser::format_bytes(ESP.getFreePsram(), size_buf, sizeof(size_buf));
|
Parser::format_bytes(ESP.getFreePsram(), size_buf, sizeof(size_buf));
|
||||||
info[F("Free PSRam")] = size_buf;
|
info[F(D_INFO_PSRAM_FREE)] = size_buf;
|
||||||
Parser::format_bytes(ESP.getPsramSize(), size_buf, sizeof(size_buf));
|
Parser::format_bytes(ESP.getPsramSize(), size_buf, sizeof(size_buf));
|
||||||
info[F("PSRam Size")] = size_buf;
|
info[F(D_INFO_PSRAM_SIZE)] = size_buf;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -641,8 +641,8 @@ void hasp_get_info(JsonDocument& doc)
|
|||||||
Parser::format_bytes(mem_mon.total_size, size_buf, sizeof(size_buf));
|
Parser::format_bytes(mem_mon.total_size, size_buf, sizeof(size_buf));
|
||||||
info[F("Total")] = size_buf;
|
info[F("Total")] = size_buf;
|
||||||
Parser::format_bytes(mem_mon.free_size, size_buf, sizeof(size_buf));
|
Parser::format_bytes(mem_mon.free_size, size_buf, sizeof(size_buf));
|
||||||
info[F("Free")] = size_buf;
|
info[F("Free")] = size_buf;
|
||||||
info[F("Fragmentation")] = mem_mon.frag_pct;
|
info[F(D_INFO_FRAGMENTATION)] = mem_mon.frag_pct;
|
||||||
|
|
||||||
info = doc.createNestedObject(F("HASP State"));
|
info = doc.createNestedObject(F("HASP State"));
|
||||||
hasp_get_sleep_state(size_buf);
|
hasp_get_sleep_state(size_buf);
|
||||||
|
@ -321,7 +321,7 @@ void mqttStart()
|
|||||||
conn_opts.password = mqttPassword.c_str();
|
conn_opts.password = mqttPassword.c_str();
|
||||||
|
|
||||||
if((rc = MQTTClient_connect(mqtt_client, &conn_opts)) != MQTTCLIENT_SUCCESS) {
|
if((rc = MQTTClient_connect(mqtt_client, &conn_opts)) != MQTTCLIENT_SUCCESS) {
|
||||||
printf("Failed to start connect, return code %d\n", rc);
|
printf("Failed to connect, return code %d\n", rc);
|
||||||
rc = EXIT_FAILURE;
|
rc = EXIT_FAILURE;
|
||||||
// goto destroy_exit;
|
// goto destroy_exit;
|
||||||
} else {
|
} else {
|
||||||
@ -346,7 +346,7 @@ void mqttStop()
|
|||||||
// disc_opts.onSuccess = onDisconnect;
|
// disc_opts.onSuccess = onDisconnect;
|
||||||
// disc_opts.onFailure = onDisconnectFailure;
|
// disc_opts.onFailure = onDisconnectFailure;
|
||||||
if((rc = MQTTClient_disconnect(mqtt_client, 1000)) != MQTTCLIENT_SUCCESS) {
|
if((rc = MQTTClient_disconnect(mqtt_client, 1000)) != MQTTCLIENT_SUCCESS) {
|
||||||
printf("Failed to start disconnect, return code %d\n", rc);
|
printf("Failed to disconnect, return code %d\n", rc);
|
||||||
rc = EXIT_FAILURE;
|
rc = EXIT_FAILURE;
|
||||||
// goto destroy_exit;
|
// goto destroy_exit;
|
||||||
}
|
}
|
||||||
@ -397,21 +397,21 @@ void mqtt_get_info(JsonDocument& doc)
|
|||||||
{
|
{
|
||||||
char mqttClientId[64];
|
char mqttClientId[64];
|
||||||
|
|
||||||
JsonObject info = doc.createNestedObject(F("MQTT"));
|
JsonObject info = doc.createNestedObject(F("MQTT"));
|
||||||
info[F("Server")] = mqttServer;
|
info[F(D_INFO_SERVER)] = mqttServer;
|
||||||
info[F("User")] = mqttUser;
|
info[F(D_INFO_USERNAME)] = mqttUser;
|
||||||
info[F("ClientID")] = haspDevice.get_hostname();
|
info[F(D_INFO_CLIENTID)] = haspDevice.get_hostname();
|
||||||
|
|
||||||
if(mqttIsConnected()) { // Check MQTT connection
|
if(mqttIsConnected()) { // Check MQTT connection
|
||||||
info[F("Status")] = F("Connected");
|
info[F(D_INFO_STATUS)] = F(D_INFO_CONNECTED);
|
||||||
} else {
|
} else {
|
||||||
info[F("Status")] = F("<font color='red'><b>Disconnected</b></font>, return code: ");
|
info[F(D_INFO_STATUS)] = F("<font color='red'><b>" D_INFO_DISCONNECTED "</b></font>, return code: ");
|
||||||
// +String(mqttClient.returnCode());
|
// +String(mqttClient.returnCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
info[F("Received")] = mqttReceiveCount;
|
info[F(D_INFO_RECEIVED)] = mqttReceiveCount;
|
||||||
info[F("Published")] = mqttPublishCount;
|
info[F(D_INFO_PUBLISHED)] = mqttPublishCount;
|
||||||
info[F("Failed")] = mqttFailedCount;
|
info[F(D_INFO_FAILED)] = mqttFailedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_PAHO
|
#endif // USE_PAHO
|
||||||
|
@ -385,25 +385,25 @@ void mqtt_get_info(JsonDocument& doc)
|
|||||||
String mac((char*)0);
|
String mac((char*)0);
|
||||||
mac.reserve(64);
|
mac.reserve(64);
|
||||||
|
|
||||||
JsonObject info = doc.createNestedObject(F("MQTT"));
|
JsonObject info = doc.createNestedObject(F("MQTT"));
|
||||||
info[F("Server")] = mqttServer;
|
info[F(D_INFO_SERVER)] = mqttServer;
|
||||||
info[F("User")] = mqttUser;
|
info[F(D_INFO_USERNAME)] = mqttUser;
|
||||||
|
|
||||||
mac = halGetMacAddress(3, "");
|
mac = halGetMacAddress(3, "");
|
||||||
mac.toLowerCase();
|
mac.toLowerCase();
|
||||||
snprintf_P(mqttClientId, sizeof(mqttClientId), PSTR("%s-%s"), haspDevice.get_hostname(), mac.c_str());
|
snprintf_P(mqttClientId, sizeof(mqttClientId), PSTR("%s-%s"), haspDevice.get_hostname(), mac.c_str());
|
||||||
info[F("ClientID")] = mqttClientId;
|
info[F(D_INFO_CLIENTID)] = mqttClientId;
|
||||||
|
|
||||||
if(mqttIsConnected()) { // Check MQTT connection
|
if(mqttIsConnected()) { // Check MQTT connection
|
||||||
info[F("Status")] = F("Connected");
|
info[F(D_INFO_STATUS)] = F(D_INFO_CONNECTED);
|
||||||
} else {
|
} else {
|
||||||
info[F("Status")] = F("<font color='red'><b>Disconnected</b></font>, return code: ");
|
info[F(D_INFO_STATUS)] = F("<font color='red'><b>" D_INFO_DISCONNECTED "</b></font>, return code: ");
|
||||||
// +String(mqttClient.returnCode());
|
// +String(mqttClient.returnCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
info[F("Received")] = mqttReceiveCount;
|
info[F(D_INFO_RECEIVED)] = mqttReceiveCount;
|
||||||
info[F("Published")] = mqttPublishCount;
|
info[F(D_INFO_PUBLISHED)] = mqttPublishCount;
|
||||||
info[F("Failed")] = mqttFailedCount;
|
info[F(D_INFO_FAILED)] = mqttFailedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HASP_USE_CONFIG > 0
|
#if HASP_USE_CONFIG > 0
|
||||||
|
@ -25,13 +25,13 @@ void EthernetEvent(WiFiEvent_t event)
|
|||||||
eth_connected = true;
|
eth_connected = true;
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||||
LOG_TRACE(TAG_ETH, F("MAC Address %s"), ETH.macAddress().c_str());
|
LOG_TRACE(TAG_ETH, F(D_INFO_MAC_ADDRESS " %s"), ETH.macAddress().c_str());
|
||||||
ip = ETH.localIP();
|
ip = ETH.localIP();
|
||||||
LOG_TRACE(TAG_ETH, F("IPv4: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
LOG_TRACE(TAG_ETH, F("IPv4: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||||
if(ETH.fullDuplex()) {
|
if(ETH.fullDuplex()) {
|
||||||
LOG_TRACE(TAG_ETH, F("FULL_DUPLEX"));
|
LOG_TRACE(TAG_ETH, F(D_INFO_FULL_DUPLEX));
|
||||||
}
|
}
|
||||||
LOG_TRACE(TAG_ETH, F("LINK_SPEED %d Mbps"), ETH.linkSpeed());
|
LOG_TRACE(TAG_ETH, F(D_INFO_LINK_SPEED " %d Mbps"), ETH.linkSpeed());
|
||||||
eth_connected = true;
|
eth_connected = true;
|
||||||
networkStart(); // Start network services
|
networkStart(); // Start network services
|
||||||
break;
|
break;
|
||||||
@ -76,19 +76,19 @@ void ethernet_get_info(JsonDocument& doc)
|
|||||||
String buffer((char*)0);
|
String buffer((char*)0);
|
||||||
buffer.reserve(64);
|
buffer.reserve(64);
|
||||||
|
|
||||||
JsonObject info = doc.createNestedObject(F("Ethernet"));
|
JsonObject info = doc.createNestedObject(F(D_INFO_ETHERNET));
|
||||||
|
|
||||||
buffer = ETH.linkSpeed();
|
buffer = ETH.linkSpeed();
|
||||||
buffer += F(" Mbps");
|
buffer += F(" Mbps");
|
||||||
if(ETH.fullDuplex()) {
|
if(ETH.fullDuplex()) {
|
||||||
buffer += F(" FULL_DUPLEX");
|
buffer += F(" " D_INFO_FULL_DUPLEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
info[F("Link Speed")] = buffer;
|
info[F(D_INFO_LINK_SPEED)] = buffer;
|
||||||
info[F("IP Address")] = ETH.localIP().toString();
|
info[F(D_INFO_IP_ADDRESS)] = ETH.localIP().toString();
|
||||||
info[F("Gateway")] = ETH.gatewayIP().toString();
|
info[F(D_INFO_GATEWAY)] = ETH.gatewayIP().toString();
|
||||||
info[F("DNS Server")] = ETH.dnsIP().toString();
|
info[F(D_INFO_DNS_SERVER)] = ETH.dnsIP().toString();
|
||||||
info[F("MAC Address")] = ETH.macAddress();
|
info[F(D_INFO_MAC_ADDRESS)] = ETH.macAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -524,7 +524,7 @@ void wifi_get_info(JsonDocument& doc)
|
|||||||
String buffer((char*)0);
|
String buffer((char*)0);
|
||||||
buffer.reserve(64);
|
buffer.reserve(64);
|
||||||
|
|
||||||
JsonObject info = doc.createNestedObject(F("Wifi"));
|
JsonObject info = doc.createNestedObject(F(D_INFO_WIFI));
|
||||||
|
|
||||||
int8_t rssi = WiFi.RSSI();
|
int8_t rssi = WiFi.RSSI();
|
||||||
buffer += String(rssi);
|
buffer += String(rssi);
|
||||||
@ -542,25 +542,22 @@ void wifi_get_info(JsonDocument& doc)
|
|||||||
buffer += F("Very Bad)");
|
buffer += F("Very Bad)");
|
||||||
}
|
}
|
||||||
|
|
||||||
info[F("SSID")] = String(WiFi.SSID());
|
info[F(D_INFO_SSID)] = String(WiFi.SSID());
|
||||||
info[F("Signal Strength")] = buffer;
|
info[F(D_INFO_RSSI)] = buffer;
|
||||||
|
|
||||||
#if defined(STM32F4xx)
|
#if defined(STM32F4xx)
|
||||||
byte mac[6];
|
byte mac[6];
|
||||||
WiFi.macAddress(mac);
|
WiFi.macAddress(mac);
|
||||||
char macAddress[16];
|
char macAddress[16];
|
||||||
snprintf_P(macAddress, sizeof(macAddress), PSTR("%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
snprintf_P(macAddress, sizeof(macAddress), PSTR("%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
httpMessage += F("</br><b>IP Address: </b>");
|
info[F(D_INFO_IP_ADDRESS)] = String(WiFi.localIP());
|
||||||
httpMessage += String(WiFi.localIP());
|
info[F(D_INFO_GATEWAY)] = String(WiFi.gatewayIP());
|
||||||
httpMessage += F("</br><b>Gateway: </b>");
|
info[F(D_INFO_MAC_ADDRESS)] = String(macAddress);
|
||||||
httpMessage += String(WiFi.gatewayIP());
|
|
||||||
httpMessage += F("</br><b>MAC Address: </b>");
|
|
||||||
httpMessage += String(macAddress);
|
|
||||||
#else
|
#else
|
||||||
info[F("IP Address")] = WiFi.localIP().toString();
|
info[F(D_INFO_IP_ADDRESS)] = WiFi.localIP().toString();
|
||||||
info[F("Gateway")] = WiFi.gatewayIP().toString();
|
info[F(D_INFO_GATEWAY)] = WiFi.gatewayIP().toString();
|
||||||
info[F("DNS Server")] = WiFi.dnsIP().toString();
|
info[F(D_INFO_DNS_SERVER)] = WiFi.dnsIP().toString();
|
||||||
info[F("MAC Address")] = WiFi.macAddress();
|
info[F(D_INFO_MAC_ADDRESS)] = WiFi.macAddress();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user