你好:
我的目的是修改AP模式下的IP地址,同时修改DHCP地址池适应修改的后的IP地址。
但是修改后连接不上(电脑端不能通过DHCP获取IP地址),请问时什么原因?
下面是函数源码。
//第一步修改DHCP
SlNetAppDhcpServerBasicOpt_t dhcpParams; _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t); dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address
dhcpParams.ipv4_addr_start = ((ipV4->ipV4)&0x00)|0x02; // first IP Address for allocation. IP Address should be set as Hex number – i.e. 0A0B0C01 for (10.11.12.1)
dhcpParams.ipv4_addr_last = ((ipV4->ipV4)&0x00)|0xfa; // last IP Address for allocation. IP Address should be set as Hex number – i.e. 0A0B0C01 for (10.11.12.1)
sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID); // Stop DHCP server before settings
sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen, (_u8* )&dhcpParams); // set parameters
sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID); // Stop DHCP server before settings
//第二步修改AP IP
lRetVal = sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)ipV4);
ASSERT_ON_ERROR(lRetVal);
//重启设备
Yonghua Pan:
你在STOP之后sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID);, 它是会把这个设置记录下来的,你需要再启动它才可以。