Skip to content

fix UdpContext::(connect,listen) signature by using IPAddress #5742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions libraries/ESP8266WiFi/src/include/UdpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,40 @@ class UdpContext
}
}

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);
Expand Down