lwip Examples
Page last updated
31 Mar 2011, by
Paul Hutton.
2
replies
2 comments on lwip Examples:
Seems that this page has been removed. I'm using these libraries on an older project with LPC2368 which I'm trying to update, shame the pages are gone. :(
Have they been archived anywhere?
In case anyone else is looking - I was trying to find out to setup a static IP address instead of the DHCP with the ethernet tester software.
[NOTE this is for the older LWIP libraries from a few years back; ignore this if you're using the latest supported mbed networking stack]
Here's a code snippet with the answer:
printf("setting up netif...\r\n");
/* Set static IP address if required */
IP4_ADDR(&netmask, 255,255,255,0); // look at your router or type ipconfig on your PC for more info
IP4_ADDR(&gateway, 192,168,0,1); // this should be the IP address of your router
IP4_ADDR(&ipaddr, 192,168,0,16); // this is a static address you chose, the first 3 numbers should match your router, and the final number can be 2..255 but should be a number that's not already being used. e.g. setup the DHCP server on your router to start at 50, then use a fixed ip <50
/* Initialise after configuration */
lwip_init();
netif->hwaddr_len = ETHARP_HWADDR_LEN;
device_address((char *)netif->hwaddr);
netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, device_init, ip_input);
netif->hostname = hostname;
netif_set_default(netif);
/* Start Network with static IP address */
printf("Configuring device for STATIC IP ADDR...\r\n");
netif_set_up(netif);
/* Start Network with DHCP */
// printf("Configuring device for DHCP...\r\n");
// dhcp_start(netif); // <-- Use DHCP
Please log in to post comments.
Seems that this page has been removed. I'm using these libraries on an older project with LPC2368 which I'm trying to update, shame the pages are gone. :(
Have they been archived anywhere?