mirror of
https://github.com/esphome/esphome.git
synced 2024-12-27 17:28:01 +01:00
commit
6433a01e07
@ -98,19 +98,20 @@ bool BLEServer::create_device_characteristics_() {
|
||||
return true;
|
||||
}
|
||||
|
||||
BLEService *BLEServer::create_service(const uint8_t *uuid, bool advertise) {
|
||||
std::shared_ptr<BLEService> BLEServer::create_service(const uint8_t *uuid, bool advertise) {
|
||||
return this->create_service(ESPBTUUID::from_raw(uuid), advertise);
|
||||
}
|
||||
BLEService *BLEServer::create_service(uint16_t uuid, bool advertise) {
|
||||
std::shared_ptr<BLEService> BLEServer::create_service(uint16_t uuid, bool advertise) {
|
||||
return this->create_service(ESPBTUUID::from_uint16(uuid), advertise);
|
||||
}
|
||||
BLEService *BLEServer::create_service(const std::string &uuid, bool advertise) {
|
||||
std::shared_ptr<BLEService> BLEServer::create_service(const std::string &uuid, bool advertise) {
|
||||
return this->create_service(ESPBTUUID::from_raw(uuid), advertise);
|
||||
}
|
||||
BLEService *BLEServer::create_service(ESPBTUUID uuid, bool advertise, uint16_t num_handles, uint8_t inst_id) {
|
||||
std::shared_ptr<BLEService> BLEServer::create_service(ESPBTUUID uuid, bool advertise, uint16_t num_handles,
|
||||
uint8_t inst_id) {
|
||||
ESP_LOGV(TAG, "Creating service - %s", uuid.to_string().c_str());
|
||||
BLEService *service = new BLEService(uuid, num_handles, inst_id); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
this->services_.push_back(service);
|
||||
std::shared_ptr<BLEService> service = std::make_shared<BLEService>(uuid, num_handles, inst_id);
|
||||
this->services_.emplace_back(service);
|
||||
if (advertise) {
|
||||
esp32_ble::global_ble->get_advertising()->add_service_uuid(uuid);
|
||||
}
|
||||
@ -149,12 +150,12 @@ void BLEServer::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t ga
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto *service : this->services_) {
|
||||
for (const auto &service : this->services_) {
|
||||
service->gatts_event_handler(event, gatts_if, param);
|
||||
}
|
||||
}
|
||||
|
||||
float BLEServer::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; }
|
||||
float BLEServer::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH + 10; }
|
||||
|
||||
void BLEServer::dump_config() { ESP_LOGCONFIG(TAG, "ESP32 BLE Server:"); }
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "esphome/core/preferences.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
@ -43,10 +44,11 @@ class BLEServer : public Component {
|
||||
void set_manufacturer(const std::string &manufacturer) { this->manufacturer_ = manufacturer; }
|
||||
void set_model(const std::string &model) { this->model_ = model; }
|
||||
|
||||
BLEService *create_service(const uint8_t *uuid, bool advertise = false);
|
||||
BLEService *create_service(uint16_t uuid, bool advertise = false);
|
||||
BLEService *create_service(const std::string &uuid, bool advertise = false);
|
||||
BLEService *create_service(ESPBTUUID uuid, bool advertise = false, uint16_t num_handles = 15, uint8_t inst_id = 0);
|
||||
std::shared_ptr<BLEService> create_service(const uint8_t *uuid, bool advertise = false);
|
||||
std::shared_ptr<BLEService> create_service(uint16_t uuid, bool advertise = false);
|
||||
std::shared_ptr<BLEService> create_service(const std::string &uuid, bool advertise = false);
|
||||
std::shared_ptr<BLEService> create_service(ESPBTUUID uuid, bool advertise = false, uint16_t num_handles = 15,
|
||||
uint8_t inst_id = 0);
|
||||
|
||||
esp_gatt_if_t get_gatts_if() { return this->gatts_if_; }
|
||||
uint32_t get_connected_client_count() { return this->connected_clients_; }
|
||||
@ -74,8 +76,8 @@ class BLEServer : public Component {
|
||||
uint32_t connected_clients_{0};
|
||||
std::map<uint16_t, void *> clients_;
|
||||
|
||||
std::vector<BLEService *> services_;
|
||||
BLEService *device_information_service_;
|
||||
std::vector<std::shared_ptr<BLEService>> services_;
|
||||
std::shared_ptr<BLEService> device_information_service_;
|
||||
|
||||
std::vector<BLEServiceComponent *> service_components_;
|
||||
|
||||
|
@ -48,7 +48,7 @@ class ESP32ImprovComponent : public Component, public BLEServiceComponent {
|
||||
std::vector<uint8_t> incoming_data_;
|
||||
wifi::WiFiAP connecting_sta_;
|
||||
|
||||
BLEService *service_;
|
||||
std::shared_ptr<BLEService> service_;
|
||||
BLECharacteristic *status_;
|
||||
BLECharacteristic *error_;
|
||||
BLECharacteristic *rpc_;
|
||||
|
@ -33,7 +33,7 @@ void NextionBinarySensor::update() {
|
||||
if (this->variable_name_.empty()) // This is a touch component
|
||||
return;
|
||||
|
||||
this->nextion_->add_to_get_queue(shared_from_this());
|
||||
this->nextion_->add_to_get_queue(this);
|
||||
}
|
||||
|
||||
void NextionBinarySensor::set_state(bool state, bool publish, bool send_to_nextion) {
|
||||
@ -48,7 +48,7 @@ void NextionBinarySensor::set_state(bool state, bool publish, bool send_to_nexti
|
||||
this->needs_to_send_update_ = true;
|
||||
} else {
|
||||
this->needs_to_send_update_ = false;
|
||||
this->nextion_->add_no_result_to_queue_with_set(shared_from_this(), (int) state);
|
||||
this->nextion_->add_no_result_to_queue_with_set(this, (int) state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,7 @@ class NextionBinarySensor;
|
||||
|
||||
class NextionBinarySensor : public NextionComponent,
|
||||
public binary_sensor::BinarySensorInitiallyOff,
|
||||
public PollingComponent,
|
||||
public std::enable_shared_from_this<NextionBinarySensor> {
|
||||
public PollingComponent {
|
||||
public:
|
||||
NextionBinarySensor(NextionBase *nextion) { this->nextion_ = nextion; }
|
||||
|
||||
|
@ -196,7 +196,7 @@ void Nextion::print_queue_members_() {
|
||||
ESP_LOGN(TAG, "print_queue_members_ (top 10) size %zu", this->nextion_queue_.size());
|
||||
ESP_LOGN(TAG, "*******************************************");
|
||||
int count = 0;
|
||||
for (auto &i : this->nextion_queue_) {
|
||||
for (auto *i : this->nextion_queue_) {
|
||||
if (count++ == 10)
|
||||
break;
|
||||
|
||||
@ -257,9 +257,8 @@ bool Nextion::remove_from_q_(bool report_empty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto nb = std::move(this->nextion_queue_.front());
|
||||
this->nextion_queue_.pop_front();
|
||||
auto &component = nb->component;
|
||||
NextionQueue *nb = this->nextion_queue_.front();
|
||||
NextionComponentBase *component = nb->component;
|
||||
|
||||
ESP_LOGN(TAG, "Removing %s from the queue", component->get_variable_name().c_str());
|
||||
|
||||
@ -267,8 +266,10 @@ bool Nextion::remove_from_q_(bool report_empty) {
|
||||
if (component->get_variable_name() == "sleep_wake") {
|
||||
this->is_sleeping_ = false;
|
||||
}
|
||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
}
|
||||
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
this->nextion_queue_.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -357,7 +358,7 @@ void Nextion::process_nextion_commands_() {
|
||||
int index = 0;
|
||||
int found = -1;
|
||||
for (auto &nb : this->nextion_queue_) {
|
||||
auto &component = nb->component;
|
||||
NextionComponentBase *component = nb->component;
|
||||
|
||||
if (component->get_queue_type() == NextionQueueType::WAVEFORM_SENSOR) {
|
||||
ESP_LOGW(TAG, "Nextion reported invalid Waveform ID %d or Channel # %d was used!",
|
||||
@ -368,6 +369,9 @@ void Nextion::process_nextion_commands_() {
|
||||
|
||||
found = index;
|
||||
|
||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
|
||||
break;
|
||||
}
|
||||
++index;
|
||||
@ -464,9 +468,8 @@ void Nextion::process_nextion_commands_() {
|
||||
break;
|
||||
}
|
||||
|
||||
auto nb = std::move(this->nextion_queue_.front());
|
||||
this->nextion_queue_.pop_front();
|
||||
auto &component = nb->component;
|
||||
NextionQueue *nb = this->nextion_queue_.front();
|
||||
NextionComponentBase *component = nb->component;
|
||||
|
||||
if (component->get_queue_type() != NextionQueueType::TEXT_SENSOR) {
|
||||
ESP_LOGE(TAG, "ERROR: Received string return but next in queue \"%s\" is not a text sensor",
|
||||
@ -477,6 +480,9 @@ void Nextion::process_nextion_commands_() {
|
||||
component->set_state_from_string(to_process, true, false);
|
||||
}
|
||||
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
this->nextion_queue_.pop_front();
|
||||
|
||||
break;
|
||||
}
|
||||
// 0x71 0x01 0x02 0x03 0x04 0xFF 0xFF 0xFF
|
||||
@ -505,9 +511,8 @@ void Nextion::process_nextion_commands_() {
|
||||
++dataindex;
|
||||
}
|
||||
|
||||
auto nb = std::move(this->nextion_queue_.front());
|
||||
this->nextion_queue_.pop_front();
|
||||
auto &component = nb->component;
|
||||
NextionQueue *nb = this->nextion_queue_.front();
|
||||
NextionComponentBase *component = nb->component;
|
||||
|
||||
if (component->get_queue_type() != NextionQueueType::SENSOR &&
|
||||
component->get_queue_type() != NextionQueueType::BINARY_SENSOR &&
|
||||
@ -521,6 +526,9 @@ void Nextion::process_nextion_commands_() {
|
||||
component->set_state_from_int(value, true, false);
|
||||
}
|
||||
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
this->nextion_queue_.pop_front();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -682,7 +690,7 @@ void Nextion::process_nextion_commands_() {
|
||||
int index = 0;
|
||||
int found = -1;
|
||||
for (auto &nb : this->nextion_queue_) {
|
||||
auto &component = nb->component;
|
||||
auto component = nb->component;
|
||||
if (component->get_queue_type() == NextionQueueType::WAVEFORM_SENSOR) {
|
||||
size_t buffer_to_send = component->get_wave_buffer().size() < 255 ? component->get_wave_buffer().size()
|
||||
: 255; // ADDT command can only send 255
|
||||
@ -699,6 +707,8 @@ void Nextion::process_nextion_commands_() {
|
||||
component->get_wave_buffer().begin() + buffer_to_send);
|
||||
}
|
||||
found = index;
|
||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
break;
|
||||
}
|
||||
++index;
|
||||
@ -727,7 +737,7 @@ void Nextion::process_nextion_commands_() {
|
||||
|
||||
if (!this->nextion_queue_.empty() && this->nextion_queue_.front()->queue_time + this->max_q_age_ms_ < ms) {
|
||||
for (int i = 0; i < this->nextion_queue_.size(); i++) {
|
||||
auto &component = this->nextion_queue_[i]->component;
|
||||
NextionComponentBase *component = this->nextion_queue_[i]->component;
|
||||
if (this->nextion_queue_[i]->queue_time + this->max_q_age_ms_ < ms) {
|
||||
if (this->nextion_queue_[i]->queue_time == 0)
|
||||
ESP_LOGD(TAG, "Removing old queue type \"%s\" name \"%s\" queue_time 0",
|
||||
@ -744,8 +754,11 @@ void Nextion::process_nextion_commands_() {
|
||||
if (component->get_variable_name() == "sleep_wake") {
|
||||
this->is_sleeping_ = false;
|
||||
}
|
||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
}
|
||||
|
||||
delete this->nextion_queue_[i]; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
|
||||
this->nextion_queue_.erase(this->nextion_queue_.begin() + i);
|
||||
i--;
|
||||
|
||||
@ -899,16 +912,18 @@ uint16_t Nextion::recv_ret_string_(std::string &response, uint32_t timeout, bool
|
||||
* @param variable_name Name for the queue
|
||||
*/
|
||||
void Nextion::add_no_result_to_queue_(const std::string &variable_name) {
|
||||
auto nextion_queue = make_unique<nextion::NextionQueue>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
|
||||
nextion_queue->component = make_unique<nextion::NextionComponentBase>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion_queue->component = new nextion::NextionComponentBase;
|
||||
nextion_queue->component->set_variable_name(variable_name);
|
||||
|
||||
nextion_queue->queue_time = millis();
|
||||
|
||||
ESP_LOGN(TAG, "Add to queue type: NORESULT component %s", nextion_queue->component->get_variable_name().c_str());
|
||||
this->nextion_queue_.push_back(nextion_queue);
|
||||
|
||||
this->nextion_queue_.push_back(std::move(nextion_queue));
|
||||
ESP_LOGN(TAG, "Add to queue type: NORESULT component %s", nextion_queue->component->get_variable_name().c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -979,7 +994,7 @@ bool Nextion::add_no_result_to_queue_with_printf_(const std::string &variable_na
|
||||
* @param is_sleep_safe The command is safe to send when the Nextion is sleeping
|
||||
*/
|
||||
|
||||
void Nextion::add_no_result_to_queue_with_set(std::shared_ptr<NextionComponentBase> component, int state_value) {
|
||||
void Nextion::add_no_result_to_queue_with_set(NextionComponentBase *component, int state_value) {
|
||||
this->add_no_result_to_queue_with_set(component->get_variable_name(), component->get_variable_name_to_send(),
|
||||
state_value);
|
||||
}
|
||||
@ -1007,8 +1022,7 @@ void Nextion::add_no_result_to_queue_with_set_internal_(const std::string &varia
|
||||
* @param state_value String value to set
|
||||
* @param is_sleep_safe The command is safe to send when the Nextion is sleeping
|
||||
*/
|
||||
void Nextion::add_no_result_to_queue_with_set(std::shared_ptr<NextionComponentBase> component,
|
||||
const std::string &state_value) {
|
||||
void Nextion::add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) {
|
||||
this->add_no_result_to_queue_with_set(component->get_variable_name(), component->get_variable_name_to_send(),
|
||||
state_value);
|
||||
}
|
||||
@ -1028,11 +1042,12 @@ void Nextion::add_no_result_to_queue_with_set_internal_(const std::string &varia
|
||||
state_value.c_str());
|
||||
}
|
||||
|
||||
void Nextion::add_to_get_queue(std::shared_ptr<NextionComponentBase> component) {
|
||||
void Nextion::add_to_get_queue(NextionComponentBase *component) {
|
||||
if ((!this->is_setup() && !this->ignore_is_setup_))
|
||||
return;
|
||||
|
||||
auto nextion_queue = make_unique<nextion::NextionQueue>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
|
||||
nextion_queue->component = component;
|
||||
nextion_queue->queue_time = millis();
|
||||
@ -1043,7 +1058,7 @@ void Nextion::add_to_get_queue(std::shared_ptr<NextionComponentBase> component)
|
||||
std::string command = "get " + component->get_variable_name_to_send();
|
||||
|
||||
if (this->send_command_(command)) {
|
||||
this->nextion_queue_.push_back(std::move(nextion_queue));
|
||||
this->nextion_queue_.push_back(nextion_queue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1055,13 +1070,15 @@ void Nextion::add_to_get_queue(std::shared_ptr<NextionComponentBase> component)
|
||||
* @param buffer_to_send The buffer size
|
||||
* @param buffer_size The buffer data
|
||||
*/
|
||||
void Nextion::add_addt_command_to_queue(std::shared_ptr<NextionComponentBase> component) {
|
||||
void Nextion::add_addt_command_to_queue(NextionComponentBase *component) {
|
||||
if ((!this->is_setup() && !this->ignore_is_setup_) || this->is_sleeping())
|
||||
return;
|
||||
|
||||
auto nextion_queue = make_unique<nextion::NextionQueue>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
|
||||
nextion_queue->component = std::make_shared<nextion::NextionComponentBase>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion_queue->component = new nextion::NextionComponentBase;
|
||||
nextion_queue->queue_time = millis();
|
||||
|
||||
size_t buffer_to_send = component->get_wave_buffer_size() < 255 ? component->get_wave_buffer_size()
|
||||
@ -1070,7 +1087,7 @@ void Nextion::add_addt_command_to_queue(std::shared_ptr<NextionComponentBase> co
|
||||
std::string command = "addt " + to_string(component->get_component_id()) + "," +
|
||||
to_string(component->get_wave_channel_id()) + "," + to_string(buffer_to_send);
|
||||
if (this->send_command_(command)) {
|
||||
this->nextion_queue_.push_back(std::move(nextion_queue));
|
||||
this->nextion_queue_.push_back(nextion_queue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -707,18 +707,17 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
void set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state);
|
||||
void set_nextion_text_state(const std::string &name, const std::string &state);
|
||||
|
||||
void add_no_result_to_queue_with_set(std::shared_ptr<NextionComponentBase> component, int state_value) override;
|
||||
void add_no_result_to_queue_with_set(NextionComponentBase *component, int state_value) override;
|
||||
void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
|
||||
int state_value) override;
|
||||
|
||||
void add_no_result_to_queue_with_set(std::shared_ptr<NextionComponentBase> component,
|
||||
const std::string &state_value) override;
|
||||
void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) override;
|
||||
void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
|
||||
const std::string &state_value) override;
|
||||
|
||||
void add_to_get_queue(std::shared_ptr<NextionComponentBase> component) override;
|
||||
void add_to_get_queue(NextionComponentBase *component) override;
|
||||
|
||||
void add_addt_command_to_queue(std::shared_ptr<NextionComponentBase> component) override;
|
||||
void add_addt_command_to_queue(NextionComponentBase *component) override;
|
||||
|
||||
void update_components_by_prefix(const std::string &prefix);
|
||||
|
||||
@ -729,7 +728,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
void set_auto_wake_on_touch_internal(bool auto_wake_on_touch) { this->auto_wake_on_touch_ = auto_wake_on_touch; }
|
||||
|
||||
protected:
|
||||
std::deque<std::unique_ptr<NextionQueue>> nextion_queue_;
|
||||
std::deque<NextionQueue *> nextion_queue_;
|
||||
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag);
|
||||
void all_components_send_state_(bool force_update = false);
|
||||
uint64_t comok_sent_ = 0;
|
||||
|
@ -24,19 +24,18 @@ class NextionBase;
|
||||
|
||||
class NextionBase {
|
||||
public:
|
||||
virtual void add_no_result_to_queue_with_set(std::shared_ptr<NextionComponentBase> component, int state_value) = 0;
|
||||
virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, int state_value) = 0;
|
||||
virtual void add_no_result_to_queue_with_set(const std::string &variable_name,
|
||||
const std::string &variable_name_to_send, int state_value) = 0;
|
||||
|
||||
virtual void add_no_result_to_queue_with_set(std::shared_ptr<NextionComponentBase> component,
|
||||
const std::string &state_value) = 0;
|
||||
virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) = 0;
|
||||
virtual void add_no_result_to_queue_with_set(const std::string &variable_name,
|
||||
const std::string &variable_name_to_send,
|
||||
const std::string &state_value) = 0;
|
||||
|
||||
virtual void add_addt_command_to_queue(std::shared_ptr<NextionComponentBase> component) = 0;
|
||||
virtual void add_addt_command_to_queue(NextionComponentBase *component) = 0;
|
||||
|
||||
virtual void add_to_get_queue(std::shared_ptr<NextionComponentBase> component) = 0;
|
||||
virtual void add_to_get_queue(NextionComponentBase *component) = 0;
|
||||
|
||||
virtual void set_component_background_color(const char *component, Color color) = 0;
|
||||
virtual void set_component_pressed_background_color(const char *component, Color color) = 0;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
namespace esphome {
|
||||
@ -23,7 +22,7 @@ class NextionComponentBase;
|
||||
class NextionQueue {
|
||||
public:
|
||||
virtual ~NextionQueue() = default;
|
||||
std::shared_ptr<NextionComponentBase> component;
|
||||
NextionComponentBase *component;
|
||||
uint32_t queue_time = 0;
|
||||
};
|
||||
|
||||
|
@ -281,12 +281,14 @@ void Nextion::upload_tft() {
|
||||
#endif
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Allocating buffer size %d, Heap size is %u", chunk_size, ESP.getFreeHeap());
|
||||
this->transfer_buffer_ = new (std::nothrow) uint8_t[chunk_size]; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
if (this->transfer_buffer_ == nullptr) { // Try a smaller size
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
this->transfer_buffer_ = new (std::nothrow) uint8_t[chunk_size];
|
||||
if (this->transfer_buffer_ == nullptr) { // Try a smaller size
|
||||
ESP_LOGD(TAG, "Could not allocate buffer size: %d trying 4096 instead", chunk_size);
|
||||
chunk_size = 4096;
|
||||
ESP_LOGD(TAG, "Allocating %d buffer", chunk_size);
|
||||
this->transfer_buffer_ = new (std::nothrow) uint8_t[chunk_size]; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
this->transfer_buffer_ = new uint8_t[chunk_size];
|
||||
|
||||
if (!this->transfer_buffer_)
|
||||
this->upload_end_();
|
||||
@ -330,7 +332,8 @@ void Nextion::upload_end_() {
|
||||
WiFiClient *Nextion::get_wifi_client_() {
|
||||
if (this->tft_url_.compare(0, 6, "https:") == 0) {
|
||||
if (this->wifi_client_secure_ == nullptr) {
|
||||
this->wifi_client_secure_ = new BearSSL::WiFiClientSecure(); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
this->wifi_client_secure_ = new BearSSL::WiFiClientSecure();
|
||||
this->wifi_client_secure_->setInsecure();
|
||||
this->wifi_client_secure_->setBufferSizes(512, 512);
|
||||
}
|
||||
@ -338,7 +341,8 @@ WiFiClient *Nextion::get_wifi_client_() {
|
||||
}
|
||||
|
||||
if (this->wifi_client_ == nullptr) {
|
||||
this->wifi_client_ = new WiFiClient(); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
this->wifi_client_ = new WiFiClient();
|
||||
}
|
||||
return this->wifi_client_;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void NextionSensor::update() {
|
||||
return;
|
||||
|
||||
if (this->wave_chan_id_ == UINT8_MAX) {
|
||||
this->nextion_->add_to_get_queue(shared_from_this());
|
||||
this->nextion_->add_to_get_queue(this);
|
||||
} else {
|
||||
if (this->send_last_value_) {
|
||||
this->add_to_wave_buffer(this->last_value_);
|
||||
@ -62,9 +62,9 @@ void NextionSensor::set_state(float state, bool publish, bool send_to_nextion) {
|
||||
double to_multiply = pow(10, this->precision_);
|
||||
int state_value = (int) (state * to_multiply);
|
||||
|
||||
this->nextion_->add_no_result_to_queue_with_set(shared_from_this(), (int) state_value);
|
||||
this->nextion_->add_no_result_to_queue_with_set(this, (int) state_value);
|
||||
} else {
|
||||
this->nextion_->add_no_result_to_queue_with_set(shared_from_this(), (int) state);
|
||||
this->nextion_->add_no_result_to_queue_with_set(this, (int) state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ void NextionSensor::wave_update_() {
|
||||
buffer_to_send, this->wave_buffer_.size(), this->component_id_, this->wave_chan_id_);
|
||||
#endif
|
||||
|
||||
this->nextion_->add_addt_command_to_queue(shared_from_this());
|
||||
this->nextion_->add_addt_command_to_queue(this);
|
||||
}
|
||||
|
||||
} // namespace nextion
|
||||
|
@ -8,10 +8,7 @@ namespace esphome {
|
||||
namespace nextion {
|
||||
class NextionSensor;
|
||||
|
||||
class NextionSensor : public NextionComponent,
|
||||
public sensor::Sensor,
|
||||
public PollingComponent,
|
||||
public std::enable_shared_from_this<NextionSensor> {
|
||||
class NextionSensor : public NextionComponent, public sensor::Sensor, public PollingComponent {
|
||||
public:
|
||||
NextionSensor(NextionBase *nextion) { this->nextion_ = nextion; }
|
||||
void send_state_to_nextion() override { this->set_state(this->state, false, true); };
|
||||
|
@ -20,7 +20,7 @@ void NextionSwitch::process_bool(const std::string &variable_name, bool on) {
|
||||
void NextionSwitch::update() {
|
||||
if (!this->nextion_->is_setup())
|
||||
return;
|
||||
this->nextion_->add_to_get_queue(shared_from_this());
|
||||
this->nextion_->add_to_get_queue(this);
|
||||
}
|
||||
|
||||
void NextionSwitch::set_state(bool state, bool publish, bool send_to_nextion) {
|
||||
@ -32,7 +32,7 @@ void NextionSwitch::set_state(bool state, bool publish, bool send_to_nextion) {
|
||||
this->needs_to_send_update_ = true;
|
||||
} else {
|
||||
this->needs_to_send_update_ = false;
|
||||
this->nextion_->add_no_result_to_queue_with_set(shared_from_this(), (int) state);
|
||||
this->nextion_->add_no_result_to_queue_with_set(this, (int) state);
|
||||
}
|
||||
}
|
||||
if (publish) {
|
||||
|
@ -8,10 +8,7 @@ namespace esphome {
|
||||
namespace nextion {
|
||||
class NextionSwitch;
|
||||
|
||||
class NextionSwitch : public NextionComponent,
|
||||
public switch_::Switch,
|
||||
public PollingComponent,
|
||||
public std::enable_shared_from_this<NextionSwitch> {
|
||||
class NextionSwitch : public NextionComponent, public switch_::Switch, public PollingComponent {
|
||||
public:
|
||||
NextionSwitch(NextionBase *nextion) { this->nextion_ = nextion; }
|
||||
|
||||
|
@ -18,7 +18,7 @@ void NextionTextSensor::process_text(const std::string &variable_name, const std
|
||||
void NextionTextSensor::update() {
|
||||
if (!this->nextion_->is_setup())
|
||||
return;
|
||||
this->nextion_->add_to_get_queue(shared_from_this());
|
||||
this->nextion_->add_to_get_queue(this);
|
||||
}
|
||||
|
||||
void NextionTextSensor::set_state(const std::string &state, bool publish, bool send_to_nextion) {
|
||||
@ -29,7 +29,7 @@ void NextionTextSensor::set_state(const std::string &state, bool publish, bool s
|
||||
if (this->nextion_->is_sleeping() || !this->visible_) {
|
||||
this->needs_to_send_update_ = true;
|
||||
} else {
|
||||
this->nextion_->add_no_result_to_queue_with_set(shared_from_this(), state);
|
||||
this->nextion_->add_no_result_to_queue_with_set(this, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,7 @@ namespace esphome {
|
||||
namespace nextion {
|
||||
class NextionTextSensor;
|
||||
|
||||
class NextionTextSensor : public NextionComponent,
|
||||
public text_sensor::TextSensor,
|
||||
public PollingComponent,
|
||||
public std::enable_shared_from_this<NextionTextSensor> {
|
||||
class NextionTextSensor : public NextionComponent, public text_sensor::TextSensor, public PollingComponent {
|
||||
public:
|
||||
NextionTextSensor(NextionBase *nextion) { this->nextion_ = nextion; }
|
||||
void update() override;
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2021.10.0b10"
|
||||
__version__ = "2021.10.0b11"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
|
||||
|
@ -178,7 +178,7 @@ def run_external_command(
|
||||
orig_argv = sys.argv
|
||||
orig_exit = sys.exit # mock sys.exit
|
||||
full_cmd = " ".join(shlex_quote(x) for x in cmd)
|
||||
_LOGGER.info("Running: %s", full_cmd)
|
||||
_LOGGER.debug("Running: %s", full_cmd)
|
||||
|
||||
orig_stdout = sys.stdout
|
||||
sys.stdout = RedirectText(sys.stdout, filter_lines=filter_lines)
|
||||
@ -214,7 +214,7 @@ def run_external_command(
|
||||
|
||||
def run_external_process(*cmd, **kwargs):
|
||||
full_cmd = " ".join(shlex_quote(x) for x in cmd)
|
||||
_LOGGER.info("Running: %s", full_cmd)
|
||||
_LOGGER.debug("Running: %s", full_cmd)
|
||||
filter_lines = kwargs.get("filter_lines")
|
||||
|
||||
capture_stdout = kwargs.get("capture_stdout", False)
|
||||
|
@ -9,7 +9,7 @@ pyserial==3.5
|
||||
platformio==5.2.1
|
||||
esptool==3.1
|
||||
click==8.0.3
|
||||
esphome-dashboard==20211020.1
|
||||
esphome-dashboard==20211021.0
|
||||
aioesphomeapi==9.1.5
|
||||
|
||||
# esp-idf requires this, but doesn't bundle it by default
|
||||
|
Loading…
Reference in New Issue
Block a user