#include <WiFi.h>

const char* ssid = "OPPOA5s";
const char* password = "megzzzzz";

const char* serverIP = "192.168.43.115";
const int serverPort = 80;

WiFiClient client;

void setup() {

  Serial.begin(115200);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi...");
  }

  Serial.println("Connected to WiFi");

  if (client.connect(serverIP, serverPort)) {
    Serial.println("Connected to Server");
  } else {
    Serial.println("Connection Failed");
  }
}

void loop() {

  if (Serial.available()) {
    String msg = Serial.readStringUntil('\n');
    client.println(msg);
  }

  if (client.available()) {
    String reply = client.readStringUntil('\n');
    Serial.print("Received: ");
    Serial.println(reply);
  }

}







