I'm trying to use my arduino uno with WifiShield to connect a webserver and to be connected by clients, that is, some clients send some data to arduino's webserver and arduino sends some data to a webserver.
Now, when I tried it for the first time, it worked perfect. Yet then, I realised that when I send the same form from the same device to arduino it gets nothing. It's a simple circuit on which I want to make a LED on if the one who is trying to do this is in my database, namely s/he is eligible to do so. So, if I click to the link to send an ID from a device to arduino, arduino can read (or get) the message but when the same device with same ID or another device with a different ID tries to send their ID, what ardunio gets is nothing. Henceforth, how can I make my arduino to serve more than one request?
ps: since the computer on which I code my programs has no wireless connection or any usb ports I couldn't attach the code, sorry
First, I'm not asking for you to tell what is wrong, I'm asking for you to tell me how. I suppose it's a huge difference. Whatsoever.
Let me write pseudocode-like then.
void setup() {
....
id="";
server.begin();
}
void loop() {
while(1) {
if(LEDon && millis()-lastOn > interval ) {
make led off;
LEDon=false;
}
if(id==""&& !LEDon) {
call respond2httpRequest(); //as server to the device
}
}
if(id!="") {
call makeHttpRequest2Server();
while(server.available()) {
read char c from server;
if(c==1) {
make led on;
LEDon=true;
id="";
}
if(c==0) {
make led off;
LEDon=false;
id="";
}
}
}
}
//I don't think the following function is necessary
makeHttpRequest2Server() {
...
}
I use the same code changed only slightly for the WiFi shield, and it works. The WiFi server library has some pretty serious bugs, so be forewarned. It uses only one socket, so multiple client requests performed simultaneously can cause the incorrect or corrupted files to be returned by the server.
I'm gonna write the code here. So, forget the pseudo-code please.
It's assumed that there will be no simultaneous requests. The problem is I cannot make the same request more than once or cannot make another request from another device.
The problem with the code I could have shown you, that I couldn't yet is I cannot make the same request more than once or cannot make another request from another device.
Fair enough. But, now we are back to reply #1, where I suggested that you are asking for help with code you haven't posted, which you got all snippy about.
If you have read the rest, you could probably notice that the while-loop is not used instead of loop(). I just wanted to limit loop(). Your attitude is totally offending. You may assume that there exists no other way than yours, yet that is highly probable to end up with being a loser that doesn't even know that s/he is loser.
Whatsoever, any help would be apperiated except PaulS's. And apparently he is one of the big boys here, let's see if there will be any attempt to help.
Am I correct that you are trying to implement a server and a client in that code? Where in the code is it failing? Does it fail (freeze) or just keep going and fails to detect new client requests?
I used this code to troubleshoot my code. It shows the status of the sockets on the wifi shield. Maybe this will help you.
Yes, you are right, it gets an HTTP request for password from a client as a server and sends an HTTP request for password again to a server as a client. Arduino compares them and then sends a signal according to the result of the comparison. The problem is it keeps going and fails to detect new client. For the first time it works fine, for other requests it prints empty string instead of Username and password on Serial.
PS: Perhaps, I misunderstood him. If so, apologies PaulS. I just felt offended, but if what you intended to do is not being offensive forgive me for being rude .
s is initially 1, after the first form is submitted, it becomes 196 and after a while becomes 166 and stays so; and d is initially 0, after the first form is submitted becomes 1 and stays the same.
I suppose it stops listening. So, what is the problem, I couldn't get it.