Skip to content

Commit a14cd11

Browse files
committed
patch for 2.4.x
1 parent 2d5674f commit a14cd11

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AsyncPing(esp8266)
2-
version=1.0.0
2+
version=1.1.0
33
author=Jes
44
maintainer=jes <[email protected]>
55
sentence=Enables asynchronous ping. For Espressif's ESP8266 MCUs.

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ This is a fully asynchronous Ping library for Espressif's ESP8266 MCUs.
33
have full ping statistic and hardware MAC address
44

55
tested on 2.3.0 esp8266/Arduino
6+
patched for 2.4.x
67

78
to install:
89
`git clone https://github.com/akaJes/AsyncPing.git ~/Arduino/libraries/AsyncPing`

src/AsyncPing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void AsyncPing::ping_prepare_echo(struct icmp_echo_hdr *iecho, u16_t len) {
136136
iecho->chksum = inet_chksum(iecho, len);
137137
}
138138

139-
u8_t AsyncPing::ping_recv (raw_pcb*pcb, pbuf*p, ip_addr*addr) {
139+
u8_t AsyncPing::ping_recv (raw_pcb*pcb, pbuf*p, C_IP_ADDR ip_addr_t *addr) {
140140
struct icmp_echo_hdr *iecho = NULL;
141141
struct ip_hdr *ip = (struct ip_hdr *)p->payload;
142142
if (pbuf_header( p, -PBUF_IP_HLEN) == 0) {
@@ -146,7 +146,7 @@ u8_t AsyncPing::ping_recv (raw_pcb*pcb, pbuf*p, ip_addr*addr) {
146146
_response.ttl = ip->_ttl;
147147
_response.answer = true;
148148
_response.total_recv++;
149-
ip_addr_t *unused_ipaddr;
149+
C_IP_ADDR ip_addr_t *unused_ipaddr;
150150
if (_response.mac == NULL)
151151
etharp_find_addr(NULL, addr, &_response.mac, &unused_ipaddr);
152152
if (_on_recv){
@@ -162,7 +162,7 @@ u8_t AsyncPing::ping_recv (raw_pcb*pcb, pbuf*p, ip_addr*addr) {
162162
return 0; /* don't eat the packet */
163163
}
164164

165-
u8_t AsyncPing::_s_ping_recv (void*arg, raw_pcb*tpcb, pbuf*pb, ip_addr*addr){
165+
u8_t AsyncPing::_s_ping_recv (void*arg, raw_pcb*tpcb, pbuf*pb, C_IP_ADDR ip_addr_t *addr){
166166
return reinterpret_cast<AsyncPing*>(arg)->ping_recv(tpcb, pb, addr);
167167
}
168168

src/AsyncPing.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "IPAddress.h"
22
#include <functional>
3+
#include "core_version.h"
34

45
extern "C" {
56
#include <lwip/raw.h>
@@ -21,7 +22,11 @@ class AsyncPingResponse{
2122
u32_t timeout;
2223
IPAddress addr;
2324
};
24-
25+
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
26+
#define C_IP_ADDR
27+
#else
28+
#define C_IP_ADDR const
29+
#endif
2530
class AsyncPing{
2631
public:
2732
typedef std::function< bool (const AsyncPingResponse& ) > THandlerFunction;
@@ -54,8 +59,8 @@ class AsyncPing{
5459
void send_packet();
5560
void ping_send(struct raw_pcb *raw, ip_addr_t *addr);
5661
void ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len);
57-
u8_t ping_recv (raw_pcb*pcb, pbuf*p, ip_addr*addr);
58-
static u8_t _s_ping_recv (void*arg, raw_pcb*tpcb, pbuf*pb, ip_addr*addr);
62+
u8_t ping_recv (raw_pcb*pcb, pbuf*p, C_IP_ADDR ip_addr_t *addr);
63+
static u8_t _s_ping_recv (void*arg, raw_pcb*tpcb, pbuf*pb, C_IP_ADDR ip_addr_t *addr);
5964
THandlerFunction _on_recv;
6065
THandlerFunction _on_sent;
6166
};

0 commit comments

Comments
 (0)