From d513d5362c8572a5721e7628ead88329f9773e37 Mon Sep 17 00:00:00 2001 From: lottaviano Date: Tue, 24 May 2011 13:41:13 +0000 Subject: [PATCH] Update the tcp_server example to use the correct ip input callback. Use tcpip_input() as the network interface function, it's required when using a kernel. Change the IP address shown into a string and add a comment. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4921 38d2e660-2303-0410-9eaa-f027e97ec537 --- boards/at91sam7x-ek/examples/tcp_server/main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/boards/at91sam7x-ek/examples/tcp_server/main.c b/boards/at91sam7x-ek/examples/tcp_server/main.c index c99a995d..71e67882 100644 --- a/boards/at91sam7x-ek/examples/tcp_server/main.c +++ b/boards/at91sam7x-ek/examples/tcp_server/main.c @@ -88,7 +88,7 @@ static void init(void) tcpip_init(NULL, NULL); /* Bring up the network interface */ - netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, ip_input); + netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input); netif_set_default(&netif); netif_set_up(&netif); } @@ -118,13 +118,16 @@ int main(void) proc_new(monitor_process, NULL, KERN_MINSTACKSIZE * 2, NULL); dhcp_start(&netif); + /* + * Here we wait for an ip address, but it's not strictly + * necessary. The address is obtained in background and + * as long as we don't use network functions, we could go + * on with initialization + */ while (!netif.ip_addr.addr) - { - dhcp_fine_tmr(); - timer_delay(DHCP_FINE_TIMER_MSECS); - } - kprintf(">>> dhcp ok: ip = %#x (kernel %s)\n", - (unsigned int)netif.ip_addr.addr, + timer_delay(200); + kprintf(">>> dhcp ok: ip = ip = %s (kernel %s)\n", + ip_ntoa(&netif.ip_addr.addr), CONFIG_KERN_PREEMPT ? "preempt" : "coop"); server = netconn_new(NETCONN_TCP); -- 2.25.1