Example #1
0
int
_tcpip_init(void)
{
  uip_ipaddr_t ipaddr;

  timer_set(&periodic_timer, CLOCK_SECOND/2);
  timer_set(&arp_timer, CLOCK_SECOND * 10);
  timer_set(&cli_timer, CLOCK_SECOND);
  
  mt76xx_dev_init();
  uip_init();

  //Printf_High("Tcp INIT \n");
#ifdef CONFIG_SOFTAP
	uip_ipaddr(ipaddr, 192,168,81,1);
	uip_sethostaddr(ipaddr);
	uip_ipaddr(ipaddr, 192,168,81,1);
	uip_setdraddr(ipaddr);
	uip_ipaddr(ipaddr, 255,255,255,0);
	uip_setnetmask(ipaddr);
//	Printf_High("TcpIP IniT===\n");
	uip_gethostaddr(ipaddr); 
#endif
 
  iot_udp_app_init();
  iot_tcp_app_init();

#ifndef CONFIG_SOFTAP
  if (IoTpAd.ComCfg.Use_DHCP!=1) {
	uip_ipaddr(ipaddr, IoTpAd.ComCfg.STATIC_IP[0],IoTpAd.ComCfg.STATIC_IP[1],
				IoTpAd.ComCfg.STATIC_IP[2],IoTpAd.ComCfg.STATIC_IP[3]);
	uip_sethostaddr(ipaddr);

	uip_ipaddr(ipaddr,IoTpAd.ComCfg.SubnetMask_IP[0], IoTpAd.ComCfg.SubnetMask_IP[1], 
				IoTpAd.ComCfg.SubnetMask_IP[2], IoTpAd.ComCfg.SubnetMask_IP[3]);
	uip_setnetmask(ipaddr);

	uip_ipaddr(ipaddr, IoTpAd.ComCfg.GateWay_IP[0], IoTpAd.ComCfg.GateWay_IP[1], 
				IoTpAd.ComCfg.GateWay_IP[2], IoTpAd.ComCfg.GateWay_IP[3]);
	uip_setdraddr(ipaddr);

#if CFG_SUPPORT_DNS
	uip_ipaddr(ipaddr, IoTpAd.ComCfg.DNS_IP[0],IoTpAd.ComCfg.DNS_IP[1],
				IoTpAd.ComCfg.DNS_IP[2],IoTpAd.ComCfg.DNS_IP[3]);
	resolv_conf(ipaddr);
	resolv_query("www.ablecloud.cn");
#endif
	dhcpc_set_state(STATE_CONFIG_DONE);
  }
#endif
  cli_fd = -1;
  return 0;
} 
Example #2
0
int
_tcpip_init(void)
{
    uip_ipaddr_t ipaddr;

    timer_set(&periodic_timer, CLOCK_SECOND/2);
    timer_set(&arp_timer, CLOCK_SECOND * 10);
    timer_set(&cli_timer, CLOCK_SECOND);

    mt76xx_dev_init();
    uip_init();

#ifdef CONFIG_SOFTAP
    uip_ipaddr(ipaddr, UIP_IPADDR0,UIP_IPADDR1,UIP_IPADDR2,UIP_IPADDR3);
    uip_sethostaddr(ipaddr);
    uip_ipaddr(ipaddr, UIP_IPADDR0,UIP_IPADDR1,UIP_IPADDR2,UIP_IPADDR3);
    uip_setdraddr(ipaddr);
    uip_ipaddr(ipaddr, UIP_NETMASK0,UIP_NETMASK1,UIP_NETMASK2,UIP_NETMASK3);
    uip_setnetmask(ipaddr);
    uip_gethostaddr(ipaddr);
#endif

    iot_udp_app_init();
    iot_tcp_app_init();

#ifdef CONFIG_STATION
    if (IoTpAd.ComCfg.Use_DHCP!=1) {
        uip_ipaddr(ipaddr, IoTpAd.ComCfg.STATIC_IP[0],IoTpAd.ComCfg.STATIC_IP[1],
                   IoTpAd.ComCfg.STATIC_IP[2],IoTpAd.ComCfg.STATIC_IP[3]);
        uip_sethostaddr(ipaddr);

        uip_ipaddr(ipaddr,IoTpAd.ComCfg.SubnetMask_IP[0], IoTpAd.ComCfg.SubnetMask_IP[1],
                   IoTpAd.ComCfg.SubnetMask_IP[2], IoTpAd.ComCfg.SubnetMask_IP[3]);
        uip_setnetmask(ipaddr);

        uip_ipaddr(ipaddr, IoTpAd.ComCfg.GateWay_IP[0], IoTpAd.ComCfg.GateWay_IP[1],
                   IoTpAd.ComCfg.GateWay_IP[2], IoTpAd.ComCfg.GateWay_IP[3]);
        uip_setdraddr(ipaddr);

#if CFG_SUPPORT_DNS
        uip_ipaddr(ipaddr, IoTpAd.ComCfg.DNS_IP[0],IoTpAd.ComCfg.DNS_IP[1],
                   IoTpAd.ComCfg.DNS_IP[2],IoTpAd.ComCfg.DNS_IP[3]);
        resolv_conf(ipaddr);
        resolv_query("www.baidu.com");
#endif
        dhcpc_set_state(STATE_CONFIG_DONE);
    }
#endif
    cli_fd = -1;
    return 0;
}