Changing IP address at run time

Document created by analog-archivist Employee on Feb 23, 2016
Version 1Show Document
  • View in full screen mode

How do I change the static IP address, subnet mask, gateway at runtime?


When you fill in the static IP address in TCP/IP configuration manager under
Settings->TCP/IP configuration, the tools automatically update a couple of .c
files that are included in your project (they have the same name as the one you
chose when you clicked on 'save' in the TCP/IP configuration manager). You'll
notice that the structure user_net_config_info holds all the various parameters
you entered in the GUI. Now, check line 231 in the init_stack() function in:

"C:\Program Files\Analog Devices\VisualDSP

You'll notice that the code 'string copies' the IP address from
user_net_config_info struct. So, if you modify that structure (and specifically
the ipaddr member) before the call to init_stack, you should be good to go. The
init_stack is called in the file lwip_sysboot_threadtype.c by default when you
create an lwIP-based project. So, before you make this call, modify the
user_net_config_info structure's ipaddr member with the chosen IP addr, disable
DHCP and it should be good to go. These operations can be completed by pulling
up user_net_config_info struct in Expressions window.