How to get "esp_netif_t *esp_netif" ???

Baldhead
Posts: 468
Joined: Sun Mar 31, 2019 5:16 am

How to get "esp_netif_t *esp_netif" ???

Postby Baldhead » Tue Sep 22, 2020 4:18 am

Hi,

I am trying to make this: "https://www.esp32.com/viewtopic.php?p=65487#p65487"

I want to generate a server hostname with the mac address.

When the function "void set_unique_hostname()" must be called ?

Code: Select all

void init_my_server()  
{       
    ESP_ERROR_CHECK(nvs_flash_init());
    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());
   
    // Register event handlers to start server when Wi-Fi is connected,
    // and stop server when disconnection happens.     
    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler, NULL));
    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, NULL));
    
    // 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());   // replace this function with "own implementation".
}


void set_unique_hostname()
{
/*
typedef enum {
    ESP_MAC_WIFI_STA,
    ESP_MAC_WIFI_SOFTAP,
    ESP_MAC_BT,
    ESP_MAC_ETH,
} esp_mac_type_t;
*/

    uint8_t get_mac[6];

    esp_err_t ret = esp_read_mac( get_mac, ESP_MAC_WIFI_STA );
    
    if( ret != ESP_OK )
    {        
        printf( "\nError Reading Mac Address: %s\n", esp_err_to_name(ret) );
        return;
    }


    char new_hostname[50];

    sprintf( new_hostname, "www.%02X:%02X:%02X.domain.local", get_mac[3], get_mac[4], get_mac[5] );  // I believe that in production i would not need to use this function. i need to read the mac address, generate the hostname string, and write it once to flash memory. Maybe a script ?????

    char old_hostname[50];

    esp_netif_get_hostname(      , old_hostname );    // How to get "esp_netif_t *esp_netif"  ???
    									      // old_hostname must be pointer to pointer argument ???	


    if ( strncmp( new_hostname, old_hostname, strlen(old_hostname) ) == 0 )
    {
        return;
    }    

    esp_netif_set_hostname(     , new_hostname );    // How to get "esp_netif_t *esp_netif"  ???
}
Last edited by Baldhead on Thu Sep 24, 2020 2:33 am, edited 1 time in total.

Baldhead
Posts: 468
Joined: Sun Mar 31, 2019 5:16 am

Re: How to get "esp_netif_t *esp_netif" ???

Postby Baldhead » Wed Sep 23, 2020 5:01 am

any suggestion will be well appreciated.

Thank's.

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: How to get "esp_netif_t *esp_netif" ???

Postby boarchuz » Wed Sep 23, 2020 5:36 am

You'll need to dive into "example_connect" since all of your WiFi initialization is apparently hiding in there.

See
https://github.com/espressif/esp-idf/bl ... #L165-L200

and
https://github.com/espressif/esp-idf/bl ... ect.c#L249

Your own implementation in your WiFi initialisation might look like this:

Code: Select all

esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta();
assert(sta_netif);
esp_netif_set_hostname(sta_netif, "MyHostname");

Baldhead
Posts: 468
Joined: Sun Mar 31, 2019 5:16 am

Re: How to get "esp_netif_t *esp_netif" ???

Postby Baldhead » Wed Sep 23, 2020 5:12 pm

Thank's @boarchuz,

Someone could tell me if the hostname is write in the flash memory ?

How to pass a pointer to pointer argument to this function "esp_netif_get_hostname( )" ???

Function prototype: "esp_err_t esp_netif_get_hostname(esp_netif_t *esp_netif, const char **hostname)"
Last edited by Baldhead on Thu Sep 24, 2020 2:16 am, edited 1 time in total.

Baldhead
Posts: 468
Joined: Sun Mar 31, 2019 5:16 am

Re: How to get "esp_netif_t *esp_netif" ???

Postby Baldhead » Thu Sep 24, 2020 2:15 am

Hi,

Now are partially working.

