如何在Arduino中使WifiClient.connect工作?

时间:2017-05-08 00:27:23

标签: arduino android-wifi android-bluetooth

我想知道WifiClient.connect是否不允许连接本地运行的服务器(例如http://localhost:8080)。我发现当网址是公共的(例如www.google.com)时,WifiClient.connect可以正常工作。如果有可能我可以通过编程方式更改以连接localhost服务器,请提供帮助。以下代码是setup()的一部分。

status = WiFi.begin(ssid, pass);

// if you're not connected, stop here:
if ( status != WL_CONNECTED) { 
  Serial.println("Couldn't get a wifi connection");
  while(true);
} 
// if you are connected, print out info about the connection:
else {
  Serial.println("Connected to network");
}

// configure the uri to be called
char apiURL[] = "127.0.0.1";

uint16_t port = 8080;    

if (client.connect(apiURL, port)){
  Serial.println("connected to " + String(apiURL)); 
  // it always prints this statement
}else{
  Serial.println("not calling " + String(apiURL));
}

我想问的另一个(也许是愚蠢的)事情:当我希望我的Arduino将数据发送到服务器(例如发出POST请求)时,蓝牙是否比Wifi更好?

0 个答案:

没有答案