【问题标题】:How establish connection between ESP32 as access point and local server如何在 ESP32 作为接入点和本地服务器之间建立连接
【发布时间】:2022-01-13 23:03:41
【问题描述】:

我必须向本地服务器发送文件,所以我使用httpClient 并尝试在主机上使用帖子:http://127.0.0.1:5000/show-version,在串行监视器中,但它不起作用,ESP 又是接入点模式


    void SendVersion (){
        client.begin(HOST);
        client.addHeader("Content-Type", "text/plain");
        int response = client.POST(version);
        if(response>0){
      
          String response = client.getString();  //Get the response to the request
        
          Serial.println(response);   //Print return code
          Serial.println(response);           //Print request answer
    
        }else{
      
          Serial.print("Error on sending POST: ");
          Serial.println(response);
      
        }
        client.end(); 
    }

【问题讨论】:

    标签: http arduino esp32 ota


    【解决方案1】:

    127.0.0.1 是一个特殊的 IP 地址,意思是“这台计算机或设备”。当您在 ESP32 上使用它时,它意味着 ESP32,而不是您尝试连接的服务器。它也被称为localhost - 同样是运行软件的计算机或设备的简写。它不能识别外部计算机。

    您需要使用您尝试连接的服务器的实际 IP 地址。如何找到取决于服​​务器运行的操作系统 - 如果您不知道如何操作,请使用 Google 查找。

    当然,如果 ESP32 处于 AP 模式,那么它尝试与之通信的服务器需要连接到 ESP32 的 wifi 网络,以便 ESP32 能够与之通信。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-20
      • 2012-04-24
      • 2012-04-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多