I dont know why, in first call, the function "esp_netif_get_hostname()" not work, but after i set the name with "esp_netif_set_hostname" the function "esp_netif_get_hostname()" work.

Code: Select all

    const char* old_hostname; 
    
    ret = esp_netif_get_hostname( netif, &old_hostname ); 
    
    printf( "esp_netif_get_hostname: %s\n", esp_err_to_name(ret) );

    printf( "old_hostname = %s\n\n", old_hostname );
ERROR:
esp_netif_get_hostname: ESP_ERR_ESP_NETIF_IF_NOT_READY
old_hostname = ��@L�@�@L�@C:/esp-idf/components/wpa_supplicant/src/esp_supplicant/esp_wpa_main.c


my_wifi.c

Code: Select all

#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"

#include "lwip/err.h"
#include "lwip/sys.h"

///////////////////////////////////////////////////////////////////////////////////////////

void set_unique_hostname();

////////////////////////////////////////////////////////////////////////////////////////////
/* The examples use WiFi configuration that you can set via project configuration menu

   If you'd rather not, just change the below entries to strings with
   the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
*/
#define EXAMPLE_ESP_WIFI_SSID      "mySSID"     // CONFIG_ESP_WIFI_SSID
#define EXAMPLE_ESP_WIFI_PASS      "myPASS"    // CONFIG_ESP_WIFI_PASSWORD
#define EXAMPLE_ESP_MAXIMUM_RETRY  5

////////////////////////////////////////////////////////////////////////////////////////////

/* FreeRTOS event group to signal when we are connected*/
static EventGroupHandle_t s_wifi_event_group;

/* The event group allows multiple bits for each event, but we only care about two events:
 * - we are connected to the AP with an IP
 * - we failed to connect after the maximum amount of retries */
#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT      BIT1

static const char *TAG = "wifi station";

static int s_retry_num = 0;

static esp_netif_t* netif = NULL;

////////////////////////////////////////////////////////////////////////////////////////////

static void event_handler( void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data )
{
    if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START)
    {
        esp_wifi_connect();
    } 
    else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
    {
        if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY)
        {
            esp_wifi_connect();
            s_retry_num++;
            ESP_LOGI(TAG, "retry to connect to the AP");
        }
        else
        {
            xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
        }
        ESP_LOGI(TAG,"connect to the AP fail");
    } 
    else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
    {
        ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
        ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
        s_retry_num = 0;
        xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
    }
}

////////////////////////////////////////////////////////////////////////////////////////////

void wifi_init_sta(void)
{
    s_wifi_event_group = xEventGroupCreate();

    ESP_ERROR_CHECK(esp_netif_init());

    ESP_ERROR_CHECK(esp_event_loop_create_default());
    netif = esp_netif_create_default_wifi_sta();


    set_unique_hostname();


    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&cfg));

    esp_event_handler_instance_t instance_any_id;
    esp_event_handler_instance_t instance_got_ip;

    ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
                                                        ESP_EVENT_ANY_ID,
                                                        &event_handler,
                                                        NULL,
                                                        &instance_any_id));

    ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
                                                        IP_EVENT_STA_GOT_IP,
                                                        &event_handler,
                                                        NULL,
                                                        &instance_got_ip));

    wifi_config_t wifi_config =
    {
        .sta =
        {
            .ssid = EXAMPLE_ESP_WIFI_SSID,
            .password = EXAMPLE_ESP_WIFI_PASS
        }
    };
    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
    ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
    ESP_ERROR_CHECK(esp_wifi_start() );

    ESP_LOGI(TAG, "wifi_init_sta finished.");

    /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
     * number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */
    EventBits_t bits = xEventGroupWaitBits( s_wifi_event_group,
                                            WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
                                            pdFALSE,
                                            pdFALSE,
                                            portMAX_DELAY);

    /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
     * happened. */
    if (bits & WIFI_CONNECTED_BIT)
    {
        ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
    }
    else if (bits & WIFI_FAIL_BIT) 
    {
        ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
    }
    else
    {
        ESP_LOGE(TAG, "UNEXPECTED EVENT");
    }

    /* The event will not be processed after unregister */
    ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip));
    ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id));
    vEventGroupDelete(s_wifi_event_group);
}

