Go Down

Topic: How to change size of readstring() in client.read() on Arduino Ethernet? (Read 3 times) previous topic - next topic

zoomkat

Quote
I tried to find the readstring function to modify its size but it just says "size" in the Ethernetclient.cpp file. How can I set it? Where is it stored? Does anybody know?


In your origional posted code, I don't see any attempt to do some cleanup like below. Did you inclued this?

Code: [Select]

         //clearing string for next read
         readString="";
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

zoomkat

Also, I think there is a limit to the number of characters in a "get" request, maybe something like 128. Are you exceeding this number?

Code: [Select]
        if (readString.length() < 150) {
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

nathanas

All i'm doing is this...

Code: [Select]
char tBuf[64];
 void loop()
{

 Serial.println("11");  
 EthernetClient client = server.available();
 if(client) {
   Serial.println("12");  
   boolean currentLineIsBlank = true;
   boolean currentLineIsGet = true;
   int tCount = 0;
   char tBuf[64];
 

   Serial.print("Client request: ");

   while (client.connected()) {
     Serial.println("13");  
     while(client.available()) {
       Serial.println("14");  
       char c = client.read();

       if(currentLineIsGet && tCount < 63)
       {

         tBuf[tCount] = c;
         tCount++;
         tBuf[tCount] = 0;          
       }


       if (c == '\n' && currentLineIsBlank) {
         // send a standard http response
         .....CODE
}
}
}
}

With 2x if (strstr...) statements it works ok, but if I add another one it stacks.
It only prints "11" once.

SurferTim

Try this: I used user and pwd because they are shorter, and password is a common packet sniffer target.
Code: [Select]
if (c == '\n' && currentLineIsBlank) {
  if(strstr(tBuf,"user=admin") != NULL && strstr(tBuf,"pwd=mypasswd") !=NULL) {
    Serial.println("Logged in");
    // do the rest of your stuff here
  }
  else Serial.println("Login failed"); 
}


nathanas

It just freezes and needs to be reseted every time..
Is there another command so I can check for "user" in an char array?
Or is something wrong with my "if strstr" ??

Go Up