esp8266 wifi STA模式下获取IP地址并修改为新的IP

设置/获取 sta IP

		res_ap_get = tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &local_ip);
        printf("self:"IPSTR"\n",IP2STR(&local_ip.ip));
        printf("self:"IPSTR"\n",IP2STR(&local_ip.netmask));
        printf("self:"IPSTR"\n",IP2STR(&local_ip.gw));
        tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA);

        IP4_ADDR(&local_ip.ip, 192, 168 , 43, 150);
        IP4_ADDR(&local_ip.gw, 192, 168 , 43, 1);
        IP4_ADDR(&local_ip.netmask, 255, 255 , 255, 0);

        printf("set:"IPSTR"\n",IP2STR(&local_ip.ip));
        printf("set:"IPSTR"\n",IP2STR(&local_ip.netmask));
        printf("set:"IPSTR"\n",IP2STR(&local_ip.gw));

        res_ap_set = tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &local_ip);
        tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA);

你可能感兴趣的:(嵌入式)