///////////////////////////////////////////////////////////////////////////////////////////////////

void set_unique_hostname()
{

/*
typedef enum {
    ESP_MAC_WIFI_STA,
    ESP_MAC_WIFI_SOFTAP,
    ESP_MAC_BT,
    ESP_MAC_ETH,
} esp_mac_type_t;
*/

    uint8_t get_mac[6] = {0};

    esp_err_t ret = esp_read_mac( get_mac, ESP_MAC_WIFI_STA );
    
    if( ret != ESP_OK )
    {        
        printf( "\nError Reading Mac Address: %s\n", esp_err_to_name(ret) );
        return;
    }

    printf( "\n\n" );
    printf( "get_mac[0] = %02X\n", get_mac[0] );
    printf( "get_mac[1] = %02X\n", get_mac[1] );
    printf( "get_mac[2] = %02X\n", get_mac[2] );
    printf( "get_mac[3] = %02X\n", get_mac[3] );
    printf( "get_mac[4] = %02X\n", get_mac[4] );
    printf( "get_mac[5] = %02X\n", get_mac[5] );


    char new_hostname[50];

    sprintf( new_hostname, "%02X:%02X:%02X.my_local_domain.local", get_mac[3], get_mac[4], get_mac[5] );

    printf( "new_hostname = %s\n\n", new_hostname );


    assert(netif);


    const char* old_hostname; 
    
    ret = esp_netif_get_hostname( netif, &old_hostname ); 
    printf( "esp_netif_get_hostname: %s\n", esp_err_to_name(ret) );

    printf( "old_hostname = %s\n\n", old_hostname );


    if ( strncmp( new_hostname, old_hostname, strlen(old_hostname) ) == 0 )
    {
        printf("\n\nnew_hostname == old_hostname\n\n");        
        return;
    }    

    ret = esp_netif_set_hostname( netif , new_hostname );    // new_hostname Maximum length 32 bytes.
    printf( "esp_netif_set_hostname: %s\n", esp_err_to_name(ret) );
   
    ret = esp_netif_get_hostname( netif, &old_hostname ); 
    printf( "esp_netif_get_hostname: %s\n", esp_err_to_name(ret) );
   
    printf( "old_hostname = %s\n\n", old_hostname );
}

///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

esp_err_t my_wifi_init( )
{
    //Initialize NVS
    esp_err_t ret = nvs_flash_init();

    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
    {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);

    ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");    
    
    wifi_init_sta();

    return ESP_OK;
}
Monitor Logging:

Code: Select all

Executing action: monitor
Running idf_monitor in directory c:\esp32projects\http_file_serving
Executing "C:\.espressif\python_env\idf4.2_py3.7_env\Scripts\python.exe C:\esp-idf\tools/idf_monitor.py -p COM7 -b 115200 --toolchain-prefix xtensa-esp32-elf- c:\esp32projects\http_file_serving\build\file_server.elf -m 'C:\.espressif\python_env\idf4.2_py3.7_env\Scripts\python.exe' 'C:\esp-idf\tools\idf.py' '-p' 'COM7'"...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM7 instead...
--- idf_monitor on \\.\COM7 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4
load:0x3fff0034,len:7356
load:0x40078000,len:14832
load:0x40080400,len:4740
0x40080400: _init at ??:?

