From dec1dc0c18fd4f8ac18d7df646839b69b7da6fd0 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 4 Jul 2021 22:04:34 +0200 Subject: [PATCH] Fix ping on Esp32 --- tasmota/xdrv_38_ping.ino | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tasmota/xdrv_38_ping.ino b/tasmota/xdrv_38_ping.ino index 93bad2b82..5a0ab9097 100644 --- a/tasmota/xdrv_38_ping.ino +++ b/tasmota/xdrv_38_ping.ino @@ -99,7 +99,7 @@ extern "C" { // ================================================================================ // Prepare a echo ICMP request // - void ICACHE_FLASH_ATTR t_ping_prepare_echo(struct icmp_echo_hdr *iecho, uint16_t len, Ping_t *ping) { + void t_ping_prepare_echo(struct icmp_echo_hdr *iecho, uint16_t len, Ping_t *ping) { size_t data_len = len - sizeof(struct icmp_echo_hdr); ICMPH_TYPE_SET(iecho, ICMP_ECHO); @@ -125,7 +125,7 @@ extern "C" { struct pbuf *p; uint16_t ping_size = sizeof(struct icmp_echo_hdr) + Ping_data_size; - ping->ping_time_sent = micros(); + ping->ping_time_sent = millis(); p = pbuf_alloc(PBUF_IP, ping_size, PBUF_RAM); if (!p) { return; } if ((p->len == p->tot_len) && (p->next == nullptr)) { @@ -135,7 +135,7 @@ extern "C" { ping_target.addr = ping->ip; #endif // ESP8266 #ifdef ESP32 - ping_target.u_addr.ip4.addr = ping->ip; + ip_addr_set_ip4_u32(&ping_target, ping->ip); #endif // ESP32 iecho = (struct icmp_echo_hdr *) p->payload; @@ -191,8 +191,7 @@ extern "C" { if (iecho->seqno != ping->seqno){ // debounce already received packet /* do some ping result processing */ sys_untimeout(t_ping_timeout, ping); // remove time-out handler - uint32_t delay = micros() - ping->ping_time_sent; - delay /= 1000; + uint32_t delay = millis() - ping->ping_time_sent; ping->sum_time += delay; if (delay < ping->min_time) { ping->min_time = delay; }