Hello, I have tried in different ways and I cannot establish the connection correctly via wifi-esp32. any ideas?
When it connects, I can see that repetier-host correctly sends the data to the esp32-wifi, I see it through the serial port of the Esp32. Photo 1
https://ibb.co/Csk94LM
When it sent data over serial , relayed over wifi, the repetier-host captured correctly. photo 2
… I do not know what I'm doing wrong. Help -___-
https://ibb.co/Ry7M83L<br/></pre></div><div><br/></div><div>#include <WiFi.h>
const char* ssid = "wifi";
const char* password = "123456";
WiFiServer server(8080);
void setup()
{
Serial.begin(115200);
// pinMode(5, OUTPUT); // set the LED pin mode
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
size_t len=0;
size_t len2=0;
byte sbuf[128];
byte sbuf2[128];
void loop(){
WiFiClient client = server.available(); // listen for incoming clients
if (client) { // if you get a client,
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
len = client.available();
client.readBytes(sbuf, len);
Serial.write(sbuf,len);
}
if (Serial.available()) {
len2 = Serial.available();
Serial.readBytes(sbuf2, len2);
client.write(sbuf2, len2);
}
}
client.stop();
}
}