Skip to content

Commit

Permalink
Enable IPv6 support for BK72xx
Browse files Browse the repository at this point in the history
This depends on a soon-to-be-released version of LibreTiny containing
libretiny-eu/libretiny#292 which will have a version of at least 1.6.1.

Previous ESPHome PRs (esphome#7408, esphome#7409, esphome#7410) make it possible to require
at least LibreTiny version 1.6.1 in order to enable IPv6.

It also bumps the required AsyncTCP version to 2.1.4, which will include
esphome/AsyncTCP#14

Closes esphome/feature-requests#2853
  • Loading branch information
dwmw2 committed Sep 5, 2024
1 parent ea174f1 commit 9468631
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions esphome/components/network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
esp8266=False,
esp32=False,
rp2040=False,
bk72xx=False,
): cv.All(
cv.boolean,
cv.Any(
cv.require_framework_version(
esp_idf=cv.Version(0, 0, 0),
esp8266_arduino=cv.Version(0, 0, 0),
rp2040_arduino=cv.Version(0, 0, 0),
bk72xx_libretiny=cv.Version(1, 6, 1),
),
cv.boolean_false,
),
Expand Down Expand Up @@ -51,3 +53,5 @@ async def to_code(config):
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6")
if CORE.is_esp8266:
cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY")
if CORE.is_bk72xx:
cg.add_build_flag("-DCONFIG_IPV6")
16 changes: 15 additions & 1 deletion esphome/components/wifi/wifi_component_libretiny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
network::IPAddresses WiFiComponent::wifi_sta_ip_addresses() {
if (!this->has_sta())
return {};
return {WiFi.localIP()};
network::IPAddresses addresses;
addresses[0] = WiFi.localIP();
#if USE_NETWORK_IPV6
int i = 1;
auto v6_addresses = WiFi.allLocalIPv6();
for (auto address : v6_addresses) {
addresses[i++] = network::IPAddress(address.toString().c_str());
}
#endif /* USE_NETWORK_IPV6 */
return addresses;
}

bool WiFiComponent::wifi_apply_hostname_() {
Expand Down Expand Up @@ -321,6 +330,11 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
s_sta_connecting = false;
break;
}
case ESPHOME_EVENT_ID_WIFI_STA_GOT_IP6: {
// auto it = info.got_ip.ip_info;
ESP_LOGV(TAG, "Event: Got IPv6");
break;
}
case ESPHOME_EVENT_ID_WIFI_STA_LOST_IP: {
ESP_LOGV(TAG, "Event: Lost IP");
break;
Expand Down
6 changes: 5 additions & 1 deletion tests/components/network/test-ipv6.bk72xx-ard.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
substitutions:
network_enable_ipv6: "false"
network_enable_ipv6: "true"

bk72xx:
framework:
version: 1.6.1

<<: !include common.yaml

0 comments on commit 9468631

Please sign in to comment.