1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

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
This commit is contained in:
david gauchard 2019-02-11 13:46:40 +01:00 committed by GitHub
parent 5948b0fc52
commit 6c5269a74b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,20 +90,40 @@ public:
}
}
bool connect(const ip_addr_t* addr, uint16_t port)
#if LWIP_VERSION_MAJOR == 1
bool connect(IPAddress addr, uint16_t port)
{
_pcb->remote_ip = *addr;
_pcb->remote_ip = addr;
_pcb->remote_port = port;
return true;
}
bool listen(CONST ip_addr_t* addr, uint16_t port)
bool listen(IPAddress addr, uint16_t port)
{
udp_recv(_pcb, &_s_recv, (void *) this);
err_t err = udp_bind(_pcb, addr, port);
return err == ERR_OK;
}
#else // lwIP-v2
bool connect(const IPAddress& addr, uint16_t port)
{
_pcb->remote_ip = addr;
_pcb->remote_port = port;
return true;
}
bool listen(const IPAddress& addr, uint16_t port)
{
udp_recv(_pcb, &_s_recv, (void *) this);
err_t err = udp_bind(_pcb, addr, port);
return err == ERR_OK;
}
#endif // lwIP-v2
void disconnect()
{
udp_disconnect(_pcb);