mirror of
https://github.com/esphome/esphome.git
synced 2026-01-26 06:22:08 -07:00
Compare commits
11 Commits
uln2003_lo
...
rp2040_web
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db5a58d71e | ||
|
|
7a2d4cd801 | ||
|
|
7c26047e04 | ||
|
|
539e2a3c90 | ||
|
|
83ae089bad | ||
|
|
39cdedfd89 | ||
|
|
4a453d90ad | ||
|
|
51bf568b8f | ||
|
|
8a0d99285c | ||
|
|
7e456265a4 | ||
|
|
6954a69ed2 |
@@ -1 +1 @@
|
||||
15dc295268b2dcf75942f42759b3ddec64eba89f75525698eb39c95a7f4b14ce
|
||||
c0db7505713f2ebf5d18f274d35469cfbdaabe1e1def9fe2195594dc345f1a49
|
||||
|
||||
@@ -292,7 +292,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
CONF_MAX_CONNECTIONS,
|
||||
esp8266=4, # ~40KB free RAM, each connection uses ~500-1000 bytes
|
||||
esp32=8, # 520KB RAM available
|
||||
rp2040=4, # 264KB RAM but LWIP constraints
|
||||
rp2040=8, # 264KB RAM, plenty of heap available
|
||||
bk72xx=8, # Moderate RAM
|
||||
rtl87xx=8, # Moderate RAM
|
||||
host=8, # Abundant resources
|
||||
|
||||
@@ -38,8 +38,10 @@ async def to_code(config):
|
||||
# https://github.com/ESP32Async/ESPAsyncTCP
|
||||
cg.add_library("ESP32Async/ESPAsyncTCP", "2.0.0")
|
||||
elif CORE.is_rp2040:
|
||||
# https://github.com/khoih-prog/AsyncTCP_RP2040W
|
||||
cg.add_library("khoih-prog/AsyncTCP_RP2040W", "1.2.0")
|
||||
# https://github.com/ayushsharma82/RPAsyncTCP
|
||||
# RPAsyncTCP is a drop-in replacement for AsyncTCP_RP2040W with better
|
||||
# ESPAsyncWebServer compatibility
|
||||
cg.add_library("ayushsharma82/RPAsyncTCP", "1.3.2")
|
||||
# Other platforms (host, etc) use socket-based implementation
|
||||
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
// Use ESPAsyncTCP library for ESP8266 (always Arduino)
|
||||
#include <ESPAsyncTCP.h>
|
||||
#elif defined(USE_RP2040)
|
||||
// Use AsyncTCP_RP2040W library for RP2040
|
||||
#include <AsyncTCP_RP2040W.h>
|
||||
// Use RPAsyncTCP library for RP2040
|
||||
#include <RPAsyncTCP.h>
|
||||
#else
|
||||
// Use socket-based implementation for other platforms
|
||||
#include "async_tcp_socket.h"
|
||||
|
||||
@@ -13,6 +13,7 @@ from esphome.const import (
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
PlatformFramework,
|
||||
)
|
||||
@@ -53,6 +54,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
@@ -106,6 +108,8 @@ async def to_code(config):
|
||||
cg.add_library("DNSServer", None)
|
||||
if CORE.is_libretiny:
|
||||
cg.add_library("DNSServer", None)
|
||||
if CORE.is_rp2040:
|
||||
cg.add_library("DNSServer", None)
|
||||
|
||||
|
||||
# Only compile the ESP-IDF DNS server when using ESP-IDF framework
|
||||
|
||||
@@ -12,7 +12,6 @@ from esphome.const import (
|
||||
KEY_FRAMEWORK_VERSION,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
from esphome.cpp_generator import add_define
|
||||
|
||||
CODEOWNERS = ["@swoboda1337"]
|
||||
|
||||
@@ -43,7 +42,6 @@ CONFIG_SCHEMA = cv.All(
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
add_define("USE_ESP32_HOSTED")
|
||||
if config[CONF_ACTIVE_HIGH]:
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
"CONFIG_ESP_HOSTED_SDIO_RESET_ACTIVE_HIGH",
|
||||
|
||||
@@ -155,9 +155,6 @@ void MHZ19Component::dump_config() {
|
||||
case MHZ19_DETECTION_RANGE_0_10000PPM:
|
||||
range_str = "0 to 10000ppm";
|
||||
break;
|
||||
default:
|
||||
range_str = "default";
|
||||
break;
|
||||
}
|
||||
ESP_LOGCONFIG(TAG, " Detection range: %s", range_str);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
#include "uln2003.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome::uln2003 {
|
||||
namespace esphome {
|
||||
namespace uln2003 {
|
||||
|
||||
static const char *const TAG = "uln2003.stepper";
|
||||
|
||||
static const LogString *step_mode_to_log_string(ULN2003StepMode mode) {
|
||||
switch (mode) {
|
||||
case ULN2003_STEP_MODE_FULL_STEP:
|
||||
return LOG_STR("FULL STEP");
|
||||
case ULN2003_STEP_MODE_HALF_STEP:
|
||||
return LOG_STR("HALF STEP");
|
||||
case ULN2003_STEP_MODE_WAVE_DRIVE:
|
||||
return LOG_STR("WAVE DRIVE");
|
||||
default:
|
||||
return LOG_STR("UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
void ULN2003::setup() {
|
||||
this->pin_a_->setup();
|
||||
this->pin_b_->setup();
|
||||
@@ -54,7 +42,22 @@ void ULN2003::dump_config() {
|
||||
LOG_PIN(" Pin B: ", this->pin_b_);
|
||||
LOG_PIN(" Pin C: ", this->pin_c_);
|
||||
LOG_PIN(" Pin D: ", this->pin_d_);
|
||||
ESP_LOGCONFIG(TAG, " Step Mode: %s", LOG_STR_ARG(step_mode_to_log_string(this->step_mode_)));
|
||||
const char *step_mode_s;
|
||||
switch (this->step_mode_) {
|
||||
case ULN2003_STEP_MODE_FULL_STEP:
|
||||
step_mode_s = "FULL STEP";
|
||||
break;
|
||||
case ULN2003_STEP_MODE_HALF_STEP:
|
||||
step_mode_s = "HALF STEP";
|
||||
break;
|
||||
case ULN2003_STEP_MODE_WAVE_DRIVE:
|
||||
step_mode_s = "WAVE DRIVE";
|
||||
break;
|
||||
default:
|
||||
step_mode_s = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
ESP_LOGCONFIG(TAG, " Step Mode: %s", step_mode_s);
|
||||
}
|
||||
void ULN2003::write_step_(int32_t step) {
|
||||
int32_t n = this->step_mode_ == ULN2003_STEP_MODE_HALF_STEP ? 8 : 4;
|
||||
@@ -87,4 +90,5 @@ void ULN2003::write_step_(int32_t step) {
|
||||
this->pin_d_->digital_write((res >> 3) & 1);
|
||||
}
|
||||
|
||||
} // namespace esphome::uln2003
|
||||
} // namespace uln2003
|
||||
} // namespace esphome
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/components/stepper/stepper.h"
|
||||
|
||||
namespace esphome::uln2003 {
|
||||
namespace esphome {
|
||||
namespace uln2003 {
|
||||
|
||||
enum ULN2003StepMode {
|
||||
ULN2003_STEP_MODE_FULL_STEP,
|
||||
@@ -39,4 +40,5 @@ class ULN2003 : public stepper::Stepper, public Component {
|
||||
int32_t current_uln_pos_{0};
|
||||
};
|
||||
|
||||
} // namespace esphome::uln2003
|
||||
} // namespace uln2003
|
||||
} // namespace esphome
|
||||
|
||||
@@ -31,6 +31,7 @@ from esphome.const import (
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
)
|
||||
from esphome.core import CORE, CoroPriority, coroutine_with_priority
|
||||
@@ -213,6 +214,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
|
||||
@@ -47,5 +47,10 @@ async def to_code(config):
|
||||
cg.add_library("ESP8266WiFi", None)
|
||||
if CORE.is_libretiny:
|
||||
CORE.add_platformio_option("lib_ignore", ["ESPAsyncTCP", "RPAsyncTCP"])
|
||||
if CORE.is_rp2040:
|
||||
# Ignore bundled AsyncTCP libraries - we use RPAsyncTCP from async_tcp component
|
||||
CORE.add_platformio_option(
|
||||
"lib_ignore", ["ESPAsyncTCP", "AsyncTCP", "AsyncTCP_RP2040W"]
|
||||
)
|
||||
# https://github.com/ESP32Async/ESPAsyncWebServer/blob/main/library.json
|
||||
cg.add_library("ESP32Async/ESPAsyncWebServer", "3.7.10")
|
||||
cg.add_library("ESP32Async/ESPAsyncWebServer", "3.9.5")
|
||||
|
||||
@@ -698,10 +698,6 @@ bool WiFiComponent::wifi_scan_start_(bool passive) {
|
||||
if (!this->wifi_mode_(true, {}))
|
||||
return false;
|
||||
|
||||
// Reset scan_done_ before starting new scan to prevent stale flag from previous scan
|
||||
// (e.g., roaming scan completed just before unexpected disconnect)
|
||||
this->scan_done_ = false;
|
||||
|
||||
struct scan_config config {};
|
||||
memset(&config, 0, sizeof(config));
|
||||
config.ssid = nullptr;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
#if (ESP_IDF_VERSION_MAJOR >= 5) && (ESP_IDF_VERSION_MINOR >= 1)
|
||||
@@ -829,29 +828,16 @@ void WiFiComponent::wifi_process_event_(IDFWiFiEvent *data) {
|
||||
|
||||
uint16_t number = it.number;
|
||||
scan_result_.init(number);
|
||||
#ifdef USE_ESP32_HOSTED
|
||||
// getting records one at a time fails on P4 with hosted esp32 WiFi coprocessor
|
||||
// Presumably an upstream bug, work-around by getting all records at once
|
||||
auto records = std::make_unique<wifi_ap_record_t[]>(number);
|
||||
err = esp_wifi_scan_get_ap_records(&number, records.get());
|
||||
if (err != ESP_OK) {
|
||||
esp_wifi_clear_ap_list();
|
||||
ESP_LOGW(TAG, "esp_wifi_scan_get_ap_records failed: %s", esp_err_to_name(err));
|
||||
return;
|
||||
}
|
||||
for (uint16_t i = 0; i < number; i++) {
|
||||
wifi_ap_record_t &record = records[i];
|
||||
#else
|
||||
|
||||
// Process one record at a time to avoid large buffer allocation
|
||||
wifi_ap_record_t record;
|
||||
for (uint16_t i = 0; i < number; i++) {
|
||||
wifi_ap_record_t record;
|
||||
err = esp_wifi_scan_get_ap_record(&record);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "esp_wifi_scan_get_ap_record failed: %s", esp_err_to_name(err));
|
||||
esp_wifi_clear_ap_list(); // Free remaining records not yet retrieved
|
||||
break;
|
||||
}
|
||||
#endif // USE_ESP32_HOSTED
|
||||
bssid_t bssid;
|
||||
std::copy(record.bssid, record.bssid + 6, bssid.begin());
|
||||
std::string ssid(reinterpret_cast<const char *>(record.ssid));
|
||||
|
||||
@@ -649,10 +649,6 @@ bool WiFiComponent::wifi_scan_start_(bool passive) {
|
||||
if (!this->wifi_mode_(true, {}))
|
||||
return false;
|
||||
|
||||
// Reset scan_done_ before starting new scan to prevent stale flag from previous scan
|
||||
// (e.g., roaming scan completed just before unexpected disconnect)
|
||||
this->scan_done_ = false;
|
||||
|
||||
// need to use WiFi because of WiFiScanClass allocations :(
|
||||
int16_t err = WiFi.scanNetworks(true, true, passive, 200);
|
||||
if (err != WIFI_SCAN_RUNNING) {
|
||||
|
||||
@@ -88,6 +88,8 @@ bool WiFiComponent::wifi_sta_pre_setup_() { return this->wifi_mode_(true, {}); }
|
||||
|
||||
bool WiFiComponent::wifi_sta_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||
if (!manual_ip.has_value()) {
|
||||
// Explicitly enable DHCP by passing all zeros - this resets any previous static IP config
|
||||
WiFi.config(IPAddress(0, 0, 0, 0), IPAddress(0, 0, 0, 0), IPAddress(0, 0, 0, 0), IPAddress(0, 0, 0, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -161,19 +163,18 @@ bool WiFiComponent::wifi_scan_start_(bool passive) {
|
||||
|
||||
#ifdef USE_WIFI_AP
|
||||
bool WiFiComponent::wifi_ap_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||
esphome::network::IPAddress ip_address, gateway, subnet, dns;
|
||||
IPAddress ip_address, gateway, subnet;
|
||||
if (manual_ip.has_value()) {
|
||||
ip_address = manual_ip->static_ip;
|
||||
gateway = manual_ip->gateway;
|
||||
subnet = manual_ip->subnet;
|
||||
dns = manual_ip->static_ip;
|
||||
ip_address = IPAddress(manual_ip->static_ip);
|
||||
gateway = IPAddress(manual_ip->gateway);
|
||||
subnet = IPAddress(manual_ip->subnet);
|
||||
} else {
|
||||
ip_address = network::IPAddress(192, 168, 4, 1);
|
||||
gateway = network::IPAddress(192, 168, 4, 1);
|
||||
subnet = network::IPAddress(255, 255, 255, 0);
|
||||
dns = network::IPAddress(192, 168, 4, 1);
|
||||
ip_address = IPAddress(192, 168, 4, 1);
|
||||
gateway = IPAddress(192, 168, 4, 1);
|
||||
subnet = IPAddress(255, 255, 255, 0);
|
||||
}
|
||||
WiFi.config(ip_address, dns, gateway, subnet);
|
||||
// Use softAPConfig for AP mode - WiFi.config() would disable DHCP for STA mode
|
||||
WiFi.softAPConfig(ip_address, gateway, subnet);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -192,12 +193,16 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
||||
}
|
||||
#endif
|
||||
|
||||
WiFi.beginAP(ap.get_ssid().c_str(), ap.get_password().c_str(), ap.has_channel() ? ap.get_channel() : 1);
|
||||
const char *password = ap.get_password().empty() ? nullptr : ap.get_password().c_str();
|
||||
WiFi.beginAP(ap.get_ssid().c_str(), password, ap.has_channel() ? ap.get_channel() : 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
network::IPAddress WiFiComponent::wifi_soft_ap_ip() { return {(const ip_addr_t *) WiFi.localIP()}; }
|
||||
network::IPAddress WiFiComponent::wifi_soft_ap_ip() {
|
||||
struct netif *ap_netif = &cyw43_state.netif[CYW43_ITF_AP];
|
||||
return {&ap_netif->ip_addr};
|
||||
}
|
||||
#endif // USE_WIFI_AP
|
||||
|
||||
bool WiFiComponent::wifi_disconnect_() {
|
||||
@@ -229,20 +234,29 @@ network::IPAddresses WiFiComponent::wifi_sta_ip_addresses() {
|
||||
network::IPAddresses addresses;
|
||||
uint8_t index = 0;
|
||||
for (auto addr : addrList) {
|
||||
addresses[index++] = addr.ipFromNetifNum();
|
||||
// Only include addresses from the STA interface (CYW43_ITF_STA = 0)
|
||||
if (addr.ifnumber() == CYW43_ITF_STA) {
|
||||
addresses[index++] = addr.ipFromNetifNum();
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
network::IPAddress WiFiComponent::wifi_subnet_mask_() { return {(const ip_addr_t *) WiFi.subnetMask()}; }
|
||||
network::IPAddress WiFiComponent::wifi_gateway_ip_() { return {(const ip_addr_t *) WiFi.gatewayIP()}; }
|
||||
network::IPAddress WiFiComponent::wifi_subnet_mask_() {
|
||||
struct netif *sta_netif = &cyw43_state.netif[CYW43_ITF_STA];
|
||||
return {&sta_netif->netmask};
|
||||
}
|
||||
network::IPAddress WiFiComponent::wifi_gateway_ip_() {
|
||||
struct netif *sta_netif = &cyw43_state.netif[CYW43_ITF_STA];
|
||||
return {&sta_netif->gw};
|
||||
}
|
||||
network::IPAddress WiFiComponent::wifi_dns_ip_(int num) {
|
||||
const ip_addr_t *dns_ip = dns_getserver(num);
|
||||
return network::IPAddress(dns_ip);
|
||||
}
|
||||
|
||||
void WiFiComponent::wifi_loop_() {
|
||||
// Handle scan completion
|
||||
if (this->state_ == WIFI_COMPONENT_STATE_STA_SCANNING && !cyw43_wifi_scan_active(&cyw43_state)) {
|
||||
// Handle scan completion - only process once when scan finishes
|
||||
if (this->state_ == WIFI_COMPONENT_STATE_STA_SCANNING && !this->scan_done_ && !cyw43_wifi_scan_active(&cyw43_state)) {
|
||||
this->scan_done_ = true;
|
||||
ESP_LOGV(TAG, "Scan done");
|
||||
#ifdef USE_WIFI_SCAN_RESULTS_LISTENERS
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#define USE_DEVICES
|
||||
#define USE_DISPLAY
|
||||
#define USE_ENTITY_ICON
|
||||
#define USE_ESP32_HOSTED
|
||||
#define USE_ESP32_IMPROV_STATE_CALLBACK
|
||||
#define USE_EVENT
|
||||
#define USE_FAN
|
||||
|
||||
@@ -114,7 +114,7 @@ lib_deps =
|
||||
ESP8266WiFi ; wifi (Arduino built-in)
|
||||
Update ; ota (Arduino built-in)
|
||||
ESP32Async/ESPAsyncTCP@2.0.0 ; async_tcp
|
||||
ESP32Async/ESPAsyncWebServer@3.7.8 ; web_server_base
|
||||
ESP32Async/ESPAsyncWebServer@3.9.5 ; web_server_base
|
||||
makuna/NeoPixelBus@2.7.3 ; neopixelbus
|
||||
ESP8266HTTPClient ; http_request (Arduino built-in)
|
||||
ESP8266mDNS ; mdns (Arduino built-in)
|
||||
@@ -200,8 +200,9 @@ platform_packages =
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
${common:arduino.lib_deps}
|
||||
ayushsharma82/RPAsyncTCP@1.3.2 ; async_tcp
|
||||
bblanchon/ArduinoJson@7.4.2 ; json
|
||||
ESP32Async/ESPAsyncWebServer@3.7.8 ; web_server_base
|
||||
ESP32Async/ESPAsyncWebServer@3.9.5 ; web_server_base
|
||||
build_flags =
|
||||
${common:arduino.build_flags}
|
||||
-DUSE_RP2040
|
||||
@@ -217,7 +218,7 @@ framework = arduino
|
||||
lib_compat_mode = soft
|
||||
lib_deps =
|
||||
bblanchon/ArduinoJson@7.4.2 ; json
|
||||
ESP32Async/ESPAsyncWebServer@3.7.8 ; web_server_base
|
||||
ESP32Async/ESPAsyncWebServer@3.9.5 ; web_server_base
|
||||
droscy/esp_wireguard@0.4.2 ; wireguard
|
||||
build_flags =
|
||||
${common:arduino.build_flags}
|
||||
|
||||
1
tests/components/captive_portal/test.rp2040-ard.yaml
Normal file
1
tests/components/captive_portal/test.rp2040-ard.yaml
Normal file
@@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
||||
1
tests/components/web_server/test.rp2040-ard.yaml
Normal file
1
tests/components/web_server/test.rp2040-ard.yaml
Normal file
@@ -0,0 +1 @@
|
||||
<<: !include common_v2.yaml
|
||||
Reference in New Issue
Block a user