ESP32 storage size of 'netif' isn't known, how to fix this error?

MuxD

Hi I'm trying to get this code block to run in the mainline of one of the examples provided with ESP-IDF (denoted by arrows)

void app_main(void)
{
    ESP_ERROR_CHECK( nvs_flash_init() );
    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());

    /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.
     * Read "Establishing Wi-Fi or Ethernet Connection" section in
     * examples/protocols/README.md for more information about this function.
     */
    ESP_ERROR_CHECK(example_connect());

    // VVV
    esp_netif_t netif;
    esp_err_t esp_netif_get_netif_impl_name(&netif, "STA");
    esp_netif_dhcpc_stop(&netif);
    esp_netif_ip_info_t ip_info;
    esp_netif_get_ip_info(&netif, &ip_info);
    esp_netif_set_ip4_addr(&ip_info.netmask, 255,255,255,255);
    esp_netif_set_ip_info(&netif, &ip_info);
    esp_netif_destroy(&netif);
    // ^^^
    
    
    ESP_LOGI(TAG, "IP4 address set successfuly");

    xTaskCreate(&http_get_task, "http_get_task", 4096, NULL, 5, NULL);
}

Here are the error logs:

../main/http_request_example_main.c: In function 'app_main':
../main/http_request_example_main.c:141:17: error: storage size of 'netif' isn't known
     esp_netif_t netif;
                 ^~~~~
../main/http_request_example_main.c:142:45: error: expected declaration specifiers or '...' before '&' token
     esp_err_t esp_netif_get_netif_impl_name(&netif, "STA");
                                             ^
../main/http_request_example_main.c:142:53: error: expected declaration specifiers or '...' before string constant
     esp_err_t esp_netif_get_netif_impl_name(&netif, "STA");
                                                     ^~~~~
../main/http_request_example_main.c:141:17: warning: unused variable 'netif' [-Wunused-variable]
     esp_netif_t netif;
                 ^~~~~
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

What I'm attempting to do is; get the esp32's to talk to each other through wifi directly so that I can see what's happening through Wireshark.

The netif is initialised in example_connect() and esp_err_t esp_netif_get_netif_impl_name(&netif, "STA"); calls that same implementation name so that some work can be done on it

I will appreciate any comments or answers. Thank you!

Tarmo

The root cause of this error is that the struct esp_netif_t is a private type in the netif implementation. You're not supposed to create any objects of this type, only pass around handles (pointers) to it.

I suspect you've misunderstood what esp_netif_get_netif_impl_name() does. According to the API doc it takes a handle to a esp_netif_t and returns the name corresponding to this interface.

What you seem to be after is retrieving the handle to your interface in the first place. For this the (rather terse) API doc suggest a few other functions, e.g. esp_netif_get_handle_from_ifkey(...) for searching for interfaces using something called interface key (no idea, sorry, but google helps there) or esp_netif_next(...) for iterating over interfaces.

According to this forum post you might want to try something like this:

    esp_netif_t* netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
    if (netif) {
        esp_netif_dhcpc_stop(netif);
        // ... rest of your code
    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

error: storage size of 'name' isn't known

OpenSSL “error: storage size of ‘ctx’ isn’t known”

Storage size of 'ServAddr' isn't known

Storage size of struct isn't known

storage size of isn't known : enum

EVP_MD_CTX "error: storage size of ‘ctx’ isn’t known"

error: storage size of 'status' isn't known, which header am I missing?

Storage size of SDL_Thread isn’t known?

How to fix compilation error for ESP32 in Arduino IDE?

Using custom LinkedList library in a main program; storage size isn't known

How to fix "Can't bind to 'ngForOf' since it isn't a known property of <child component>" if ContentChildren used

C errors: implicit declaration of function and storage size isn't known, despite the function and struct being members of an included header file

How can I fix "Future isn't a type" error in flutter?

how to fix Manager isn't accessible via Words instances error?

How do i fix mutating operator isn't mutable error?

storage size of array isn't constant

why "storage size of 'array' isn't constant"

Error: Can't bind to 'ngModel' since it isn't a known property of

how to fix 'mat-error' is not a known element:?

how to get 0% value that isn't 0 if 100% is not known

storage size of DIR variable is not known

How can I fix the rails error "mystylesheet.css isn't precompiled"?

Manager isn't accessible via WatchList instances How do I fix this error?

How do I fix a syntax error when it looks like there isn't one

How to fix update error "Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)"?

How to fix this Firebase message format sent from ESP32 (Arduino, ESP-IDF - all text, no Firebase library used)

How To Increase RX Serial Buffer Size for ESP32 library Hardwareserial (Platform IO)

Shrine::Error: storage :cache isn't registered on FileUploader

How to fix Firebase Storage reference error