Skip to content

Commit

Permalink
Adopt helper function in WiFiIdp
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Aug 11, 2020
1 parent e1e58b1 commit 91dc7b8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions libraries/WiFi/src/WiFiUdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ uint8_t arduino::WiFiUDP::beginMulticast(IPAddress ip, uint16_t port) {
if(begin(port) != 1){
return 0;
}

SocketAddress socketAddress = WiFi.socketAddressFromIpAddress(ip, port);

nsapi_addr_t multicastGroup = {NSAPI_IPv4, {ip[0], ip[1], ip[2], ip[3]}};

if (_socket.join_multicast_group(SocketAddress(multicastGroup)) != NSAPI_ERROR_OK) {
if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK) {
printf("Error joining the multicast group\n");
return 0;
}
Expand All @@ -58,9 +58,8 @@ void arduino::WiFiUDP::stop() {
_socket.close();
}

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

0 comments on commit 91dc7b8

Please sign in to comment.