Skip to content

Commit 6c5269a

Browse files
authored
fix UdpContext::(connect,listen) signature by using IPAddress (#5742)
* fix UdpContext::listen signature by using IPAddress * fix UdpContext::connect signature by using IPAddress by courtesy of @AlfredLamoule
1 parent 5948b0f commit 6c5269a

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

libraries/ESP8266WiFi/src/include/UdpContext.h

+23-3
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,40 @@ class UdpContext
9090
}
9191
}
9292

93-
bool connect(const ip_addr_t* addr, uint16_t port)
93+
#if LWIP_VERSION_MAJOR == 1
94+
95+
bool connect(IPAddress addr, uint16_t port)
9496
{
95-
_pcb->remote_ip = *addr;
97+
_pcb->remote_ip = addr;
9698
_pcb->remote_port = port;
9799
return true;
98100
}
99101

100-
bool listen(CONST ip_addr_t* addr, uint16_t port)
102+
bool listen(IPAddress addr, uint16_t port)
101103
{
102104
udp_recv(_pcb, &_s_recv, (void *) this);
103105
err_t err = udp_bind(_pcb, addr, port);
104106
return err == ERR_OK;
105107
}
106108

109+
#else // lwIP-v2
110+
111+
bool connect(const IPAddress& addr, uint16_t port)
112+
{
113+
_pcb->remote_ip = addr;
114+
_pcb->remote_port = port;
115+
return true;
116+
}
117+
118+
bool listen(const IPAddress& addr, uint16_t port)
119+
{
120+
udp_recv(_pcb, &_s_recv, (void *) this);
121+
err_t err = udp_bind(_pcb, addr, port);
122+
return err == ERR_OK;
123+
}
124+
125+
#endif // lwIP-v2
126+
107127
void disconnect()
108128
{
109129
udp_disconnect(_pcb);

0 commit comments

Comments
 (0)