|
From: | Xun Chen |
Subject: | [lwip-users] A better way to switch between static IP and DHCP? |
Date: | Wed, 4 Oct 2017 12:11:56 -0400 |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
Somehow my lwip user forum
subscription/setting/options was not functioning properly, and I
may have sent out this request multiple times since I tried to
figure out what was wrong. My apologies if it was the case...
Hi there, The following test was based on lwip 1.41 port on TI's TiVaware With #define LWIP_DHCP 1 & #define LWIP_AUTOIP 1 in lwipopts.h, I have no problem using DHCP lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_DHCP); With #define LWIP_DHCP 0 & #define LWIP_AUTOIP 0 in lwipopts.h, I also have no problem using static IP lwIPInit(g_ui32SysClock, pui8MACArray, inet_addr("55.0.168.192"), inet_addr("0.255.255.255"), inet_addr("1.0.168.192"), IPADDR_USE_STATIC); //The IP address was in a reversed order, but it works But if I wish to have both DHCP and Static IP feature, switching between them based on user configuration, I couldn't make it work without modifying lwiplib.c, ie. if I make lwipopts.h: #define LWIP_DHCP 1 #define LWIP_AUTOIP 1 .... if (USER_NEEDS_DHCP){ lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_DHCP); //This works } else{ lwIPInit(g_ui32SysClock, pui8MACArray, inet_addr("55.0.168.192"), inet_addr("0.255.255.255"), inet_addr("1.0.168.192"), IPADDR_USE_STATIC); } Static IP will not work I am sure I can modify lwiplib.c based on LWIP_DHCP and LWIP_AUTOIP conditions to make it work, but is there a better way to get the job done? Thanks! |
[Prev in Thread] | Current Thread | [Next in Thread] |