Skip to content

Commit cd9baae

Browse files
committed
networkInterface: rename setLocalIPFull to config
1 parent b635f92 commit cd9baae

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

libraries/Ethernet/src/Ethernet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress ga
3333
IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
3434
setMACAddress(mac);
3535

36-
if (!NetworkInterface::setLocalIPFull(ip, subnet, gateway)) {
36+
if (!NetworkInterface::config(ip, subnet, gateway)) {
3737
return 0;
3838
}
3939

libraries/SocketWrapper/SocketHelpers.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,13 @@ bool NetworkInterface::disconnect() {
151151
return (net_if_down(netif) == 0);
152152
}
153153

154-
bool NetworkInterface::setLocalIPFull(IPAddress ip, IPAddress subnet, IPAddress gateway) {
155-
struct in_addr ip_addr, subnet_addr, gw_addr;
156-
157-
ip_addr.s_addr = ip;
158-
subnet_addr.s_addr = subnet;
159-
gw_addr.s_addr = gateway;
160-
161-
if (!net_if_ipv4_addr_add(netif, &ip_addr, NET_ADDR_MANUAL, 0)) {
162-
LOG_ERR("Failed to set static IP address");
163-
return false;
164-
}
165-
166-
net_if_ipv4_set_netmask(netif, &subnet_addr);
167-
net_if_ipv4_set_gw(netif, &gw_addr);
168-
LOG_INF("Static IP configured");
169-
return true;
154+
void NetworkInterface::config(const IPAddress ip, const IPAddress dns_server,
155+
const IPAddress gateway, const IPAddress subnet) {
156+
setLocalIP(ip);
157+
setDnsServerIP(dns_server);
158+
setGatewayIP(gateway);
159+
setSubnetMask(subnet);
160+
return;
170161
}
171162

172163
void NetworkInterface::setLocalIP(const IPAddress ip) {

libraries/SocketWrapper/SocketHelpers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class NetworkInterface {
4949
IPAddress gatewayIP();
5050
IPAddress dnsServerIP();
5151

52+
void config(const IPAddress ip, const IPAddress dns_server, const IPAddress gateway,
53+
const IPAddress subnet);
5254
void setMACAddress(const uint8_t *mac);
53-
bool setLocalIPFull(IPAddress ip, IPAddress subnet, IPAddress gateway);
5455
void setLocalIP(const IPAddress ip);
5556
void setSubnetMask(const IPAddress subnet);
5657
void setGatewayIP(const IPAddress gateway);

0 commit comments

Comments
 (0)