Skip to content

Commit b53dd95

Browse files
committed
Add constructor to handle string parameters
1 parent 1f3b9a5 commit b53dd95

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Diff for: src/Arduino_EthernetConnectionHandler.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,27 @@ EthernetConnectionHandler::EthernetConnectionHandler(IPAddress ip, IPAddress dns
4444

4545
}
4646

47+
EthernetConnectionHandler::EthernetConnectionHandler(const char * ip, const char * dns, const char * gateway, const char * netmask, bool const keep_alive)
48+
: ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
49+
,_ip{INADDR_NONE}
50+
,_dns{INADDR_NONE}
51+
,_gateway{INADDR_NONE}
52+
,_netmask{INADDR_NONE}
53+
{
54+
if(!_ip.fromString(ip)) {
55+
_ip = INADDR_NONE;
56+
}
57+
if(!_dns.fromString(dns)) {
58+
_dns = INADDR_NONE;
59+
}
60+
if(!_gateway.fromString(gateway)) {
61+
_gateway = INADDR_NONE;
62+
}
63+
if(!_netmask.fromString(netmask)) {
64+
_netmask = INADDR_NONE;
65+
}
66+
}
67+
4768
/******************************************************************************
4869
PROTECTED MEMBER FUNCTIONS
4970
******************************************************************************/

Diff for: src/Arduino_EthernetConnectionHandler.h

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class EthernetConnectionHandler : public ConnectionHandler
3333

3434
EthernetConnectionHandler(bool const keep_alive = true);
3535
EthernetConnectionHandler(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress netmask, bool const keep_alive = true);
36+
EthernetConnectionHandler(const char * ip, const char * dns, const char * gateway, const char * netmask, bool const keep_alive = true);
3637

3738

3839
virtual unsigned long getTime() override { return 0; }

0 commit comments

Comments
 (0)