Support ESP8266 Arduino 3.0.0 (#1897)

Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
Stefan Agner 2021-06-15 08:50:58 +02:00 committed by GitHub
parent 92bbedfa5a
commit a80f9ed336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View File

@ -237,7 +237,7 @@ optional<float> FilterOutValueFilter::new_value(float value) {
return value;
} else {
int8_t accuracy = this->parent_->get_accuracy_decimals();
float accuracy_mult = pow10f(accuracy);
float accuracy_mult = powf(10.0f, accuracy);
float rounded_filter_out = roundf(accuracy_mult * this->value_to_filter_out_);
float rounded_value = roundf(accuracy_mult * value);
if (rounded_filter_out == rounded_value)

View File

@ -10,6 +10,10 @@
#include <wpa2_enterprise.h>
#endif
#ifdef WIFI_IS_OFF_AT_BOOT // Identifies ESP8266 Arduino 3.0.0
#define ARDUINO_ESP8266_RELEASE_3
#endif
extern "C" {
#include "lwip/err.h"
#include "lwip/dns.h"
@ -18,6 +22,12 @@ extern "C" {
#if LWIP_IPV6
#include "lwip/netif.h" // struct netif
#endif
#ifdef ARDUINO_ESP8266_RELEASE_3
#include "LwipDhcpServer.h"
#define wifi_softap_set_dhcps_lease(lease) dhcpSoftAP.set_dhcps_lease(lease)
#define wifi_softap_set_dhcps_lease_time(time) dhcpSoftAP.set_dhcps_lease_time(time)
#define wifi_softap_set_dhcps_offer_option(offer, mode) dhcpSoftAP.set_dhcps_offer_option(offer, mode)
#endif
}
#include "esphome/core/helpers.h"
@ -649,6 +659,10 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
return false;
}
#ifdef ARDUINO_ESP8266_RELEASE_3
dhcpSoftAP.begin(&info);
#endif
struct dhcps_lease lease {};
IPAddress start_address = info.ip.addr;
start_address[3] += 99;

View File

@ -28,6 +28,7 @@ ARDUINO_VERSION_ESP32 = {
# See also https://github.com/platformio/platform-espressif8266/releases
ARDUINO_VERSION_ESP8266 = {
"dev": "https://github.com/platformio/platform-espressif8266.git",
"3.0.0": "platformio/espressif8266@3.0.0",
"2.7.4": "platformio/espressif8266@2.6.2",
"2.7.3": "platformio/espressif8266@2.6.1",
"2.7.2": "platformio/espressif8266@2.6.0",

View File

@ -105,7 +105,7 @@ std::string truncate_string(const std::string &s, size_t length) {
}
std::string value_accuracy_to_string(float value, int8_t accuracy_decimals) {
auto multiplier = float(pow10(accuracy_decimals));
auto multiplier = float(powf(10.0f, accuracy_decimals));
float value_rounded = roundf(value * multiplier) / multiplier;
char tmp[32]; // should be enough, but we should maybe improve this at some point.
dtostrf(value_rounded, 0, uint8_t(std::max(0, int(accuracy_decimals))), tmp);