From 95e0d0219d8c592dc947edad6858a32a298a06f7 Mon Sep 17 00:00:00 2001 From: NP v/d Spek Date: Sun, 28 Jul 2024 15:14:35 +0200 Subject: [PATCH] wip checking crash issue --- esphome/components/espnow/espnow.cpp | 6 ++++-- esphome/components/espnow/espnow.h | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/esphome/components/espnow/espnow.cpp b/esphome/components/espnow/espnow.cpp index 3b1c44347d..885f2b2607 100644 --- a/esphome/components/espnow/espnow.cpp +++ b/esphome/components/espnow/espnow.cpp @@ -53,8 +53,10 @@ ESPNowPackage::ESPNowPackage(const uint64_t mac_address, const std::vectordata_.resize(len); - std::copy_n(data, len, this->data_.begin()); + this->mac_address_ = mac_address; + this->data_.clear(); + // this->data_.insert(this->data_.begin(), len, *data) + // std::copy_n(data, len, this->data_.begin()); } ESPNowComponent::ESPNowComponent() { global_esp_now = this; } diff --git a/esphome/components/espnow/espnow.h b/esphome/components/espnow/espnow.h index c18a09ed0e..795cae4c2a 100644 --- a/esphome/components/espnow/espnow.h +++ b/esphome/components/espnow/espnow.h @@ -137,12 +137,13 @@ class ESPNowComponent : public Component { void set_wifi_channel(uint8_t channel) { this->wifi_channel_ = channel; } ESPNowPackage *send_package(const uint64_t mac_address, const uint8_t *data, int len) { - auto package = new ESPNowPackage(mac_address, data, len); - return this->send_package(package); + // ESPNowPackage * package = new ESPNowPackage(mac_address, data, len); + // return this->send_package(package); + return nullptr; } ESPNowPackage *send_package(const uint64_t mac_address, const std::vector data) { - auto package = new ESPNowPackage(mac_address, data); + ESPNowPackage *package = new ESPNowPackage(mac_address, data); return this->send_package(package); }