Skip to content

Commit 91dc7b8

Browse files
committed
Adopt helper function in WiFiIdp
1 parent e1e58b1 commit 91dc7b8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

libraries/WiFi/src/WiFiUdp.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ uint8_t arduino::WiFiUDP::beginMulticast(IPAddress ip, uint16_t port) {
4343
if(begin(port) != 1){
4444
return 0;
4545
}
46+
47+
SocketAddress socketAddress = WiFi.socketAddressFromIpAddress(ip, port);
4648

47-
nsapi_addr_t multicastGroup = {NSAPI_IPv4, {ip[0], ip[1], ip[2], ip[3]}};
48-
49-
if (_socket.join_multicast_group(SocketAddress(multicastGroup)) != NSAPI_ERROR_OK) {
49+
if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK) {
5050
printf("Error joining the multicast group\n");
5151
return 0;
5252
}
@@ -58,9 +58,8 @@ void arduino::WiFiUDP::stop() {
5858
_socket.close();
5959
}
6060

61-
int arduino::WiFiUDP::beginPacket(IPAddress ip, uint16_t port) {
62-
nsapi_addr_t convertedIP = {NSAPI_IPv4, {ip[0], ip[1], ip[2], ip[3]}};
63-
_host = SocketAddress(convertedIP, port);
61+
int arduino::WiFiUDP::beginPacket(IPAddress ip, uint16_t port) {
62+
_host = WiFi.socketAddressFromIpAddress(ip, port);
6463
//If IP is null and port is 0 the initialization failed
6564
return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1;
6665
}

0 commit comments

Comments
 (0)