Go Down

Topic: Ethernet Sheild and GSM router (Read 3 times) previous topic - next topic

pylon

Have you tried doing the same connection (to the websocket server) on your laptop using the telnet command? I guess it's not an Arduino problem but one on the network, somewhere between your GSM router and the server.

gibbon

Quote
Have you tried doing the same connection (to the websocket server) on your laptop using the telnet command?


Yes and it works fine.

Quote
I guess it's not an Arduino problem but one on the network, somewhere between your GSM router and the server.


But i can plug my laptop into the GSM router and connect to the server fine? Unplug laptop, plug in arduino and cant connect.

thanks
Andy

pylon

The error is in the library you're using:

Code: [Select]
    while(_client.available() == 0 && attempts < maxAttempts)
    {
        delay(100);
        attempts++;
    }
   
    while((line = readLine()) != "") {
        handshake += line + '\n';
    }


The code is waiting for up to 30 seconds for one character to arrive but then the whole answer has to be there completely. I'd guess that the GSM modem is splitting the packets into smaller packets and the library code isn't prepared for that.

gibbon

Ahh ok, ive looked at this code for while thinking this is where the problem (if any) must lie.

I will give it ago despite my C++ not being to good, but i have to ask, do you have any idea how to impliment a workaround to wait for all packets before proceeding?

Thanks
Andy

pylon

Although this is an ugly hack, it might be enough for your needs:

Code: [Select]
    while(_client.available() < 14 && attempts < maxAttempts)
    {
        delay(100);
        attempts++;
    }
   
    while((line = readLine()) != "") {
        handshake += line + '\n';
    }


This way you're waiting for at least the string to be arrived you're testing for afterwards.

BTW: the author of the library did a lot of work to move the constant strings to the flash memory (PROGMEM) but then uses the String class which wastes more memory than he saved with the first action but making the code much more complex.

Go Up