mag1024 / esphome-nat-ap

An ESPHome custom component that implements a WIFI repeater (NAT-ing AP)
5 stars 0 forks source link

5.1 compatability? #1

Open alex-red opened 10 months ago

alex-red commented 10 months ago

Hey, thanks for this!

I'm playing around with a esp32-c6 which requires the esp-idf 5.1 which has a lot of breaking changes, particularily with dhcps_set_option_info. I thought I would pick your brain to see if you had any ideas how I could adapt this to work with 5.1.

Error:

In file included from src/main.cpp:17:
src/nat-ap.h: In function 'void ap_config(esp_netif_t*)':
src/nat-ap.h:66:33: error: invalid use of incomplete type 'esp_netif_t' {aka 'struct esp_netif_obj'}
   66 |   dhcps_set_option_info(ap_netif->dhcps, 6, &dhcps_dns_value, sizeof(dhcps_dns_value));
      |                                 ^~
In file included from /data/cache/platformio/packages/framework-espidf/components/esp_netif/include/esp_netif.h:13,
                 from /data/cache/platformio/packages/framework-espidf/components/esp_wifi/include/esp_wifi_default.h:10,
                 from /data/cache/platformio/packages/framework-espidf/components/esp_wifi/include/esp_wifi.h:58,
                 from src/nat-ap.h:6:
/data/cache/platformio/packages/framework-espidf/components/esp_netif/include/esp_netif_types.h:47:8: note: forward declaration of 'esp_netif_t' {aka 'struct esp_netif_obj'}
   47 | struct esp_netif_obj;
      |        ^~~~~~~~~~~~~
src/nat-ap.h:69:31: error: invalid use of incomplete type 'esp_netif_t' {aka 'struct esp_netif_obj'}
   69 |   dhcps_dns_setserver(ap_netif->dhcps, &dnsserver);
      |                               ^~
/data/cache/platformio/packages/framework-espidf/components/esp_netif/include/esp_netif_types.h:47:8: note: forward declaration of 'esp_netif_t' {aka 'struct esp_netif_obj'}
   47 | struct esp_netif_obj;
      |        ^~~~~~~~~~~~~

My setup:

esphome:
  name: esp32-c6-a
  friendly_name: esp32-c6-a
  includes:
    - nat-ap.h

esp32:
  board: esp32-c6-devkitc-1
  variant: esp32c6
  framework:
    type: esp-idf
    version: 5.1.0
    platform_version: https://github.com/stintel/platform-espressif32#esp32-c6-test
    sdkconfig_options:
      CONFIG_COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_LWIP_IP_FORWARD: y
      CONFIG_LWIP_IPV4_NAPT: y

I think this is how they want us to use it now: https://docs.espressif.com/projects/esp-faq/en/latest/software-framework/wifi.html#lwip-how-to-configure-the-option-contents-of-dhcp-server-in-esp-idf but I couldn't get it to work.

mag1024 commented 10 months ago

The 'incomplete type' seems to indicate that some include is missing.... but I haven't tried 5.x myself. Many esphome modules seem to not be compatible with version 5 yet.

Bascht74 commented 7 months ago

Is there a plan to add a "bridge" mode, so natting is not needed anymore?

mag1024 commented 7 months ago

Is there a plan to add a "bridge" mode, so natting is not needed anymore?

This is not the right project (or the right issue) to answer this question. We're simply exposing the capabilities provided by the Espressif framework in the context of Esphome. AFAIK, the framework can only do this via NAT -- I'm not even sure it's possible to do bridge wifi without some custom support from the AP.