# example-mainloop-without-arp.c

    00001 #include "uip.h"
    00002 #include "uip_arp.h"
    00003 #include "network-device.h"
    00004 #include "httpd.h"
    00005 #include "timer.h"
    00006
    00007 /*---------------------------------------------------------------------------*/
    00008 int
    00009 main(void)
    00010 {
    00011   int i;
    00012   uip_ipaddr_t ipaddr;
    00013   struct timer periodic_timer;
    00014
    00015   timer_set(&periodic_timer, CLOCK_SECOND / 2);
    00016
    00017   network_device_init();
    00018   uip_init();
    00019
    00020   uip_ipaddr(ipaddr, 192,168,0,2);
    00021   uip_sethostaddr(ipaddr);
    00022
    00023   httpd_init();
    00024
    00025   while(1) {
    00026     uip_len = network_device_read();
    00027     if(uip_len > 0) {
    00028       uip_input();
    00029       /* If the above function invocation resulted in data that
    00030          should be sent out on the network, the global variable
    00031          uip_len is set to a value > 0. */
    00032       if(uip_len > 0) {
    00033         network_device_send();
    00034       }
    00035     } else if(timer_expired(&periodic_timer)) {
    00036       timer_reset(&periodic_timer);
    00037       for(i = 0; i < UIP_CONNS; i++) {
    00038         uip_periodic(i);
    00039         /* If the above function invocation resulted in data that
    00040            should be sent out on the network, the global variable
    00041            uip_len is set to a value > 0. */
    00042         if(uip_len > 0) {
    00043           network_device_send();
    00044         }
    00045       }
    00046
    00047 #if UIP_UDP
    00048       for(i = 0; i < UIP_UDP_CONNS; i++) {
    00049         uip_udp_periodic(i);
    00050         /* If the above function invocation resulted in data that
    00051            should be sent out on the network, the global variable
    00052            uip_len is set to a value > 0. */
    00053         if(uip_len > 0) {
    00054           network_device_send();
    00055         }
    00056       }
    00057 #endif /* UIP_UDP */
    00058     }
    00059   }
    00060   return 0;
    00061 }
    00062 /*---------------------------------------------------------------------------*/