Skip to content

Commit 9961e55

Browse files
committed
doc for new interface
1 parent 11a502f commit 9961e55

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

keywords.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,29 @@
77
#######################################
88

99
AsyncPing KEYWORD1
10+
AsyncPingResponse KEYWORD1
1011

1112
#######################################
1213
# Methods and Functions (KEYWORD2)
1314
#######################################
1415

1516
on KEYWORD2
16-
init KEYWORD2
17-
17+
begin KEYWORD2
1818
cancel KEYWORD2
19+
response KEYWORD2
20+
1921
answer KEYWORD2
2022

2123
addr KEYWORD2
2224
time KEYWORD2
23-
seq KEYWORD2
25+
icmp_seq KEYWORD2
2426
ttl KEYWORD2
2527
size KEYWORD2
2628

2729
total_sent KEYWORD2
2830
total_recv KEYWORD2
2931
total_time KEYWORD2
32+
timeout KEYWORD2
3033
mac KEYWORD2
3134

3235
######################################

readme.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ have full ping statistic and hardware MAC address
55
usage
66
```
77
AsyncPing ping;
8-
ping.on(true,[](AsyncPing& host){
9-
if (host.answer()) {
10-
Serial.printf("%d bytes from %s: icmp_seq=%d ttl=%d time=%d ms\n",host.size(),host.addr().toString().c_str(),host.seq(),host.ttl(),host.time());
11-
if (host.mac())
12-
Serial.printf("detected eth address " MACSTR "\n",MAC2STR(host.mac()->addr));
13-
} else
14-
Serial.printf("no answer yet for %s icmp_seq=%d\n",host.addr().toString().c_str(),host.seq());
8+
ping.on(true,[](const AsyncPingResponse& response){
9+
IPAddress addr(response.addr); //to prevent with no const toString() in 2.3.0
10+
if (response.answer)
11+
Serial.printf("%d bytes from %s: icmp_seq=%d ttl=%d time=%d ms\n", response.size, addr.toString().c_str(), response.icmp_seq, response.ttl, response.time);
12+
else
13+
Serial.printf("no answer yet for %s icmp_seq=%d\n", addr.toString().c_str(), response.icmp_seq);
14+
return false; //do not stop
1515
});
16-
ping.init(WiFi.gatewayIP());
16+
ping.on(false,[](const AsyncPingResponse& response){
17+
IPAddress addr(response.addr); //to prevent with no const toString() in 2.3.0
18+
Serial.printf("total answer from %s sent %d recevied %d time %d ms\n",addr.toString().c_str(),response.total_sent,response.total_recv,response.total_time);
19+
if (response.mac)
20+
Serial.printf("detected eth address " MACSTR "\n",MAC2STR(response.mac->addr));
21+
return true;
22+
});
23+
24+
ping.begin(WiFi.gatewayIP());
1725
```

0 commit comments

Comments
 (0)