Hello to everyone! I am very new to community and to arduino environment. I have started a small project using my arduino GIGA R1 WiFi.
I do not know if I have to post my code as it is almost 1000 lines. The logic behind it is that when it is powered on if there are no saved datas in its memory then it starts an access point where a user can connect to it and pass al the necessaries parameters to login in a local network. When it is connecting then the AP stops and it creates a server in a specific ip and port. At first I do get/post requests with success. But after some time, all the requests I do fails. I use some logs and I verify that: 1) my server is running, 2) Arduino is connecting to local network, 3) the flow do not enter in if (client.connected() { .... }, 4) I use client.flush(); client.stop(); .
I post the void where the requests for server are coming.
void AccessPointRequests() {
WiFiClient client;
if (isServerRunning) {
client = elevatorServer.available();
} else {
client = server.available();
}
if (status == WL_CONNECTED) {
if (client.connected()) {
TurnOnBlueLed();
String request = "";
if (Serial) Serial.println("There is an incoming message!");
if (Serial) Serial.println("New Client connected for Elevator Module!");
request = client.readStringUntil('\r');
// Handle GET Request
if (request.indexOf("GET / ") >= 0) {
client.print("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n");
client.print("Hello, this is a development from Poseidon Software!");
} else if (request.indexOf("GET /question1") >= 0) {
sendResponse1(client);
} else if (request.indexOf("GET /question2") >= 0) {
sendResponse2(client);
} else if (request.indexOf("GET /question3") >= 0) {
sendResponse3(client);
}
// Handle POST Request
else if (request.indexOf("POST / ") >= 0) {
handlePost(client, request);
} else {
client.print("HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\n404: Not Found");
}
client.flush();
client.stop();
contentType = "";
AuthorType = "";
if (Serial) Serial.println("Client disconnected from Elevator Module!");
TurnOnGreenLed();
}
return;
}
...
...
}
I have tried almost anything and I do not understand why all the requests after some times 30 minutes, or 20 minutes, in general in random times, my requests fail. I remind you that when arduino starts, all the requests are working with no problem.