mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
commit
d362b494b8
@ -99,7 +99,7 @@ extern "C" {
|
|||||||
// ================================================================================
|
// ================================================================================
|
||||||
// Prepare a echo ICMP request
|
// 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);
|
size_t data_len = len - sizeof(struct icmp_echo_hdr);
|
||||||
|
|
||||||
ICMPH_TYPE_SET(iecho, ICMP_ECHO);
|
ICMPH_TYPE_SET(iecho, ICMP_ECHO);
|
||||||
@ -125,7 +125,7 @@ extern "C" {
|
|||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
uint16_t ping_size = sizeof(struct icmp_echo_hdr) + Ping_data_size;
|
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);
|
p = pbuf_alloc(PBUF_IP, ping_size, PBUF_RAM);
|
||||||
if (!p) { return; }
|
if (!p) { return; }
|
||||||
if ((p->len == p->tot_len) && (p->next == nullptr)) {
|
if ((p->len == p->tot_len) && (p->next == nullptr)) {
|
||||||
@ -135,7 +135,7 @@ extern "C" {
|
|||||||
ping_target.addr = ping->ip;
|
ping_target.addr = ping->ip;
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
ping_target.u_addr.ip4.addr = ping->ip;
|
ip_addr_set_ip4_u32(&ping_target, ping->ip);
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
iecho = (struct icmp_echo_hdr *) p->payload;
|
iecho = (struct icmp_echo_hdr *) p->payload;
|
||||||
|
|
||||||
@ -191,8 +191,7 @@ extern "C" {
|
|||||||
if (iecho->seqno != ping->seqno){ // debounce already received packet
|
if (iecho->seqno != ping->seqno){ // debounce already received packet
|
||||||
/* do some ping result processing */
|
/* do some ping result processing */
|
||||||
sys_untimeout(t_ping_timeout, ping); // remove time-out handler
|
sys_untimeout(t_ping_timeout, ping); // remove time-out handler
|
||||||
uint32_t delay = micros() - ping->ping_time_sent;
|
uint32_t delay = millis() - ping->ping_time_sent;
|
||||||
delay /= 1000;
|
|
||||||
|
|
||||||
ping->sum_time += delay;
|
ping->sum_time += delay;
|
||||||
if (delay < ping->min_time) { ping->min_time = delay; }
|
if (delay < ping->min_time) { ping->min_time = delay; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user