📜  esp32 dhcp server - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:39.950000             🧑  作者: Mango

代码示例1
WiFiServer server(80);

static const char *ap_ssid = "ESP32-001";
static const char *ap_pass = "temp_pass";

void setup() {
  Serial.begin(115200);

  WiFi.softAP(ap_ssid, ap_pass);
  Serial.print("Access point running. IP address: ");
  Serial.print(WiFi.softAPIP());
  Serial.println("");

  server.begin();
}

void loop() {
  WiFiClient client = server.available();

  if (client) {
    String client_ip = client.remoteIP().toString();
    Serial.print("Client connected. IP address = ");
    Serial.print(client_ip);
    Serial.println("");
    client.println("Hello ...");
    client.stop();
  }
}