mirror of
https://github.com/esphome/esphome.git
synced 2025-11-15 06:15:47 +00:00
Merge branch 'memory_api' into memory_api_action_chaining_const_ref
This commit is contained in:
@@ -224,7 +224,7 @@ void APIServer::dump_config() {
|
|||||||
" Address: %s:%u\n"
|
" Address: %s:%u\n"
|
||||||
" Listen backlog: %u\n"
|
" Listen backlog: %u\n"
|
||||||
" Max connections: %u",
|
" Max connections: %u",
|
||||||
network::get_use_address().c_str(), this->port_, this->listen_backlog_, this->max_connections_);
|
network::get_use_address(), this->port_, this->listen_backlog_, this->max_connections_);
|
||||||
#ifdef USE_API_NOISE
|
#ifdef USE_API_NOISE
|
||||||
ESP_LOGCONFIG(TAG, " Noise encryption: %s", YESNO(this->noise_ctx_->has_psk()));
|
ESP_LOGCONFIG(TAG, " Noise encryption: %s", YESNO(this->noise_ctx_->has_psk()));
|
||||||
if (!this->noise_ctx_->has_psk()) {
|
if (!this->noise_ctx_->has_psk()) {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ void ESPHomeOTAComponent::dump_config() {
|
|||||||
"Over-The-Air updates:\n"
|
"Over-The-Air updates:\n"
|
||||||
" Address: %s:%u\n"
|
" Address: %s:%u\n"
|
||||||
" Version: %d",
|
" Version: %d",
|
||||||
network::get_use_address().c_str(), this->port_, USE_OTA_VERSION);
|
network::get_use_address(), this->port_, USE_OTA_VERSION);
|
||||||
#ifdef USE_OTA_PASSWORD
|
#ifdef USE_OTA_PASSWORD
|
||||||
if (!this->password_.empty()) {
|
if (!this->password_.empty()) {
|
||||||
ESP_LOGCONFIG(TAG, " Password configured");
|
ESP_LOGCONFIG(TAG, " Password configured");
|
||||||
|
|||||||
@@ -691,9 +691,9 @@ void EthernetComponent::set_manual_ip(const ManualIP &manual_ip) { this->manual_
|
|||||||
|
|
||||||
// set_use_address() is guaranteed to be called during component setup by Python code generation,
|
// set_use_address() is guaranteed to be called during component setup by Python code generation,
|
||||||
// so use_address_ will always be valid when get_use_address() is called - no fallback needed.
|
// so use_address_ will always be valid when get_use_address() is called - no fallback needed.
|
||||||
const std::string &EthernetComponent::get_use_address() const { return this->use_address_; }
|
const char *EthernetComponent::get_use_address() const { return this->use_address_; }
|
||||||
|
|
||||||
void EthernetComponent::set_use_address(const std::string &use_address) { this->use_address_ = use_address; }
|
void EthernetComponent::set_use_address(const char *use_address) { this->use_address_ = use_address; }
|
||||||
|
|
||||||
void EthernetComponent::get_eth_mac_address_raw(uint8_t *mac) {
|
void EthernetComponent::get_eth_mac_address_raw(uint8_t *mac) {
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ class EthernetComponent : public Component {
|
|||||||
|
|
||||||
network::IPAddresses get_ip_addresses();
|
network::IPAddresses get_ip_addresses();
|
||||||
network::IPAddress get_dns_address(uint8_t num);
|
network::IPAddress get_dns_address(uint8_t num);
|
||||||
const std::string &get_use_address() const;
|
const char *get_use_address() const;
|
||||||
void set_use_address(const std::string &use_address);
|
void set_use_address(const char *use_address);
|
||||||
void get_eth_mac_address_raw(uint8_t *mac);
|
void get_eth_mac_address_raw(uint8_t *mac);
|
||||||
std::string get_eth_mac_address_pretty();
|
std::string get_eth_mac_address_pretty();
|
||||||
eth_duplex_t get_duplex_mode();
|
eth_duplex_t get_duplex_mode();
|
||||||
@@ -114,7 +114,6 @@ class EthernetComponent : public Component {
|
|||||||
/// @brief Set arbitratry PHY registers from config.
|
/// @brief Set arbitratry PHY registers from config.
|
||||||
void write_phy_register_(esp_eth_mac_t *mac, PHYRegister register_data);
|
void write_phy_register_(esp_eth_mac_t *mac, PHYRegister register_data);
|
||||||
|
|
||||||
std::string use_address_;
|
|
||||||
#ifdef USE_ETHERNET_SPI
|
#ifdef USE_ETHERNET_SPI
|
||||||
uint8_t clk_pin_;
|
uint8_t clk_pin_;
|
||||||
uint8_t miso_pin_;
|
uint8_t miso_pin_;
|
||||||
@@ -158,6 +157,11 @@ class EthernetComponent : public Component {
|
|||||||
esp_eth_handle_t eth_handle_;
|
esp_eth_handle_t eth_handle_;
|
||||||
esp_eth_phy_t *phy_{nullptr};
|
esp_eth_phy_t *phy_{nullptr};
|
||||||
optional<std::array<uint8_t, 6>> fixed_mac_;
|
optional<std::array<uint8_t, 6>> fixed_mac_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Stores a pointer to a string literal (static storage duration).
|
||||||
|
// ONLY set from Python-generated code with string literals - never dynamic strings.
|
||||||
|
const char *use_address_{""};
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ network::IPAddresses get_ip_addresses() {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &get_use_address() {
|
const char *get_use_address() {
|
||||||
// Global component pointers are guaranteed to be set by component constructors when USE_* is defined
|
// Global component pointers are guaranteed to be set by component constructors when USE_* is defined
|
||||||
#ifdef USE_ETHERNET
|
#ifdef USE_ETHERNET
|
||||||
return ethernet::global_eth_component->get_use_address();
|
return ethernet::global_eth_component->get_use_address();
|
||||||
@@ -105,8 +105,7 @@ const std::string &get_use_address() {
|
|||||||
|
|
||||||
#if !defined(USE_ETHERNET) && !defined(USE_MODEM) && !defined(USE_WIFI) && !defined(USE_OPENTHREAD)
|
#if !defined(USE_ETHERNET) && !defined(USE_MODEM) && !defined(USE_WIFI) && !defined(USE_OPENTHREAD)
|
||||||
// Fallback when no network component is defined (e.g., host platform)
|
// Fallback when no network component is defined (e.g., host platform)
|
||||||
static const std::string empty;
|
return "";
|
||||||
return empty;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ bool is_connected();
|
|||||||
/// Return whether the network is disabled (only wifi for now)
|
/// Return whether the network is disabled (only wifi for now)
|
||||||
bool is_disabled();
|
bool is_disabled();
|
||||||
/// Get the active network hostname
|
/// Get the active network hostname
|
||||||
const std::string &get_use_address();
|
const char *get_use_address();
|
||||||
IPAddresses get_ip_addresses();
|
IPAddresses get_ip_addresses();
|
||||||
|
|
||||||
} // namespace network
|
} // namespace network
|
||||||
|
|||||||
@@ -254,9 +254,9 @@ void OpenThreadComponent::on_factory_reset(std::function<void()> callback) {
|
|||||||
|
|
||||||
// set_use_address() is guaranteed to be called during component setup by Python code generation,
|
// set_use_address() is guaranteed to be called during component setup by Python code generation,
|
||||||
// so use_address_ will always be valid when get_use_address() is called - no fallback needed.
|
// so use_address_ will always be valid when get_use_address() is called - no fallback needed.
|
||||||
const std::string &OpenThreadComponent::get_use_address() const { return this->use_address_; }
|
const char *OpenThreadComponent::get_use_address() const { return this->use_address_; }
|
||||||
|
|
||||||
void OpenThreadComponent::set_use_address(const std::string &use_address) { this->use_address_ = use_address; }
|
void OpenThreadComponent::set_use_address(const char *use_address) { this->use_address_ = use_address; }
|
||||||
|
|
||||||
} // namespace openthread
|
} // namespace openthread
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|||||||
@@ -33,15 +33,19 @@ class OpenThreadComponent : public Component {
|
|||||||
void on_factory_reset(std::function<void()> callback);
|
void on_factory_reset(std::function<void()> callback);
|
||||||
void defer_factory_reset_external_callback();
|
void defer_factory_reset_external_callback();
|
||||||
|
|
||||||
const std::string &get_use_address() const;
|
const char *get_use_address() const;
|
||||||
void set_use_address(const std::string &use_address);
|
void set_use_address(const char *use_address);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::optional<otIp6Address> get_omr_address_(InstanceLock &lock);
|
std::optional<otIp6Address> get_omr_address_(InstanceLock &lock);
|
||||||
bool teardown_started_{false};
|
bool teardown_started_{false};
|
||||||
bool teardown_complete_{false};
|
bool teardown_complete_{false};
|
||||||
std::function<void()> factory_reset_external_callback_;
|
std::function<void()> factory_reset_external_callback_;
|
||||||
std::string use_address_;
|
|
||||||
|
private:
|
||||||
|
// Stores a pointer to a string literal (static storage duration).
|
||||||
|
// ONLY set from Python-generated code with string literals - never dynamic strings.
|
||||||
|
const char *use_address_{""};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern OpenThreadComponent *global_openthread_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
extern OpenThreadComponent *global_openthread_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ void WebServer::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG,
|
ESP_LOGCONFIG(TAG,
|
||||||
"Web Server:\n"
|
"Web Server:\n"
|
||||||
" Address: %s:%u",
|
" Address: %s:%u",
|
||||||
network::get_use_address().c_str(), this->base_->get_port());
|
network::get_use_address(), this->base_->get_port());
|
||||||
}
|
}
|
||||||
float WebServer::get_setup_priority() const { return setup_priority::WIFI - 1.0f; }
|
float WebServer::get_setup_priority() const { return setup_priority::WIFI - 1.0f; }
|
||||||
|
|
||||||
|
|||||||
@@ -273,8 +273,8 @@ network::IPAddress WiFiComponent::get_dns_address(int num) {
|
|||||||
}
|
}
|
||||||
// set_use_address() is guaranteed to be called during component setup by Python code generation,
|
// set_use_address() is guaranteed to be called during component setup by Python code generation,
|
||||||
// so use_address_ will always be valid when get_use_address() is called - no fallback needed.
|
// so use_address_ will always be valid when get_use_address() is called - no fallback needed.
|
||||||
const std::string &WiFiComponent::get_use_address() const { return this->use_address_; }
|
const char *WiFiComponent::get_use_address() const { return this->use_address_; }
|
||||||
void WiFiComponent::set_use_address(const std::string &use_address) { this->use_address_ = use_address; }
|
void WiFiComponent::set_use_address(const char *use_address) { this->use_address_ = use_address; }
|
||||||
|
|
||||||
#ifdef USE_WIFI_AP
|
#ifdef USE_WIFI_AP
|
||||||
void WiFiComponent::setup_ap_config_() {
|
void WiFiComponent::setup_ap_config_() {
|
||||||
|
|||||||
@@ -283,8 +283,8 @@ class WiFiComponent : public Component {
|
|||||||
|
|
||||||
network::IPAddress get_dns_address(int num);
|
network::IPAddress get_dns_address(int num);
|
||||||
network::IPAddresses get_ip_addresses();
|
network::IPAddresses get_ip_addresses();
|
||||||
const std::string &get_use_address() const;
|
const char *get_use_address() const;
|
||||||
void set_use_address(const std::string &use_address);
|
void set_use_address(const char *use_address);
|
||||||
|
|
||||||
const wifi_scan_vector_t<WiFiScanResult> &get_scan_result() const { return scan_result_; }
|
const wifi_scan_vector_t<WiFiScanResult> &get_scan_result() const { return scan_result_; }
|
||||||
|
|
||||||
@@ -393,7 +393,6 @@ class WiFiComponent : public Component {
|
|||||||
void wifi_scan_done_callback_();
|
void wifi_scan_done_callback_();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string use_address_;
|
|
||||||
FixedVector<WiFiAP> sta_;
|
FixedVector<WiFiAP> sta_;
|
||||||
std::vector<WiFiSTAPriority> sta_priorities_;
|
std::vector<WiFiSTAPriority> sta_priorities_;
|
||||||
wifi_scan_vector_t<WiFiScanResult> scan_result_;
|
wifi_scan_vector_t<WiFiScanResult> scan_result_;
|
||||||
@@ -445,6 +444,11 @@ class WiFiComponent : public Component {
|
|||||||
// Pointers at the end (naturally aligned)
|
// Pointers at the end (naturally aligned)
|
||||||
Trigger<> *connect_trigger_{new Trigger<>()};
|
Trigger<> *connect_trigger_{new Trigger<>()};
|
||||||
Trigger<> *disconnect_trigger_{new Trigger<>()};
|
Trigger<> *disconnect_trigger_{new Trigger<>()};
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Stores a pointer to a string literal (static storage duration).
|
||||||
|
// ONLY set from Python-generated code with string literals - never dynamic strings.
|
||||||
|
const char *use_address_{""};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WiFiComponent *global_wifi_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
extern WiFiComponent *global_wifi_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
|||||||
Reference in New Issue
Block a user