查看WiFi.config()的源代码
←
WiFi.config()
跳转至:
导航
、
搜索
因为以下原因,你没有权限编辑本页:
你刚才请求的操作只对属于该用户组的用户开放:
用户
您可以查看并复制此页面的源代码:
:[[WiFi库|WiFi]] {| border="0" cellpadding="20" width="100%" |- |width="100%" valign="top" align="left"| <font color="olivedrab" size="+3">'''config()'''</font> <font color="orange" size="+1">'''描述'''</font> <span style="background:lightblue">WiFi.config()</span> allows you to configure a static IP address as well as change the DNS, gateway, and subnet addresses on the WiFi shield. Unlike <span style="background:lightblue">WiFi.begin()</span> which automatically configures the WiFi shield to use DHCP, <span style="background:lightblue">WiFi.config()</span> allows you to manually set the network address of the shield. Calling <span style="background:lightblue">WiFi.config()</span> before <span style="background:lightblue">WiFi.begin()</span> forces <span style="background:lightblue">begin()</span> to configure the WiFi shield with the network addresses specified in <span style="background:lightblue">config()</span>. You can call <span style="background:lightblue">WiFi.config()</span> after <span style="background:lightblue">WiFi.begin()</span>, but the shield will initialize with <span style="background:lightblue">begin()</span> in the default DHCP mode. Once the <span style="background:lightblue">config()</span> method is called, it will change the network address as requested. <font color="orange" size="+1">'''语法'''</font> WiFi.config(ip); WiFi.config(ip, dns); WiFi.config(ip, dns, gateway); WiFi.config(ip, dns, gateway, subnet); <font color="orange" size="+1">'''参数'''</font> '''ip''': the IP address of the device (array of 4 bytes) '''dns''': the address for a DNS server. '''gateway''': the IP address of the network gateway (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1 '''subnet''': the subnet mask of the network (array of 4 bytes). optional: defaults to 255.255.255.0 <font color="orange" size="+1">'''返回值'''</font> Nothing <font color="orange" size="+1">'''示例'''</font> This example shows how to set the static IP address, 192.168.0.177, of the LAN network to the WiFi shield: <pre style="color:dimgray"> #include <SPI.h> #include <WiFi.h> // the IP address for the shield: IPAddress ip(192, 168, 0, 177); char ssid[] = "yourNetwork"; // your network SSID (name) char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP) int status = WL_IDLE_STATUS; void setup() { // Initialize serial and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } // check for the presence of the shield: if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); while(true); // don't continue } WiFi.config(ip); // attempt to connect to Wifi network: while ( status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); // Connect to WPA/WPA2 network. Change this line if using open or WEP network: status = WiFi.begin(ssid, pass); // wait 10 seconds for connection: delay(10000); } // print your WiFi shield's IP address: Serial.print("IP Address: "); Serial.println(WiFi.localIP()); } void loop () {} </pre> |} ---- [[WiFi库|返回WiFi库]] [[Arduino库|返回Arduino库菜单]] [[首页|返回首页]] 更多建议和问题欢迎反馈至 [http://www.yfrobot.com YFRobot论坛]
返回
WiFi.config()
。
导航菜单
个人工具
登录
名字空间
页面
讨论
不转换
变种
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
台灣正體
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
YF-论坛提问
YFRobot-直营店
YFRobot-企业店
Arduino
Arduino之入门篇
Arduino入门教程
Arduino语法参考
Arduino库
Arduino核心代码
编程平台
Mixly库
Mind+库
MakeCode扩展
传感器系列
积木式传感器系列
黑板传感器系列
蓝板传感器系列
Micro:Bit
Micro:Bit 通用基础教程
Valon智能车
Valon-I
帮助
帮助
wiki语法参考
工具箱
链入页面
相关更改
特殊页面
页面信息