IDF version 5.2.1 and am using the ping example code with a couple changes for debugging and binding to network interfaces. It appears to work without errors, but results in no pings reaching the target computer or ping success/fail callbacks being called.
Code: Select all
Output from monitor:
I (20605) net_action: Sending Ping
I (20605) ping: Interface eth1
I (20605) ping: Interface eth0
I (20605) net: Ping Initiated. Host: 192.168.0.163, IP: 192.168.0.163
Code: Select all
Ping initialization code:
send_ping("192.168.0.163");
void send_ping(char *host)
{
// Get the interface keys
uint8_t eth_idx = 0;
esp_netif_t *ifscan = esp_netif_next(NULL);
while (ifscan != NULL && u8KeyIndex < 3) {
eth_idx = esp_netif_get_netif_impl_index(ifscan);
char *desc = esp_netif_get_desc(ifscan);
ESP_LOGI("ping","Interface %s",desc);
ifscan = esp_netif_next(ifscan);
}
/* 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));
getaddrinfo(host, NULL, &hint, &res);
struct in_addr addr4 = ((struct sockaddr_in *) (res->ai_addr))->sin_addr;
inet_addr_to_ip4addr(ip_2_ip4(&target_addr), &addr4);
freeaddrinfo(res);
esp_ping_config_t ping_config = ESP_PING_DEFAULT_CONFIG();
ping_config.target_addr = target_addr; // target IP address
ping_config.count = 10; //ESP_PING_COUNT_INFINITE; // ping in infinite mode, esp_ping_stop can stop it
ping_config.interface = eth_idx;
/* 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 = "foo"; // arguments that feeds to all callback functions, can be NULL
//cbs.cb_args = eth_event_group;
esp_ping_handle_t ping;
ESP_ERROR_CHECK(esp_ping_new_session(&ping_config, &cbs, &ping));
ESP_LOGI("net","Ping Initiated. Host: %s, IP: %s",host, ip4addr_ntoa(&target_addr.u_addr.ip4));
}
I am successfully able to send broadcast messages (type 0x7000) and UDP packets to the same machine. Both IP addresses on my ESP32 board are pingable from the target host (192.168.0.163). Something is stuck internally in the ESP32 ping code.