mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 17:48:40 +00:00
Merge branch 'rp2040-accept-no-irq-malloc' into integration
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include <esphome/components/sensor/sensor.h>
|
||||
#include <esphome/core/component.h>
|
||||
|
||||
#define BME280_ERROR_WRONG_CHIP_ID "Wrong chip ID"
|
||||
#define BME280_ERROR_WRONG_CHIP_ID "Wrong chip ID or no response"
|
||||
|
||||
namespace esphome {
|
||||
namespace bme280_base {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#define BMP280_ERROR_WRONG_CHIP_ID "Wrong chip ID"
|
||||
#define BMP280_ERROR_WRONG_CHIP_ID "Wrong chip ID or no response"
|
||||
|
||||
namespace esphome {
|
||||
namespace bmp280_base {
|
||||
|
||||
@@ -425,7 +425,7 @@ LWIPRawImpl::~LWIPRawImpl() {
|
||||
// Base class destructor handles pcb_ cleanup via tcp_abort
|
||||
}
|
||||
|
||||
void LWIPRawImpl::init(struct pbuf *initial_rx) {
|
||||
void LWIPRawImpl::init(struct pbuf *initial_rx, bool initial_rx_closed) {
|
||||
LWIP_LOCK();
|
||||
LWIP_LOG("init(%p)", this->pcb_);
|
||||
tcp_arg(this->pcb_, this);
|
||||
@@ -435,6 +435,7 @@ void LWIPRawImpl::init(struct pbuf *initial_rx) {
|
||||
this->rx_buf_ = initial_rx;
|
||||
this->rx_buf_offset_ = 0;
|
||||
}
|
||||
this->rx_closed_ = initial_rx_closed;
|
||||
}
|
||||
|
||||
void LWIPRawImpl::s_err_fn(void *arg, err_t err) {
|
||||
@@ -670,7 +671,7 @@ LWIPRawListenImpl::~LWIPRawListenImpl() {
|
||||
LWIP_LOCK();
|
||||
// Abort any queued PCBs that were never accepted by the main loop.
|
||||
// Clear the error callback first — tcp_abort triggers it, and we don't
|
||||
// want s_accepted_pcb_err_fn writing to slots during destruction.
|
||||
// want s_queued_err_fn writing to slots during destruction.
|
||||
for (uint8_t i = 0; i < this->accepted_socket_count_; i++) {
|
||||
auto &entry = this->accepted_pcbs_[i];
|
||||
if (entry.pcb != nullptr) {
|
||||
@@ -775,11 +776,7 @@ std::unique_ptr<LWIPRawImpl> LWIPRawListenImpl::accept(struct sockaddr *addr, so
|
||||
// Create socket wrapper on the main loop (not in accept callback) to avoid
|
||||
// heap allocation in IRQ context on RP2040. Transfer any data received while queued.
|
||||
auto sock = make_unique<LWIPRawImpl>(this->family_, entry.pcb);
|
||||
sock->init(entry.rx_buf);
|
||||
if (entry.rx_closed) {
|
||||
// Remote closed while queued — mark so read() returns EOF after buffered data
|
||||
sock->rx_closed_ = true;
|
||||
}
|
||||
sock->init(entry.rx_buf, entry.rx_closed);
|
||||
if (addr != nullptr) {
|
||||
sock->getpeername(addr, addrlen);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class LWIPRawImpl : public LWIPRawCommon {
|
||||
using LWIPRawCommon::LWIPRawCommon;
|
||||
~LWIPRawImpl();
|
||||
|
||||
void init(struct pbuf *initial_rx = nullptr);
|
||||
void init(struct pbuf *initial_rx = nullptr, bool initial_rx_closed = false);
|
||||
|
||||
// Non-listening sockets return error
|
||||
std::unique_ptr<LWIPRawImpl> accept(struct sockaddr *, socklen_t *) {
|
||||
@@ -121,8 +121,6 @@ class LWIPRawImpl : public LWIPRawCommon {
|
||||
static void s_err_fn(void *arg, err_t err);
|
||||
static err_t s_recv_fn(void *arg, struct tcp_pcb *pcb, struct pbuf *pb, err_t err);
|
||||
|
||||
friend class LWIPRawListenImpl; // accept() transfers queued rx data
|
||||
|
||||
protected:
|
||||
ssize_t internal_write_(const void *buf, size_t len);
|
||||
int internal_output_();
|
||||
|
||||
Reference in New Issue
Block a user