I am trying to ping a local url address, but not worked.
I am trying like the code below in a AP WITHOUT internet connection.
With " #define MY_PING_URL "www.espressif.com" " worked, in a AP with internet connection obviously.
In windows cmd, "ping myfota.local", worked, image in annex.
Pinging local address by ip address worked too.
Some "local dns" problem maybe.
esp-idf Monitor:
Code: Select all
I (11098) MY_PING_APP: Unknown host: [ http://myfota.local ]
I (11098) MY_PING_APP: ret = 202
Code: Select all
// I tried with this two defines
//#define MY_PING_URL "myfota.local"
#define MY_PING_URL "http://myfota.local"
esp_err_t initialize_ping()
{
// convert URL to IP address
ip_addr_t target_addr;
struct addrinfo hint;
struct addrinfo *res = NULL;
memset(&hint, 0, sizeof(hint));
memset(&target_addr, 0, sizeof(target_addr));
int ret = getaddrinfo(MY_PING_URL, NULL, &hint, &res);
if( ret != 0 )
{
ESP_LOGI( MY_PING_TAG, LOG_USER1( "Unknown host: [ %s ]" ), MY_PING_URL );
ESP_LOGI( MY_PING_TAG, LOG_USER1( "ret = %d\n" ), ret );
return ESP_ERR_NOT_FOUND;
}
if( res->ai_family == AF_INET ) // ipv4
{
struct in_addr addr4 = ( (struct sockaddr_in *) (res->ai_addr) )->sin_addr;
inet_addr_to_ip4addr( ip_2_ip4( &target_addr ), &addr4 );
//target_addr.type = IPADDR_TYPE_V4;
ESP_LOGI( MY_PING_TAG, LOG_USER1( "IPv4 = %s" ), ip4addr_ntoa( &(target_addr.u_addr.ip4) ) );
}
else if( res->ai_family == AF_INET6 ) // ipv6
{
struct in6_addr addr6 = ( (struct sockaddr_in6 *) (res->ai_addr) )->sin6_addr;
inet6_addr_to_ip6addr( ip_2_ip6( &target_addr ), &addr6 );
//target_addr.type = IPADDR_TYPE_V6;
ESP_LOGI( MY_PING_TAG, LOG_USER1( "IPv6 = %s" ), ip6addr_ntoa( &(target_addr.u_addr.ip6) ) );
}
else // unknown
{
ESP_LOGI( MY_PING_TAG, LOG_USER1( "Unknown family = %d" ), res->ai_family );
}
freeaddrinfo(res);
esp_ping_config_t ping_config = ESP_PING_DEFAULT_CONFIG();
ping_config.target_addr = target_addr; // target IP address
ping_config.count = ESP_PING_COUNT_INFINITE; // ping in infinite mode, esp_ping_stop can stop it
ping_config.timeout_ms = 5000;
// set callback functions
esp_ping_callbacks_t cbs;
cbs.on_ping_success = test_on_ping_success;
cbs.on_ping_timeout = test_on_ping_timeout;
cbs.on_ping_end = test_on_ping_end;
cbs.cb_args = NULL; // arguments that will feed to all callback functions, can be NULL
esp_ping_handle_t ping;
esp_err_t e = esp_ping_new_session(&ping_config, &cbs, &ping);
if( e != ESP_OK )
{
ESP_LOGI( MY_PING_TAG, LOG_USER1( "Nao foi possivel criar a sessao ping !!!\nError = %s\n" ), esp_err_to_name( e ) );
return e;
}
e = esp_ping_start(ping);
if( e != ESP_OK )
{
ESP_LOGI( MY_PING_TAG, LOG_USER1( "Nao foi possivel iniciar o ping !!!\nError = %s\n" ), esp_err_to_name( e ) );
return e;
}
ESP_LOGI( MY_PING_TAG, LOG_USER1( "My Ping Start" ) );
return ESP_OK;
}
* esp-idf v5.1
* esp32-s3
* I am trying to connect esp32-S3 to Apache Server running on windows 11 to do a FOTA. I am using XAMPP.
* https://github.com/espressif/esp-idf/issues/11792
* https://github.com/espressif/esp-idf/issues/11814
Thank's.