/***************************************************************************** 函 数 名 : uip_app_init 功能描述 : the uip appliacation function 输入参数 : void 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2017年4月17日 作 者 : QSWWD 修改内容 : 新生成函数 *****************************************************************************/ void uip_app_init(void) { uip_ipaddr_t ipaddr; uip_ipaddr(ipaddr, 8,8,8,8); /* hello_world_init();*/ /* resolv_init(); uip_ipaddr(ipaddr, 195,54,122,204); resolv_conf(ipaddr); resolv_query("www.sics.se");*/ example1_init(); example2_init(); telnetd_init(); smtp_init(); uip_ipaddr(ipaddr, 127,0,0,1); smtp_configure("localhost", ipaddr); SMTP_SEND("*****@*****.**", NULL, "*****@*****.**", "Testing SMTP from uIP", "Test message sent by uIP\r\n"); hello_world_init(); httpd_init(); #if UIP_UDP my_udp8899_init(); dhcpc_init(&uip_ethaddr,6); resolv_init(); resolv_conf(ipaddr); resolv_query("www.baidu.com"); #endif }
/***************************************************************************** * Main Control Loop * * *****************************************************************************/ int main(void) { unsigned char i; unsigned char arptimer=0; // PORTB PB5 als Ausgang (in use LED) DDRB=(1<<PB5); PORTB=(1<<PB5); init_sensors(); // init NIC device driver nic_init(); // init uIP uip_init(); // init app example1_init(); // init ARP cache uip_arp_init(); // init periodic timer initTimer(); sei(); // initialisierendes lesen der Temperatur(en) read_temp_sensors(); while(1) { if(minInt==1){ minInt=0; read_temp_sensors(); } // look for a packet uip_len = nic_poll(); if(uip_len == 0) { // if timed out, call periodic function for each connection //if(timerCounter > TIMERCOUNTER_PERIODIC_TIMEOUT) if(tInt) { tInt = 0; //timerCounter = 0; for(i = 0; i < UIP_CONNS; i++) { uip_periodic(i); // transmit a packet, if one is ready if(uip_len > 0) { uip_arp_out(); nic_send(); } } /* Call the ARP timer function every 10 seconds. */ if(++arptimer == 20) { uip_arp_timer(); arptimer = 0; } } } else // packet received { // process an IP packet if(BUF->type == htons(UIP_ETHTYPE_IP)) { // add the source to the ARP cache // also correctly set the ethernet packet length before processing uip_arp_ipin(); uip_input(); // transmit a packet, if one is ready if(uip_len > 0) { uip_arp_out(); nic_send(); } } // process an ARP packet else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); // transmit a packet, if one is ready if(uip_len > 0) nic_send(); } } } return 1; }