mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-09-13 13:44:10 +00:00
Merge remote-tracking branch 'emsesp/dev' into dev
This commit is contained in:
+20
-4
@@ -59,11 +59,16 @@ bool LED::loop(uint8_t healthcheck, bool button_busy) {
|
||||
// the user-requested LED blink always has preference
|
||||
if (!is_user_led_blink_) {
|
||||
// check for button press.
|
||||
// if button is pressed, show LED (yellow on RGB LED, on/off on standard LED)
|
||||
// it will turn off on the next loop cycle
|
||||
// while the button is held show the LED (yellow on RGB LED, on/off on standard LED),
|
||||
// and on release go back to the default state and re-check the health on the next cycle
|
||||
if (last_button_busy_ != button_busy) {
|
||||
last_button_busy_ = button_busy;
|
||||
set_led(button_busy ? Color::OFF : Color::YELLOW); // Yellow
|
||||
if (button_busy) {
|
||||
set_led(Color::YELLOW); // Yellow
|
||||
} else {
|
||||
reset_led();
|
||||
previous_healthcheck_ = System::HEALTHCHECK_RESET;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,6 +109,12 @@ bool LED::loop(uint8_t healthcheck, bool button_busy) {
|
||||
color_steps_[2] = Color::BLUE; // blue, no network and no bus
|
||||
}
|
||||
}
|
||||
|
||||
// there's nothing to flash, so leave the LED in the state reset_led() gave it.
|
||||
// Running the sequence here would keep writing Color::OFF and a healthy system would never show green.
|
||||
if (healthcheck == 0 || button_busy) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// show the LED status based on the healthcheck and button busy status
|
||||
@@ -119,6 +130,11 @@ void LED::reset_led() {
|
||||
color_steps_[0] = Color::OFF;
|
||||
color_steps_[1] = Color::OFF;
|
||||
color_steps_[2] = Color::OFF;
|
||||
|
||||
// rewind the sequence so it starts from the top if the health degrades again
|
||||
led_long_timer_ = 1; // 1 will kick it off immediately
|
||||
led_short_timer_ = 0;
|
||||
led_flash_step_ = 0;
|
||||
}
|
||||
|
||||
// LED flash every few ms and then perform a factory reset
|
||||
@@ -313,4 +329,4 @@ void LED::start_led_fast_flash(uint8_t duration) {
|
||||
led_fast_flash_timer_ = true; // it's active
|
||||
}
|
||||
|
||||
} // namespace emsesp
|
||||
} // namespace emsesp
|
||||
+18
-1
@@ -82,7 +82,13 @@ void Network::begin() {
|
||||
WiFi.persistent(false);
|
||||
WiFi.setAutoReconnect(false);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.disconnect(true, true); // wipe old settings in NVS. Will give a warning on boot but can be ignored.
|
||||
|
||||
if (WiFi.STA.started()) {
|
||||
WiFi.disconnect(true, true); // wipe old settings; only when STA is up
|
||||
} else {
|
||||
WiFi.disconnect(true, false); // disconnect/off without erase, so no warning is shown
|
||||
}
|
||||
|
||||
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
|
||||
WiFi.setHostname(hostname_.c_str()); // updates shared default_hostname buffer
|
||||
WiFi.enableSTA(true); // creates the STA netif
|
||||
@@ -539,6 +545,17 @@ void Network::startEthernet() {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
// The Tasmota SDK is built with CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=2, so the Ethernet MAC is derived as
|
||||
// a locally-administered address from base+1 instead of the universal base+3 that Arduino Core 2 used.
|
||||
// Seed the MAC table with the old value before the EMAC driver reads it, so DHCP reservations survive an upgrade.
|
||||
uint8_t eth_mac[6];
|
||||
if (esp_read_mac(eth_mac, ESP_MAC_BASE) == ESP_OK) {
|
||||
eth_mac[5] += 3;
|
||||
esp_iface_mac_addr_set(eth_mac, ESP_MAC_ETH);
|
||||
}
|
||||
*/
|
||||
|
||||
// reset power and add a delay as ETH doesn't not always start up correctly after a warm boot
|
||||
if (eth_power_ != -1) {
|
||||
pinMode(eth_power_, OUTPUT);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define EMSESP_NETWORK_H_
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
#include <esp_mac.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <ETH.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
+17
-4
@@ -93,6 +93,20 @@ uint32_t System::min_free_mem_;
|
||||
std::vector<uint8_t, AllocatorPSRAM<uint8_t>> System::valid_system_gpios_;
|
||||
std::vector<System::GpioUsage, AllocatorPSRAM<System::GpioUsage>> System::used_gpios_;
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
// The DNS slots are shared between IPv4 and IPv6, so with IPv6 enabled the first slot can hold an
|
||||
// IPv6 server. Pick the first IPv4 one so it matches the label we print it under.
|
||||
static IPAddress dns_ipv4(const NetworkInterface & netif) {
|
||||
for (uint8_t i = 0; i < ESP_NETIF_DNS_MAX; i++) {
|
||||
IPAddress ip = netif.dnsIP(i);
|
||||
if (ip.type() == IPv4 && static_cast<uint32_t>(ip) != 0) {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
return IPAddress();
|
||||
}
|
||||
#endif
|
||||
|
||||
// find the index of the language
|
||||
// 0 = EN, 1 = DE, etc...
|
||||
uint8_t System::language_index() {
|
||||
@@ -858,8 +872,7 @@ void System::send_info_mqtt() {
|
||||
doc["MAC"] = WiFi.macAddress();
|
||||
doc["IPv4 address"] = uuid::printable_to_string(WiFi.localIP()) + "/" + uuid::printable_to_string(WiFi.subnetMask());
|
||||
doc["IPv4 gateway"] = uuid::printable_to_string(WiFi.gatewayIP());
|
||||
doc["IPv4 nameserver"] = uuid::printable_to_string(WiFi.dnsIP());
|
||||
|
||||
doc["IPv4 DNS Server"] = uuid::printable_to_string(dns_ipv4(WiFi.STA));
|
||||
if (WiFi.linkLocalIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && WiFi.linkLocalIPv6().toString() != "::") {
|
||||
doc["IPv6 address"] = uuid::printable_to_string(WiFi.linkLocalIPv6());
|
||||
}
|
||||
@@ -1168,7 +1181,7 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
shell.printfln(" Hostname: %s", WiFi.getHostname());
|
||||
shell.printfln(" IPv4 address: %s/%s", uuid::printable_to_string(WiFi.localIP()).c_str(), uuid::printable_to_string(WiFi.subnetMask()).c_str());
|
||||
shell.printfln(" IPv4 gateway: %s", uuid::printable_to_string(WiFi.gatewayIP()).c_str());
|
||||
shell.printfln(" IPv4 nameserver: %s", uuid::printable_to_string(WiFi.dnsIP()).c_str());
|
||||
shell.printfln(" IPv4 DNS Server: %s", uuid::printable_to_string(dns_ipv4(WiFi.STA)).c_str());
|
||||
if (WiFi.linkLocalIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && WiFi.linkLocalIPv6().toString() != "::") {
|
||||
shell.printfln(" IPv6 address: %s", uuid::printable_to_string(WiFi.linkLocalIPv6()).c_str());
|
||||
}
|
||||
@@ -1201,7 +1214,7 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
shell.printfln(" Hostname: %s", ETH.getHostname());
|
||||
shell.printfln(" IPv4 address: %s/%s", uuid::printable_to_string(ETH.localIP()).c_str(), uuid::printable_to_string(ETH.subnetMask()).c_str());
|
||||
shell.printfln(" IPv4 gateway: %s", uuid::printable_to_string(ETH.gatewayIP()).c_str());
|
||||
shell.printfln(" IPv4 nameserver: %s", uuid::printable_to_string(ETH.dnsIP()).c_str());
|
||||
shell.printfln(" IPv4 DNS Server: %s", uuid::printable_to_string(dns_ipv4(ETH)).c_str());
|
||||
if (ETH.linkLocalIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && ETH.linkLocalIPv6().toString() != "::") {
|
||||
shell.printfln(" IPv6 address: %s", uuid::printable_to_string(ETH.linkLocalIPv6()).c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user