Compile with arduino 3.0

This commit is contained in:
MichaelDvP
2024-04-29 13:53:00 +02:00
parent abbf2e091b
commit b034bd05e8
6 changed files with 58 additions and 18 deletions

View File

@@ -76,7 +76,7 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo
return false; return false;
memset(_buf, 0x00, 16); memset(_buf, 0x00, 16);
#ifdef ESP32 #ifdef ESP32
#if ESP_ARDUINO_VERSION_MAJOR < 3 #if ESP_IDF_VERSION_MAJOR < 5
mbedtls_md5_init(&_ctx); mbedtls_md5_init(&_ctx);
mbedtls_md5_starts_ret(&_ctx); mbedtls_md5_starts_ret(&_ctx);
mbedtls_md5_update_ret(&_ctx, data, len); mbedtls_md5_update_ret(&_ctx, data, len);

View File

@@ -148,9 +148,9 @@ StateUpdateResult APSettings::update(JsonObject root, APSettings & settings) {
newSettings.ssidHidden = root["ssid_hidden"] | FACTORY_AP_SSID_HIDDEN; newSettings.ssidHidden = root["ssid_hidden"] | FACTORY_AP_SSID_HIDDEN;
newSettings.maxClients = static_cast<uint8_t>(root["max_clients"] | FACTORY_AP_MAX_CLIENTS); newSettings.maxClients = static_cast<uint8_t>(root["max_clients"] | FACTORY_AP_MAX_CLIENTS);
JsonUtils::readIP(root, "local_ip", newSettings.localIP, FACTORY_AP_LOCAL_IP); JsonUtils::readIP(root, "local_ip", newSettings.localIP, String(FACTORY_AP_LOCAL_IP));
JsonUtils::readIP(root, "gateway_ip", newSettings.gatewayIP, FACTORY_AP_GATEWAY_IP); JsonUtils::readIP(root, "gateway_ip", newSettings.gatewayIP,String(FACTORY_AP_GATEWAY_IP));
JsonUtils::readIP(root, "subnet_mask", newSettings.subnetMask, FACTORY_AP_SUBNET_MASK); JsonUtils::readIP(root, "subnet_mask", newSettings.subnetMask, String(FACTORY_AP_SUBNET_MASK));
if (newSettings == settings) { if (newSettings == settings) {
return StateUpdateResult::UNCHANGED; return StateUpdateResult::UNCHANGED;

View File

@@ -65,12 +65,17 @@ void NetworkSettingsService::loop() {
void NetworkSettingsService::manageSTA() { void NetworkSettingsService::manageSTA() {
// Abort if already connected, or if we have no SSID // Abort if already connected, or if we have no SSID
if (WiFi.isConnected() || _state.ssid.length() == 0) { if (WiFi.isConnected() || _state.ssid.length() == 0) {
#if ESP_IDF_VERSION_MAJOR >= 5
if (_state.ssid.length() == 0) {
ETH.enableIPv6(_state.enableIPv6);
}
#endif
return; return;
} }
// Connect or reconnect as required // Connect or reconnect as required
if ((WiFi.getMode() & WIFI_STA) == 0) { if ((WiFi.getMode() & WIFI_STA) == 0) {
#ifdef TASMOTA_SDK #if ESP_IDF_VERSION_MAJOR >= 5
WiFi.enableIPv6(_state.enableIPv6); WiFi.enableIPv6(_state.enableIPv6);
#endif #endif
if (_state.staticIPConfig) { if (_state.staticIPConfig) {
@@ -352,25 +357,27 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
if (_state.tx_power == 0) { if (_state.tx_power == 0) {
setWiFiPowerOnRSSI(); setWiFiPowerOnRSSI();
} }
#if ESP_IDF_VERSION_MAJOR < 5
if (_state.enableIPv6) { if (_state.enableIPv6) {
WiFi.enableIpV6(); WiFi.enableIpV6();
} }
#endif
break; break;
case ARDUINO_EVENT_ETH_CONNECTED: case ARDUINO_EVENT_ETH_CONNECTED:
#if ESP_IDF_VERSION_MAJOR < 5
if (_state.enableIPv6) { if (_state.enableIPv6) {
ETH.enableIpV6(); ETH.enableIpV6();
} }
#endif
break; break;
// IPv6 specific // IPv6 specific
case ARDUINO_EVENT_WIFI_STA_GOT_IP6: case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
case ARDUINO_EVENT_ETH_GOT_IP6: case ARDUINO_EVENT_ETH_GOT_IP6:
if (emsesp::EMSESP::system_.ethernet_connected()) { emsesp::EMSESP::logger().info("IPv6=%s", IPAddress(IPv6, (uint8_t *)info.got_ip6.ip6_info.ip.addr, 0).toString().c_str());
emsesp::EMSESP::logger().info("Ethernet connected (IPv6=%s, speed %d Mbps)", ETH.localIPv6().toString().c_str(), ETH.linkSpeed());
}
emsesp::EMSESP::system_.has_ipv6(true); emsesp::EMSESP::system_.has_ipv6(true);
break; break;
default: default:
break; break;

View File

@@ -30,8 +30,12 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
// for both connections show ethernet // for both connections show ethernet
if (ethernet_connected) { if (ethernet_connected) {
// Ethernet // Ethernet
root["local_ip"] = ETH.localIP().toString(); root["local_ip"] = ETH.localIP().toString();
root["local_ipv6"] = ETH.localIPv6().toString(); #if ESP_IDF_VERSION_MAJOR < 5
root["local_ipv6"] = ETH.localIPv6().toString();
#else
root["local_ipv6"] = ETH.linkLocalIPv6().toString();
#endif
root["mac_address"] = ETH.macAddress(); root["mac_address"] = ETH.macAddress();
root["subnet_mask"] = ETH.subnetMask().toString(); root["subnet_mask"] = ETH.subnetMask().toString();
root["gateway_ip"] = ETH.gatewayIP().toString(); root["gateway_ip"] = ETH.gatewayIP().toString();
@@ -49,8 +53,13 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
root["dns_ip_2"] = dnsIP2.toString(); root["dns_ip_2"] = dnsIP2.toString();
} }
} else if (wifi_status == WL_CONNECTED) { } else if (wifi_status == WL_CONNECTED) {
root["local_ip"] = WiFi.localIP().toString(); root["local_ip"] = WiFi.localIP().toString();
root["local_ipv6"] = WiFi.localIPv6().toString(); // #if ESP_ARDUINO_VERSION_MAJOR < 3
#if ESP_IDF_VERSION_MAJOR < 5
root["local_ipv6"] = WiFi.localIPv6().toString();
#else
root["local_ipv6"] = WiFi.linkLocalIPv6().toString();
#endif
root["mac_address"] = WiFi.macAddress(); root["mac_address"] = WiFi.macAddress();
root["rssi"] = WiFi.RSSI(); root["rssi"] = WiFi.RSSI();
root["ssid"] = WiFi.SSID(); root["ssid"] = WiFi.SSID();

View File

@@ -198,6 +198,9 @@ platform_packages=
framework = arduino framework = arduino
board = esp32dev board = esp32dev
board_build.filesystem = littlefs board_build.filesystem = littlefs
board_upload.flash_size = 16MB
board_build.partitions = esp32_partition_16M.csv
board_build.extra_flags = -DBOARD_HAS_PSRAM
build_flags = build_flags =
${factory_settings.build_flags} ${factory_settings.build_flags}
${common.my_build_flags} ${common.my_build_flags}

View File

@@ -610,7 +610,7 @@ void System::send_info_mqtt() {
doc["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask()); doc["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask());
doc["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP()); doc["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP());
doc["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP()); doc["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP());
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") { if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && ETH.localIPv6().toString() != "::") {
doc["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6()); doc["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6());
} }
*/ */
@@ -624,9 +624,17 @@ void System::send_info_mqtt() {
doc["IPv4 address"] = uuid::printable_to_string(WiFi.localIP()) + "/" + uuid::printable_to_string(WiFi.subnetMask()); 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 gateway"] = uuid::printable_to_string(WiFi.gatewayIP());
doc["IPv4 nameserver"] = uuid::printable_to_string(WiFi.dnsIP()); doc["IPv4 nameserver"] = uuid::printable_to_string(WiFi.dnsIP());
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
#if ESP_IDF_VERSION_MAJOR < 5
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && WiFi.localIPv6().toString() != "::") {
doc["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6()); doc["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6());
} }
#else
if (WiFi.linkLocalIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && WiFi.linkLocalIPv6().toString() != "::") {
doc["IPv6 address"] = uuid::printable_to_string(WiFi.linkLocalIPv6());
}
#endif
} }
#endif #endif
Mqtt::queue_publish_retain(F_(info), doc.as<JsonObject>(), true); // topic called "info" and it's Retained Mqtt::queue_publish_retain(F_(info), doc.as<JsonObject>(), true); // topic called "info" and it's Retained
@@ -739,7 +747,7 @@ void System::network_init(bool refresh) {
// ETH_CLOCK_GPIO17_OUT = 3 RMII clock output from GPIO17, for 50hz inverted clock // ETH_CLOCK_GPIO17_OUT = 3 RMII clock output from GPIO17, for 50hz inverted clock
auto clock_mode = (eth_clock_mode_t)eth_clock_mode_; auto clock_mode = (eth_clock_mode_t)eth_clock_mode_;
#if ESP_ARDUINO_VERSION_MAJOR < 3 #if ESP_IDF_VERSION_MAJOR < 5
eth_present_ = ETH.begin(phy_addr, power, mdc, mdio, type, clock_mode); eth_present_ = ETH.begin(phy_addr, power, mdc, mdio, type, clock_mode);
#else #else
eth_present_ = ETH.begin(type, phy_addr, mdc, mdio, power, clock_mode); eth_present_ = ETH.begin(type, phy_addr, mdc, mdio, power, clock_mode);
@@ -998,9 +1006,16 @@ void System::show_system(uuid::console::Shell & shell) {
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 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 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 nameserver: %s", uuid::printable_to_string(WiFi.dnsIP()).c_str());
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") { #if ESP_IDF_VERSION_MAJOR < 5
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && WiFi.localIPv6().toString() != "::") {
shell.printfln(" IPv6 address: %s", uuid::printable_to_string(WiFi.localIPv6()).c_str()); shell.printfln(" IPv6 address: %s", uuid::printable_to_string(WiFi.localIPv6()).c_str());
} }
#else
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());
}
#endif
break; break;
case WL_CONNECT_FAILED: case WL_CONNECT_FAILED:
@@ -1031,9 +1046,15 @@ void System::show_system(uuid::console::Shell & shell) {
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 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 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 nameserver: %s", uuid::printable_to_string(ETH.dnsIP()).c_str());
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") { #if ESP_IDF_VERSION_MAJOR < 5
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && ETH.localIPv6().toString() != "::") {
shell.printfln(" IPv6 address: %s", uuid::printable_to_string(ETH.localIPv6()).c_str()); shell.printfln(" IPv6 address: %s", uuid::printable_to_string(ETH.localIPv6()).c_str());
} }
#else
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());
}
#endif
} }
shell.println(); shell.println();