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!