mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 17:57:37 +08:00
Merge remote-tracking branch 'origin/wifi_phy_mode_esp8266' into integration
This commit is contained in:
@@ -220,7 +220,7 @@ async def to_code(config):
|
|||||||
data = _get_data()
|
data = _get_data()
|
||||||
|
|
||||||
if data.micro_decoder_support:
|
if data.micro_decoder_support:
|
||||||
add_idf_component(name="esphome/micro-decoder", ref="0.1.1")
|
add_idf_component(name="esphome/micro-decoder", ref="0.2.0")
|
||||||
|
|
||||||
# All codecs are enabled by default in micro-decoder, so disable the ones that aren't requested to save flash
|
# All codecs are enabled by default in micro-decoder, so disable the ones that aren't requested to save flash
|
||||||
if not data.flac_support:
|
if not data.flac_support:
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ NO_WIFI_VARIANTS = [const.VARIANT_ESP32H2, const.VARIANT_ESP32P4]
|
|||||||
CONF_SAVE = "save"
|
CONF_SAVE = "save"
|
||||||
CONF_BAND_MODE = "band_mode"
|
CONF_BAND_MODE = "band_mode"
|
||||||
CONF_MIN_AUTH_MODE = "min_auth_mode"
|
CONF_MIN_AUTH_MODE = "min_auth_mode"
|
||||||
|
CONF_PHY_MODE = "phy_mode"
|
||||||
CONF_POST_CONNECT_ROAMING = "post_connect_roaming"
|
CONF_POST_CONNECT_ROAMING = "post_connect_roaming"
|
||||||
|
|
||||||
# Maximum number of WiFi networks that can be configured
|
# Maximum number of WiFi networks that can be configured
|
||||||
@@ -112,6 +113,14 @@ WIFI_MIN_AUTH_MODES = {
|
|||||||
"WPA3": WifiMinAuthMode.WIFI_MIN_AUTH_MODE_WPA3,
|
"WPA3": WifiMinAuthMode.WIFI_MIN_AUTH_MODE_WPA3,
|
||||||
}
|
}
|
||||||
VALIDATE_WIFI_MIN_AUTH_MODE = cv.enum(WIFI_MIN_AUTH_MODES, upper=True)
|
VALIDATE_WIFI_MIN_AUTH_MODE = cv.enum(WIFI_MIN_AUTH_MODES, upper=True)
|
||||||
|
|
||||||
|
WiFi8266PhyMode = wifi_ns.enum("WiFi8266PhyMode")
|
||||||
|
WIFI_8266_PHY_MODES = {
|
||||||
|
"AUTO": WiFi8266PhyMode.WIFI_8266_PHY_MODE_AUTO,
|
||||||
|
"11B": WiFi8266PhyMode.WIFI_8266_PHY_MODE_11B,
|
||||||
|
"11G": WiFi8266PhyMode.WIFI_8266_PHY_MODE_11G,
|
||||||
|
"11N": WiFi8266PhyMode.WIFI_8266_PHY_MODE_11N,
|
||||||
|
}
|
||||||
WiFiConnectedCondition = wifi_ns.class_("WiFiConnectedCondition", Condition)
|
WiFiConnectedCondition = wifi_ns.class_("WiFiConnectedCondition", Condition)
|
||||||
WiFiEnabledCondition = wifi_ns.class_("WiFiEnabledCondition", Condition)
|
WiFiEnabledCondition = wifi_ns.class_("WiFiEnabledCondition", Condition)
|
||||||
WiFiAPActiveCondition = wifi_ns.class_("WiFiAPActiveCondition", Condition)
|
WiFiAPActiveCondition = wifi_ns.class_("WiFiAPActiveCondition", Condition)
|
||||||
@@ -406,6 +415,10 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.only_on_esp32,
|
cv.only_on_esp32,
|
||||||
only_on_variant(supported=[const.VARIANT_ESP32C5]),
|
only_on_variant(supported=[const.VARIANT_ESP32C5]),
|
||||||
),
|
),
|
||||||
|
cv.Optional(CONF_PHY_MODE): cv.All(
|
||||||
|
cv.enum(WIFI_8266_PHY_MODES, upper=True),
|
||||||
|
cv.only_on_esp8266,
|
||||||
|
),
|
||||||
cv.Optional(CONF_PASSIVE_SCAN, default=False): cv.boolean,
|
cv.Optional(CONF_PASSIVE_SCAN, default=False): cv.boolean,
|
||||||
cv.Optional(CONF_ENABLE_ON_BOOT, default=True): cv.boolean,
|
cv.Optional(CONF_ENABLE_ON_BOOT, default=True): cv.boolean,
|
||||||
cv.Optional(CONF_POST_CONNECT_ROAMING, default=True): cv.boolean,
|
cv.Optional(CONF_POST_CONNECT_ROAMING, default=True): cv.boolean,
|
||||||
@@ -569,6 +582,9 @@ async def to_code(config):
|
|||||||
|
|
||||||
if CORE.is_esp8266:
|
if CORE.is_esp8266:
|
||||||
cg.add_library("ESP8266WiFi", None)
|
cg.add_library("ESP8266WiFi", None)
|
||||||
|
if CONF_PHY_MODE in config:
|
||||||
|
cg.add_define("USE_WIFI_PHY_MODE")
|
||||||
|
cg.add(var.set_phy_mode(config[CONF_PHY_MODE]))
|
||||||
elif CORE.is_rp2040:
|
elif CORE.is_rp2040:
|
||||||
cg.add_library("WiFi", None)
|
cg.add_library("WiFi", None)
|
||||||
|
|
||||||
|
|||||||
@@ -345,6 +345,17 @@ enum WifiMinAuthMode : uint8_t {
|
|||||||
WIFI_MIN_AUTH_MODE_WPA3,
|
WIFI_MIN_AUTH_MODE_WPA3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef USE_WIFI_PHY_MODE
|
||||||
|
// Values 1-3 match ESP8266 SDK phy_mode_t (PHY_MODE_11B=1, PHY_MODE_11G=2, PHY_MODE_11N=3).
|
||||||
|
// AUTO leaves the SDK at its default (no wifi_set_phy_mode() call).
|
||||||
|
enum WiFi8266PhyMode : uint8_t {
|
||||||
|
WIFI_8266_PHY_MODE_AUTO = 0,
|
||||||
|
WIFI_8266_PHY_MODE_11B = 1,
|
||||||
|
WIFI_8266_PHY_MODE_11G = 2,
|
||||||
|
WIFI_8266_PHY_MODE_11N = 3,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_ESP32
|
#ifdef USE_ESP32
|
||||||
struct IDFWiFiEvent;
|
struct IDFWiFiEvent;
|
||||||
#endif
|
#endif
|
||||||
@@ -455,6 +466,9 @@ class WiFiComponent final : public Component {
|
|||||||
#if defined(USE_ESP32) && defined(SOC_WIFI_SUPPORT_5G)
|
#if defined(USE_ESP32) && defined(SOC_WIFI_SUPPORT_5G)
|
||||||
void set_band_mode(wifi_band_mode_t band_mode) { this->band_mode_ = band_mode; }
|
void set_band_mode(wifi_band_mode_t band_mode) { this->band_mode_ = band_mode; }
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_WIFI_PHY_MODE
|
||||||
|
void set_phy_mode(WiFi8266PhyMode phy_mode) { this->phy_mode_ = phy_mode; }
|
||||||
|
#endif
|
||||||
|
|
||||||
void set_passive_scan(bool passive);
|
void set_passive_scan(bool passive);
|
||||||
|
|
||||||
@@ -672,6 +686,9 @@ class WiFiComponent final : public Component {
|
|||||||
bool wifi_apply_power_save_();
|
bool wifi_apply_power_save_();
|
||||||
#if defined(USE_ESP32) && defined(SOC_WIFI_SUPPORT_5G)
|
#if defined(USE_ESP32) && defined(SOC_WIFI_SUPPORT_5G)
|
||||||
bool wifi_apply_band_mode_();
|
bool wifi_apply_band_mode_();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_WIFI_PHY_MODE
|
||||||
|
bool wifi_apply_phy_mode_();
|
||||||
#endif
|
#endif
|
||||||
bool wifi_sta_ip_config_(const optional<ManualIP> &manual_ip);
|
bool wifi_sta_ip_config_(const optional<ManualIP> &manual_ip);
|
||||||
bool wifi_apply_hostname_();
|
bool wifi_apply_hostname_();
|
||||||
@@ -810,6 +827,9 @@ class WiFiComponent final : public Component {
|
|||||||
WiFiPowerSaveMode power_save_{WIFI_POWER_SAVE_NONE};
|
WiFiPowerSaveMode power_save_{WIFI_POWER_SAVE_NONE};
|
||||||
#if defined(USE_ESP32) && defined(SOC_WIFI_SUPPORT_5G)
|
#if defined(USE_ESP32) && defined(SOC_WIFI_SUPPORT_5G)
|
||||||
wifi_band_mode_t band_mode_{WIFI_BAND_MODE_AUTO};
|
wifi_band_mode_t band_mode_{WIFI_BAND_MODE_AUTO};
|
||||||
|
#endif
|
||||||
|
#ifdef USE_WIFI_PHY_MODE
|
||||||
|
WiFi8266PhyMode phy_mode_{WIFI_8266_PHY_MODE_AUTO};
|
||||||
#endif
|
#endif
|
||||||
WifiMinAuthMode min_auth_mode_{WIFI_MIN_AUTH_MODE_WPA2};
|
WifiMinAuthMode min_auth_mode_{WIFI_MIN_AUTH_MODE_WPA2};
|
||||||
WiFiRetryPhase retry_phase_{WiFiRetryPhase::INITIAL_CONNECT};
|
WiFiRetryPhase retry_phase_{WiFiRetryPhase::INITIAL_CONNECT};
|
||||||
|
|||||||
@@ -621,10 +621,25 @@ bool WiFiComponent::wifi_sta_pre_setup_() {
|
|||||||
ESP_LOGV(TAG, "Disabling Auto-Connect failed");
|
ESP_LOGV(TAG, "Disabling Auto-Connect failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_WIFI_PHY_MODE
|
||||||
|
if (!this->wifi_apply_phy_mode_()) {
|
||||||
|
ESP_LOGV(TAG, "Setting PHY Mode failed");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
delay(10);
|
delay(10);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_WIFI_PHY_MODE
|
||||||
|
bool WiFiComponent::wifi_apply_phy_mode_() {
|
||||||
|
if (this->phy_mode_ == WIFI_8266_PHY_MODE_AUTO)
|
||||||
|
return true;
|
||||||
|
// Values of WiFi8266PhyMode are aligned with the SDK's phy_mode_t enum.
|
||||||
|
return wifi_set_phy_mode(static_cast<phy_mode_t>(this->phy_mode_));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void WiFiComponent::wifi_pre_setup_() {
|
void WiFiComponent::wifi_pre_setup_() {
|
||||||
wifi_set_event_handler_cb(&WiFiComponent::wifi_event_callback);
|
wifi_set_event_handler_cb(&WiFiComponent::wifi_event_callback);
|
||||||
|
|
||||||
|
|||||||
@@ -283,6 +283,7 @@
|
|||||||
#define USE_CAPTIVE_PORTAL_GZIP
|
#define USE_CAPTIVE_PORTAL_GZIP
|
||||||
#define USE_WIFI_11KV_SUPPORT
|
#define USE_WIFI_11KV_SUPPORT
|
||||||
#define USE_WIFI_FAST_CONNECT
|
#define USE_WIFI_FAST_CONNECT
|
||||||
|
#define USE_WIFI_PHY_MODE
|
||||||
#define USE_WIFI_IP_STATE_LISTENERS
|
#define USE_WIFI_IP_STATE_LISTENERS
|
||||||
#define USE_WIFI_SCAN_RESULTS_LISTENERS
|
#define USE_WIFI_SCAN_RESULTS_LISTENERS
|
||||||
#define USE_WIFI_CONNECT_STATE_LISTENERS
|
#define USE_WIFI_CONNECT_STATE_LISTENERS
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ dependencies:
|
|||||||
esphome/esp-micro-speech-features:
|
esphome/esp-micro-speech-features:
|
||||||
version: 1.2.3
|
version: 1.2.3
|
||||||
esphome/micro-decoder:
|
esphome/micro-decoder:
|
||||||
version: 0.1.1
|
version: 0.2.0
|
||||||
esphome/micro-flac:
|
esphome/micro-flac:
|
||||||
version: 0.1.1
|
version: 0.1.1
|
||||||
esphome/micro-opus:
|
esphome/micro-opus:
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ wifi:
|
|||||||
subnet: 255.255.255.0
|
subnet: 255.255.255.0
|
||||||
dns1: 1.1.1.1
|
dns1: 1.1.1.1
|
||||||
dns2: 8.8.8.8
|
dns2: 8.8.8.8
|
||||||
|
phy_mode: 11G
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- !include common.yaml
|
- !include common.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user