1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-29 00:22:21 +01:00

ESP-IDF support and generic target platforms (#2303)

* Socket refactor and SSL

* esp-idf temp

* Fixes

* Echo component and noise

* Add noise API transport support

* Updates

* ESP-IDF

* Complete

* Fixes

* Fixes

* Versions update

* New i2c APIs

* Complete i2c refactor

* SPI migration

* Revert ESP Preferences migration, too complex for now

* OTA support

* Remove echo again

* Remove ssl again

* GPIOFlags updates

* Rename esphal and ICACHE_RAM_ATTR

* Make ESP32 arduino compilable again

* Fix GPIO flags

* Complete pin registry refactor and fixes

* Fixes to make test1 compile

* Remove sdkconfig file

* Ignore sdkconfig file

* Fixes in reviewing

* Make test2 compile

* Make test4 compile

* Make test5 compile

* Run clang-format

* Fix lint errors

* Use esp-idf APIs instead of btStart

* Another round of fixes

* Start implementing ESP8266

* Make test3 compile

* Guard esp8266 code

* Lint

* Reformat

* Fixes

* Fixes v2

* more fixes

* ESP-IDF tidy target

* Convert ARDUINO_ARCH_ESPxx

* Update WiFiSignalSensor

* Update time ifdefs

* OTA needs millis from hal

* RestartSwitch needs delay from hal

* ESP-IDF Uart

* Fix OTA blank password

* Allow setting sdkconfig

* Fix idf partitions and allow setting sdkconfig from yaml

* Re-add read/write compat APIs and fix esp8266 uart

* Fix esp8266 store log strings in flash

* Fix ESP32 arduino preferences not initialized

* Update ifdefs

* Change how sdkconfig change is detected

* Add checks to ci-custom and fix them

* Run clang-format

* Add esp-idf clang-tidy target and fix errors

* Fixes from clang-tidy idf round 2

* Fixes from compiling tests with esp-idf

* Run clang-format

* Switch test5.yaml to esp-idf

* Implement ESP8266 Preferences

* Lint

* Re-do PIO package version selection a bit

* Fix arduinoespressif32 package version

* Fix unit tests

* Lint

* Lint fixes

* Fix readv/writev not defined

* Fix graphing component

* Re-add all old options from core/config.py

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Otto Winter
2021-09-20 11:47:51 +02:00
committed by GitHub
parent 1e8e471dec
commit ac0d921413
583 changed files with 9008 additions and 5420 deletions

View File

@@ -6,8 +6,9 @@
#include <cstring>
#ifdef ARDUINO_ARCH_ESP32
#ifdef USE_ESP32
#include <esp_idf_version.h>
#include <lwip/sockets.h>
#endif
namespace esphome {
@@ -81,7 +82,7 @@ class BSDSocketImpl : public Socket {
int listen(int backlog) override { return ::listen(fd_, backlog); }
ssize_t read(void *buf, size_t len) override { return ::read(fd_, buf, len); }
ssize_t readv(const struct iovec *iov, int iovcnt) override {
#if defined(ARDUINO_ARCH_ESP32) && ESP_IDF_VERSION_MAJOR < 4
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 4
// esp-idf v3 doesn't have readv, emulate it
ssize_t ret = 0;
for (int i = 0; i < iovcnt; i++) {
@@ -97,6 +98,9 @@ class BSDSocketImpl : public Socket {
break;
}
return ret;
#elif defined(USE_ESP32)
// ESP-IDF v4 only has symbol lwip_readv
return ::lwip_readv(fd_, iov, iovcnt);
#else
return ::readv(fd_, iov, iovcnt);
#endif
@@ -104,7 +108,7 @@ class BSDSocketImpl : public Socket {
ssize_t write(const void *buf, size_t len) override { return ::write(fd_, buf, len); }
ssize_t send(void *buf, size_t len, int flags) { return ::send(fd_, buf, len, flags); }
ssize_t writev(const struct iovec *iov, int iovcnt) override {
#if defined(ARDUINO_ARCH_ESP32) && ESP_IDF_VERSION_MAJOR < 4
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 4
// esp-idf v3 doesn't have writev, emulate it
ssize_t ret = 0;
for (int i = 0; i < iovcnt; i++) {
@@ -121,6 +125,9 @@ class BSDSocketImpl : public Socket {
break;
}
return ret;
#elif defined(USE_ESP32)
// ESP-IDF v4 only has symbol lwip_writev
return ::lwip_writev(fd_, iov, iovcnt);
#else
return ::writev(fd_, iov, iovcnt);
#endif

View File

@@ -86,7 +86,7 @@ struct iovec {
size_t iov_len;
};
#ifdef ARDUINO_ARCH_ESP8266
#ifdef USE_ESP8266
// arduino-esp8266 declares a global vars called INADDR_NONE/ANY which are invalid with the define
#ifdef INADDR_ANY
#undef INADDR_ANY
@@ -97,7 +97,7 @@ struct iovec {
#define ESPHOME_INADDR_ANY ((uint32_t) 0x00000000UL)
#define ESPHOME_INADDR_NONE ((uint32_t) 0xFFFFFFFFUL)
#else // !ARDUINO_ARCH_ESP8266
#else // !USE_ESP8266
#define ESPHOME_INADDR_ANY INADDR_ANY
#define ESPHOME_INADDR_NONE INADDR_NONE
#endif
@@ -114,7 +114,7 @@ struct iovec {
#include <fcntl.h>
#include <stdint.h>
#ifdef ARDUINO_ARCH_ESP32
#ifdef USE_ARDUINO
// arduino-esp32 declares a global var called INADDR_NONE which is replaced
// by the define
#ifdef INADDR_NONE
@@ -125,7 +125,7 @@ typedef uint32_t socklen_t;
#define ESPHOME_INADDR_ANY ((uint32_t) 0x00000000UL)
#define ESPHOME_INADDR_NONE ((uint32_t) 0xFFFFFFFFUL)
#else // !ARDUINO_ARCH_ESP32
#else // !USE_ESP32
#define ESPHOME_INADDR_ANY INADDR_ANY
#define ESPHOME_INADDR_NONE INADDR_NONE
#endif

View File

@@ -11,6 +11,7 @@
#include <cstring>
#include <queue>
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
@@ -492,7 +493,7 @@ class LWIPRawImpl : public Socket {
// nothing to do here, we just don't push it to the queue
return ERR_OK;
}
auto sock = std::unique_ptr<LWIPRawImpl>(new LWIPRawImpl(newpcb));
auto sock = make_unique<LWIPRawImpl>(newpcb);
sock->init();
accepted_sockets_.push(std::move(sock));
return ERR_OK;