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;
memset(_buf, 0x00, 16);
#ifdef ESP32
#if ESP_ARDUINO_VERSION_MAJOR < 3
#if ESP_IDF_VERSION_MAJOR < 5
mbedtls_md5_init(&_ctx);
mbedtls_md5_starts_ret(&_ctx);
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.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, "gateway_ip", newSettings.gatewayIP, FACTORY_AP_GATEWAY_IP);
JsonUtils::readIP(root, "subnet_mask", newSettings.subnetMask, FACTORY_AP_SUBNET_MASK);
JsonUtils::readIP(root, "local_ip", newSettings.localIP, String(FACTORY_AP_LOCAL_IP));
JsonUtils::readIP(root, "gateway_ip", newSettings.gatewayIP,String(FACTORY_AP_GATEWAY_IP));
JsonUtils::readIP(root, "subnet_mask", newSettings.subnetMask, String(FACTORY_AP_SUBNET_MASK));
if (newSettings == settings) {
return StateUpdateResult::UNCHANGED;

View File

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

View File

@@ -30,8 +30,12 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
// for both connections show ethernet
if (ethernet_connected) {
// Ethernet
root["local_ip"] = ETH.localIP().toString();
root["local_ipv6"] = ETH.localIPv6().toString();
root["local_ip"] = ETH.localIP().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["subnet_mask"] = ETH.subnetMask().toString();
root["gateway_ip"] = ETH.gatewayIP().toString();
@@ -49,8 +53,13 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
root["dns_ip_2"] = dnsIP2.toString();
}
} else if (wifi_status == WL_CONNECTED) {
root["local_ip"] = WiFi.localIP().toString();
root["local_ipv6"] = WiFi.localIPv6().toString();
root["local_ip"] = WiFi.localIP().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["rssi"] = WiFi.RSSI();
root["ssid"] = WiFi.SSID();