mirror of
https://github.com/esphome/esphome.git
synced 2024-12-21 16:27:44 +01:00
Clean-up constant definitions (#2148)
This commit is contained in:
parent
8cc3cbb22e
commit
5ec9bb0fb5
@ -745,9 +745,7 @@ DeviceInfoResponse APIConnection::device_info(const DeviceInfoRequest &msg) {
|
||||
resp.mac_address = get_mac_address_pretty();
|
||||
resp.esphome_version = ESPHOME_VERSION;
|
||||
resp.compilation_time = App.get_compilation_time();
|
||||
#ifdef ARDUINO_BOARD
|
||||
resp.model = ARDUINO_BOARD;
|
||||
#endif
|
||||
resp.model = ESPHOME_BOARD;
|
||||
#ifdef USE_DEEP_SLEEP
|
||||
resp.has_deep_sleep = deep_sleep::global_has_deep_sleep;
|
||||
#endif
|
||||
|
@ -10,7 +10,7 @@ static const char *const TAG = "bme680_bsec.sensor";
|
||||
|
||||
static const std::string IAQ_ACCURACY_STATES[4] = {"Stabilizing", "Uncertain", "Calibrating", "Calibrated"};
|
||||
|
||||
BME680BSECComponent *BME680BSECComponent::instance;
|
||||
BME680BSECComponent *BME680BSECComponent::instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
void BME680BSECComponent::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up BME680 via BSEC...");
|
||||
@ -359,7 +359,7 @@ void BME680BSECComponent::publish_sensor_state_(sensor::Sensor *sensor, float va
|
||||
sensor->publish_state(value);
|
||||
}
|
||||
|
||||
void BME680BSECComponent::publish_sensor_state_(text_sensor::TextSensor *sensor, std::string value) {
|
||||
void BME680BSECComponent::publish_sensor_state_(text_sensor::TextSensor *sensor, const std::string &value) {
|
||||
if (!sensor || (sensor->has_state() && sensor->state == value)) {
|
||||
return;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class BME680BSECComponent : public Component, public i2c::I2CDevice {
|
||||
int64_t get_time_ns_();
|
||||
|
||||
void publish_sensor_state_(sensor::Sensor *sensor, float value, bool change_only = false);
|
||||
void publish_sensor_state_(text_sensor::TextSensor *sensor, std::string value);
|
||||
void publish_sensor_state_(text_sensor::TextSensor *sensor, const std::string &value);
|
||||
|
||||
void load_state_();
|
||||
void save_state_(uint8_t accuracy);
|
||||
|
@ -82,11 +82,9 @@ bool BLEServer::create_device_characteristics_() {
|
||||
this->device_information_service_->create_characteristic(MODEL_UUID, BLECharacteristic::PROPERTY_READ);
|
||||
model->set_value(this->model_.value());
|
||||
} else {
|
||||
#ifdef ARDUINO_BOARD
|
||||
BLECharacteristic *model =
|
||||
this->device_information_service_->create_characteristic(MODEL_UUID, BLECharacteristic::PROPERTY_READ);
|
||||
model->set_value(ARDUINO_BOARD);
|
||||
#endif
|
||||
model->set_value(ESPHOME_BOARD);
|
||||
}
|
||||
|
||||
BLECharacteristic *version =
|
||||
|
@ -102,9 +102,7 @@ bool MQTTComponent::send_discovery_() {
|
||||
device_info["identifiers"] = get_mac_address();
|
||||
device_info["name"] = node_name;
|
||||
device_info["sw_version"] = "esphome v" ESPHOME_VERSION " " + App.get_compilation_time();
|
||||
#ifdef ARDUINO_BOARD
|
||||
device_info["model"] = ARDUINO_BOARD;
|
||||
#endif
|
||||
device_info["model"] = ESPHOME_BOARD;
|
||||
device_info["manufacturer"] = "espressif";
|
||||
},
|
||||
0, discovery_info.retain);
|
||||
|
@ -305,7 +305,7 @@ def wifi_network(config, static_ip):
|
||||
cg.add(ap.set_password(config[CONF_PASSWORD]))
|
||||
if CONF_EAP in config:
|
||||
cg.add(ap.set_eap(eap_auth(config[CONF_EAP])))
|
||||
cg.add_define("ESPHOME_WIFI_WPA2_EAP")
|
||||
cg.add_define("USE_WIFI_WPA2_EAP")
|
||||
if CONF_BSSID in config:
|
||||
cg.add(ap.set_bssid([HexInt(i) for i in config[CONF_BSSID].parts]))
|
||||
if CONF_HIDDEN in config:
|
||||
|
@ -258,7 +258,7 @@ void WiFiComponent::start_connecting(const WiFiAP &ap, bool two) {
|
||||
ESP_LOGV(TAG, " BSSID: Not Set");
|
||||
}
|
||||
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
if (ap.get_eap().has_value()) {
|
||||
ESP_LOGV(TAG, " WPA2 Enterprise authentication configured:");
|
||||
EAPAuth eap_config = ap.get_eap().value();
|
||||
@ -274,7 +274,7 @@ void WiFiComponent::start_connecting(const WiFiAP &ap, bool two) {
|
||||
} else {
|
||||
#endif
|
||||
ESP_LOGV(TAG, " Password: " LOG_SECRET("'%s'"), ap.get_password().c_str());
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
}
|
||||
#endif
|
||||
if (ap.get_channel().has_value()) {
|
||||
@ -478,7 +478,7 @@ void WiFiComponent::check_scanning_finished() {
|
||||
// copy manual IP (if set)
|
||||
connect_params.set_manual_ip(config.get_manual_ip());
|
||||
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
// copy EAP parameters (if set)
|
||||
connect_params.set_eap(config.get_eap());
|
||||
#endif
|
||||
@ -638,8 +638,8 @@ void WiFiAP::set_ssid(const std::string &ssid) { this->ssid_ = ssid; }
|
||||
void WiFiAP::set_bssid(bssid_t bssid) { this->bssid_ = bssid; }
|
||||
void WiFiAP::set_bssid(optional<bssid_t> bssid) { this->bssid_ = bssid; }
|
||||
void WiFiAP::set_password(const std::string &password) { this->password_ = password; }
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
void WiFiAP::set_eap(optional<EAPAuth> eap_auth) { this->eap_ = eap_auth; }
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
void WiFiAP::set_eap(optional<EAPAuth> eap_auth) { this->eap_ = std::move(eap_auth); }
|
||||
#endif
|
||||
void WiFiAP::set_channel(optional<uint8_t> channel) { this->channel_ = channel; }
|
||||
void WiFiAP::set_manual_ip(optional<ManualIP> manual_ip) { this->manual_ip_ = std::move(manual_ip); }
|
||||
@ -647,7 +647,7 @@ void WiFiAP::set_hidden(bool hidden) { this->hidden_ = hidden; }
|
||||
const std::string &WiFiAP::get_ssid() const { return this->ssid_; }
|
||||
const optional<bssid_t> &WiFiAP::get_bssid() const { return this->bssid_; }
|
||||
const std::string &WiFiAP::get_password() const { return this->password_; }
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
const optional<EAPAuth> &WiFiAP::get_eap() const { return this->eap_; }
|
||||
#endif
|
||||
const optional<uint8_t> &WiFiAP::get_channel() const { return this->channel_; }
|
||||
@ -679,7 +679,7 @@ bool WiFiScanResult::matches(const WiFiAP &config) {
|
||||
if (config.get_bssid().has_value() && *config.get_bssid() != this->bssid_)
|
||||
return false;
|
||||
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
// BSSID requires auth but no PSK or EAP credentials given
|
||||
if (this->with_auth_ && (config.get_password().empty() && !config.get_eap().has_value()))
|
||||
return false;
|
||||
|
@ -63,7 +63,7 @@ struct ManualIP {
|
||||
IPAddress dns2; ///< The second DNS server. 0.0.0.0 for default.
|
||||
};
|
||||
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
struct EAPAuth {
|
||||
std::string identity; // required for all auth types
|
||||
std::string username;
|
||||
@ -73,7 +73,7 @@ struct EAPAuth {
|
||||
const char *client_cert;
|
||||
const char *client_key;
|
||||
};
|
||||
#endif // ESPHOME_WIFI_WPA2_EAP
|
||||
#endif // USE_WIFI_WPA2_EAP
|
||||
|
||||
using bssid_t = std::array<uint8_t, 6>;
|
||||
|
||||
@ -83,9 +83,9 @@ class WiFiAP {
|
||||
void set_bssid(bssid_t bssid);
|
||||
void set_bssid(optional<bssid_t> bssid);
|
||||
void set_password(const std::string &password);
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
void set_eap(optional<EAPAuth> eap_auth);
|
||||
#endif // ESPHOME_WIFI_WPA2_EAP
|
||||
#endif // USE_WIFI_WPA2_EAP
|
||||
void set_channel(optional<uint8_t> channel);
|
||||
void set_priority(float priority) { priority_ = priority; }
|
||||
void set_manual_ip(optional<ManualIP> manual_ip);
|
||||
@ -93,9 +93,9 @@ class WiFiAP {
|
||||
const std::string &get_ssid() const;
|
||||
const optional<bssid_t> &get_bssid() const;
|
||||
const std::string &get_password() const;
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
const optional<EAPAuth> &get_eap() const;
|
||||
#endif // ESPHOME_WIFI_WPA2_EAP
|
||||
#endif // USE_WIFI_WPA2_EAP
|
||||
const optional<uint8_t> &get_channel() const;
|
||||
float get_priority() const { return priority_; }
|
||||
const optional<ManualIP> &get_manual_ip() const;
|
||||
@ -105,9 +105,9 @@ class WiFiAP {
|
||||
std::string ssid_;
|
||||
optional<bssid_t> bssid_;
|
||||
std::string password_;
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
optional<EAPAuth> eap_;
|
||||
#endif // ESPHOME_WIFI_WPA2_EAP
|
||||
#endif // USE_WIFI_WPA2_EAP
|
||||
optional<uint8_t> channel_;
|
||||
float priority_{0};
|
||||
optional<ManualIP> manual_ip_;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
#include <esp_wpa2.h>
|
||||
#endif
|
||||
#include "lwip/err.h"
|
||||
@ -163,7 +163,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
||||
conf.sta.threshold.authmode = WIFI_AUTH_WPA_WPA2_PSK;
|
||||
}
|
||||
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
if (ap.get_eap().has_value()) {
|
||||
conf.sta.threshold.authmode = WIFI_AUTH_WPA2_ENTERPRISE;
|
||||
}
|
||||
@ -220,7 +220,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
||||
}
|
||||
|
||||
// setup enterprise authentication if required
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
if (ap.get_eap().has_value()) {
|
||||
// note: all certificates and keys have to be null terminated. Lengths are appended by +1 to include \0.
|
||||
EAPAuth eap = ap.get_eap().value();
|
||||
@ -264,7 +264,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
||||
ESP_LOGV(TAG, "esp_wifi_sta_wpa2_ent_enable failed! %d", err);
|
||||
}
|
||||
}
|
||||
#endif // ESPHOME_WIFI_WPA2_EAP
|
||||
#endif // USE_WIFI_WPA2_EAP
|
||||
|
||||
this->wifi_apply_hostname_();
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
#include <wpa2_enterprise.h>
|
||||
#endif
|
||||
|
||||
@ -250,7 +250,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
||||
}
|
||||
|
||||
// setup enterprise authentication if required
|
||||
#ifdef ESPHOME_WIFI_WPA2_EAP
|
||||
#ifdef USE_WIFI_WPA2_EAP
|
||||
if (ap.get_eap().has_value()) {
|
||||
// note: all certificates and keys have to be null terminated. Lengths are appended by +1 to include \0.
|
||||
EAPAuth eap = ap.get_eap().value();
|
||||
@ -293,7 +293,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
||||
ESP_LOGV(TAG, "esp_wifi_sta_wpa2_ent_enable failed! %d", ret);
|
||||
}
|
||||
}
|
||||
#endif // ESPHOME_WIFI_WPA2_EAP
|
||||
#endif // USE_WIFI_WPA2_EAP
|
||||
|
||||
this->wifi_apply_hostname_();
|
||||
|
||||
|
@ -1,31 +1,52 @@
|
||||
#pragma once
|
||||
// This file is auto-generated! Do not edit!
|
||||
|
||||
// This file is not used by the runtime, instead, a version is generated during
|
||||
// compilation with only the relevant feature flags for the current build.
|
||||
//
|
||||
// This file is only used by static analyzers and IDEs.
|
||||
|
||||
// Informative flags
|
||||
#define ESPHOME_BOARD "dummy_board"
|
||||
#define ESPHOME_PROJECT_NAME "dummy project"
|
||||
#define ESPHOME_PROJECT_VERSION "v2"
|
||||
|
||||
// Feature flags
|
||||
#define USE_ADC_SENSOR_VCC
|
||||
#define USE_API
|
||||
#define USE_LOGGER
|
||||
#define USE_BINARY_SENSOR
|
||||
#define USE_SENSOR
|
||||
#define USE_SWITCH
|
||||
#define USE_WIFI
|
||||
#define USE_STATUS_LED
|
||||
#define USE_TEXT_SENSOR
|
||||
#define USE_FAN
|
||||
#define USE_COVER
|
||||
#define USE_LIGHT
|
||||
#define USE_CAPTIVE_PORTAL
|
||||
#define USE_CLIMATE
|
||||
#define USE_NUMBER
|
||||
#define USE_SELECT
|
||||
#define USE_MQTT
|
||||
#define USE_POWER_SUPPLY
|
||||
#define USE_COVER
|
||||
#define USE_DEEP_SLEEP
|
||||
#define USE_ESP8266_PREFERENCES_FLASH
|
||||
#define USE_FAN
|
||||
#define USE_HOMEASSISTANT_TIME
|
||||
#define USE_I2C_MULTIPLEXER
|
||||
#define USE_JSON
|
||||
#define USE_LIGHT
|
||||
#define USE_LOGGER
|
||||
#define USE_MDNS
|
||||
#define USE_MQTT
|
||||
#define USE_NUMBER
|
||||
#define USE_OTA_STATE_CALLBACK
|
||||
#define USE_POWER_SUPPLY
|
||||
#define USE_PROMETHEUS
|
||||
#define USE_SELECT
|
||||
#define USE_SENSOR
|
||||
#define USE_STATUS_LED
|
||||
#define USE_SWITCH
|
||||
#define USE_TEXT_SENSOR
|
||||
#define USE_TFT_UPLOAD
|
||||
#define USE_TIME
|
||||
#define USE_WIFI
|
||||
#define USE_WIFI_WPA2_EAP
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#define USE_ESP32_CAMERA
|
||||
#define USE_ESP32_BLE_SERVER
|
||||
#define USE_ESP32_CAMERA
|
||||
#define USE_ETHERNET
|
||||
#define USE_IMPROV
|
||||
#endif
|
||||
#define USE_TIME
|
||||
#define USE_DEEP_SLEEP
|
||||
#define USE_CAPTIVE_PORTAL
|
||||
#define ESPHOME_BOARD "dummy_board"
|
||||
#define USE_MDNS
|
||||
|
||||
// Disabled feature flags
|
||||
//#define USE_BSEC // Requires a library with proprietary license.
|
||||
|
@ -1,3 +1,9 @@
|
||||
#pragma once
|
||||
// This file is auto-generated! Do not edit!
|
||||
|
||||
// This file is not used by the runtime, instead, a version is generated during
|
||||
// compilation with only the version for the current build. This is kept in its
|
||||
// own file so that not all files have to be recompiled for each new release.
|
||||
//
|
||||
// This file is only used by static analyzers and IDEs.
|
||||
|
||||
#define ESPHOME_VERSION "dev"
|
||||
|
Loading…
Reference in New Issue
Block a user