entry 0x400806a4
I (29) boot: ESP-IDF v4.2-dev-1235-g71dc5eb27-dirty 2nd stage bootloader
I (29) boot: compile time 18:07:34
I (31) boot: chip revision: 1
I (34) qio_mode: Enabling default flash chip QIO
I (40) boot.esp32: SPI Speed      : 80MHz
I (44) boot.esp32: SPI Mode       : QIO
I (49) boot.esp32: SPI Flash Size : 4MB
I (53) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length  
I (70) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (77) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00100000
I (92) boot:  3 storage          Unknown data     01 82 00110000 000f0000
I (100) boot: End of partition table
I (104) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x1b77c (112508) map
I (150) esp_image: segment 1: paddr=0x0002b7a4 vaddr=0x3ffb0000 size=0x03a34 ( 14900) load
I (156) esp_image: segment 2: paddr=0x0002f1e0 vaddr=0x40080000 size=0x00404 (  1028) load
0x40080000: _WindowOverflow4 at C:/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1730

I (157) esp_image: segment 3: paddr=0x0002f5ec vaddr=0x40080404 size=0x00a2c (  2604) load 
I (167) esp_image: segment 4: paddr=0x00030020 vaddr=0x400d0020 size=0x781d8 (491992) map
0x400d0020: _stext at ??:?

I (339) esp_image: segment 5: paddr=0x000a8200 vaddr=0x40080e30 size=0x187f4 (100340) load
I (392) boot: Loaded app from partition at offset 0x10000
I (392) boot: Disabling RNG early entropy source...
I (392) psram: This chip is ESP32-D0WD
I (397) spiram: Found 64MBit SPI RAM device        
I (401) spiram: SPI RAM mode: flash 80m sram 80m   
I (407) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (414) cpu_start: Pro cpu up.
I (418) cpu_start: Application information:
I (423) cpu_start: Project name:     file_server
I (428) cpu_start: App version:      1
I (432) cpu_start: Compile time:     Sep 23 2020 18:07:15
I (438) cpu_start: ELF file SHA256:  183fc67aaa3db281...
I (444) cpu_start: ESP-IDF:          v4.2-dev-1235-g71dc5eb27-dirty
I (451) cpu_start: Starting app cpu, entry point is 0x40081760
0x40081760: call_start_cpu1 at C:/esp-idf/components/esp32/cpu_start.c:286

I (0) cpu_start: App cpu up.
I (952) spiram: SPI SRAM memory test OK
I (952) heap_init: Initializing. RAM available for dynamic allocation:
I (952) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (958) heap_init: At 3FFB97D8 len 00026828 (154 KiB): DRAM
I (965) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (971) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (977) heap_init: At 40099624 len 000069DC (26 KiB): IRAM
I (984) cpu_start: Pro cpu start user code
I (988) spiram: Adding pool of 4096K of external SPI memory to heap allocator
I (1009) spi_flash: detected chip: generic
I (1009) spi_flash: flash io: qio
I (1009) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (1023) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (1064) wifi station: ESP_WIFI_MODE_STA
I (1065) system_api: Base MAC address is not set
I (1065) system_api: read default base MAC address from EFUSE


get_mac[0] = 24
get_mac[1] = 6F
get_mac[2] = 28
get_mac[3] = F0
get_mac[4] = 09
get_mac[5] = 5C

new_hostname = F0:09:5C.my_local_domain.local

esp_netif_get_hostname: ESP_ERR_ESP_NETIF_IF_NOT_READY
old_hostname = ��@L�@�@L�@C:/esp-idf/components/wpa_supplicant/src/esp_supplicant/esp_wpa_main.c

esp_netif_set_hostname: ESP_OK
esp_netif_get_hostname: ESP_OK
old_hostname = F0:09:5C.my_local_domain.local

