(1)场景 设备: PC, 路由器,CC3200 开发板。 PC 连接路由器 ,CC3200 作为station模式连接路由器。
现象:CC3200使用DHCP方式分配IP地址正常。请问CC3200是否可以静态分配IP地址,即将CC3200的IP设置为固定的地址(与路由器在同一个网段)?谢谢。
Viki Shi:
论坛有类似问题,解答请看这边: http://www.deyisupport.com/question_answer/wireless_connectivity/wifi/f/105/t/76374.aspx
Terry Han:
直接使用API函数
Setting a static IP address to the device working in STA mode or P2P client.The IP address will be stored in the FileSystem.In order to disable the static IP and get the address assigned from DHCP one should use SL_STA_P2P_CL_IPV4_DHCP_SET
SlNetCfgIpV4Args_t ipV4;ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2PipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway addressipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4); sl_Stop(0);sl_Start(NULL,NULL,NULL);