From 9f3e6da4564ad8a7f636c198ec99c0052b17d95d Mon Sep 17 00:00:00 2001 From: joaquinbvw Date: Mon, 23 Jan 2017 12:03:31 -0500 Subject: [PATCH 1/2] Creating the function setStaticIP I am currently working on a project and needed a function to change the network configuration while the Tiva was active and because of local requeriments we can't use a DHCP server, so I checked the lwiplib library and found the lwIPNetworkConfigChange function and decide to add that functionality to my local Ethernet library. I think this could be a useful function, I saw some people on the internet asking for such functionality. --- libraries/Ethernet/Ethernet.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libraries/Ethernet/Ethernet.cpp b/libraries/Ethernet/Ethernet.cpp index 8259cef..097cf07 100644 --- a/libraries/Ethernet/Ethernet.cpp +++ b/libraries/Ethernet/Ethernet.cpp @@ -76,6 +76,21 @@ int EthernetClass::maintain() return 0; } +int EthernetClass::setStaticIP(IPAddress local_ip, IPAddress gateway, IPAddress subnet) +{ + struct ip_addr ipaddr; + struct ip_addr net_mask; + struct ip_addr gw_addr; + + IP4_ADDR(&ipaddr, local_ip[0], local_ip[1], local_ip[2], local_ip[3]); + IP4_ADDR(&net_mask, subnet[0], subnet[1], subnet[2], subnet[3]); + IP4_ADDR(&gw_addr, gateway[0], gateway[1], gateway[2], gateway[3]); + + lwIPNetworkConfigChange(htonl(ipaddr.addr),htonl(net_mask.addr),htonl(gw_addr.addr),IPADDR_USE_STATIC); + + return 0; +} + IPAddress EthernetClass::localIP() { return lwIPLocalIPAddrGet(); From 1c3da264b9045a5b24341a6569f7b701ea87b25a Mon Sep 17 00:00:00 2001 From: joaquinbvw Date: Mon, 23 Jan 2017 12:04:42 -0500 Subject: [PATCH 2/2] Creating the function setStaticIP I am currently working on a project and needed a function to change the network configuration while the Tiva was active and because of local requeriments we can't use a DHCP server, so I checked the lwiplib library and found the lwIPNetworkConfigChange function and decide to add that functionality to my local Ethernet library. I think this could be a useful function, I saw some people on the internet asking for such functionality. --- libraries/Ethernet/Ethernet.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/Ethernet/Ethernet.h b/libraries/Ethernet/Ethernet.h index cd1fb79..f11e6e7 100644 --- a/libraries/Ethernet/Ethernet.h +++ b/libraries/Ethernet/Ethernet.h @@ -40,6 +40,8 @@ class EthernetClass { /* For Arduino compatibility */ int maintain(); + + int setStaticIP(IPAddress local_ip, IPAddress gateway, IPAddress subnet); /* IP Address related functions */ IPAddress localIP();