I (1108) wifi:wifi driver task: 3ffc9698, prio:23, stack:3584, core=0
I (1127) wifi:wifi firmware version: 4234f65
I (1128) wifi:wifi certification version: v7.0
I (1128) wifi:config NVS flash: enabled
I (1128) wifi:config nano formating: disabled
I (1132) wifi:Init dynamic tx buffer num: 32
I (1136) wifi:Init data frame dynamic rx buffer num: 32
I (1141) wifi:Init management frame dynamic rx buffer num: 32
I (1147) wifi:Init management short buffer num: 32
I (1151) wifi:Init static tx buffer num: 16
I (1156) wifi:Init static rx buffer size: 1600
I (1159) wifi:Init static rx buffer num: 10
I (1163) wifi:Init dynamic rx buffer num: 32
I (1252) phy: phy_version: 4180, cb3948e, Sep 12 2019, 16:39:13, 0, 0
I (1253) wifi:mode : sta (24:6f:28:f0:09:5c)
I (1255) wifi station: wifi_init_sta finished.
I (1375) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:11
I (1376) wifi:state: init -> auth (b0)
I (1384) wifi:state: auth -> assoc (0)
I (1388) wifi:state: assoc -> run (10)
I (1492) wifi:connected with mySSID, aid = 6, channel 11, BW20, bssid = xx:xx:xx:xx:xx:xx
I (1492) wifi:security type: 3, phy: bgn, rssi: -47
I (1497) wifi:pm start, type: 1

I (1583) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (2565) esp_netif_handlers: sta ip: 192.168.0.8, mask: 255.255.255.0, gw: 192.168.0.1
I (2565) wifi station: got ip:192.168.0.8
I (2568) wifi station: connected to ap SSID:mySSID password:myPASS
Last edited by Baldhead on Thu Sep 24, 2020 2:35 am, edited 1 time in total.

Baldhead
Posts: 468
Joined: Sun Mar 31, 2019 5:16 am

Re: How to get "esp_netif_t *esp_netif" ???

Postby Baldhead » Thu Sep 24, 2020 2:32 am

Hi again,

I would like to know how i can integrate the above "my_wifi.c" file with my https/wss server ?

Project structure(sort of looks like this):

Code: Select all

project root folder/
    main/
        - main.c
    components/
        communication/
            my_wifi/
                - my_wifi.c
            my_ws_server/        
                - webSocket_server.c
In this code below, wifi and https/wss server works, but use "example connect()".

Code: Select all

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


    // Register event handlers to start server when Wi-Fi is connected,
    // and stop server when disconnection happens.     
    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler, NULL));
    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, NULL));


    // 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());  
}

In this code below, only wifi works.
I tried to register the event handler, but the server don't work.
If i use "ESP_ERROR_CHECK(esp_event_loop_create_default())" the run time program crash.
I would like to leave the wifi file(my_wifi.c) separate from the server file(webSocket_server.c), the way i am currently using it.
I think that the problem is how to register event handler in the right way in the file "webSocket_server.c".
How could i make it work with separated "my_wifi.c" and "webSocket_server.c" files ?

Code: Select all

void init_webSocket_server()  
{
    my_wifi_init( );    // my_wifi.c file
    
    
    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler, NULL));
    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, NULL));
}

Thank's.

sergiomarina
Posts: 48
Joined: Wed Feb 05, 2020 6:29 pm

Re: How to get "esp_netif_t *esp_netif" ???

Postby sergiomarina » Sat Jan 21, 2023 11:40 am

Hi.
I connect to this post with the aim not to duplicate.

I'd like to assign the property 'host' of a http_client.
The 'host' is also the AP and therefore it would be sufficient to retrieve the IP address of the gateway.

I would like to leave as-is the example-connect section (just to be clear, now, I've solved modifying the example-connect section. I'm happy with it, so my request would work just as an improvement with the aim to ease portability)
I think the right function is 'esp_netif_get_ip_info', but i need to provide an object 'esp_netif' which I do not know how-to retrieve.
Does exist a function that makes that?

+++++++++++++++++++++++++++++
(added few hours later) a link that seems related:
viewtopic.php?t=21359
the question is the same and since 2021 it has been having no reply. So it seems not an easy task.
I'm wondering if IDFV5.0 has something that can help.
I looked for 'adapter' in components dir and I could find nothing.
-------------------------------------

Thank you.
Sergio




Thank you.
Sergio

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 85 guests