Skip to content

Commit 82291da

Browse files
committed
Add return code for beginPacket
1 parent c171117 commit 82291da

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libraries/WiFi/src/WiFiUdp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ void arduino::WiFiUDP::stop() {
4646
int arduino::WiFiUDP::beginPacket(IPAddress ip, uint16_t port) {
4747
nsapi_addr_t convertedIP = {NSAPI_IPv4, {ip[0], ip[1], ip[2], ip[3]}};
4848
_host = SocketAddress(convertedIP, port);
49-
return 1;
49+
//If first octet of assigned IP is 0 and port is 0 the initialization failed
50+
return (_host.get_addr().bytes[0] == 0 && _host.get_port() == 0) ? 0 : 1;
5051
}
5152

5253
int arduino::WiFiUDP::beginPacket(const char *host, uint16_t port) {

0 commit comments

Comments
 (0)