arduino_uip icon indicating copy to clipboard operation
arduino_uip copied to clipboard

Websockets using arduino_uip

Open samehhady opened this issue 11 years ago • 7 comments
trafficstars

First of all thank you for your great effort. I am wondering if it is possible to implement websockets using this library and maybe be able to use the Pusher library https://github.com/krohling/ArduinoPusherClient

Pusher is already compitable with Arduino Ethernet library, it would be great if it can be used with arduino_uip.

samehhady avatar Nov 25 '13 12:11 samehhady

So go ahead, test and report your results. The only issue I can see with this library is its haevy use of String-class. You may easily run out ouf RAM as UIPEthernet requires aprox. 400-500 bytes and just crashes when your Sketch allocates more than available so you override your heap or stacks memory. Sketches running with the original Ethernet-lib (with W5100 based shield) are less susceptible to memory-corruption as the stack runs 100% on the Hardware, so even if you override heap memory chances are good the next call to Server.available() succeeds anyway (no gurantee made as the remainder or your Sketch might hang anyway...) So I think you should use at least a Mega260 to run this library with UIPEthernet

ntruchsess avatar Nov 25 '13 13:11 ntruchsess

Thank you for your reply, I guess we will never know till we actually try it out. I will try it out and let you guys know how did it go.

samehhady avatar Nov 25 '13 14:11 samehhady

FInally am able to test it now, but am getting this error:

In file included from /Users/Sam/Documents/Arduino/libraries/PusherClient/PusherClient.h:33, from /Users/Sam/Documents/Arduino/libraries/PusherClient/PusherClient.cpp:25: /Users/Sam/Documents/Arduino/libraries/PusherClient/WebSocketClient.h:49: error: 'EthernetClient' does not name a type

Any idea whats the reason ?

samehhady avatar Dec 27 '13 17:12 samehhady

UIPEthernet.h is not included (maybe it's not resolved). If you are using Arduino 1.5.x it's most likely that the library-files are not in correct location, so you might check using Arduino 1.0.5. (I do not support Arduino 1.5.x out of the box yet as the 1.5.x library-specification is not stable yet). To see what is included and from which directories you can switch on debugging-output for compilation in Arduino setting.

Don't forget you have to include UIPEthernet.h in the sketch itself. Due to the way the Arduino-IDE works including it indirectly from the PusherClient-lib itself is not sufficient.

That is just gessing... If you want me to understand what really is going on, please submit complete code to reproduce.

  • Norbert

ntruchsess avatar Dec 29 '13 14:12 ntruchsess

Hi ntruchsess, Well I am using Arduino 1.0.4 I am already including the Library files in †he main sketch & in PusherClient ( it was referring to ethernet library ) Let me share the code with you.

You can access the full library from here: https://github.com/krohling/ArduinoPusherClient

What I did is:

#include < Servo.h > #include < SPI.h > #include < UIPEthernet.h > #include < PusherClient.h >

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; PusherClient client; Servo leftServo; Servo rightServo;


And in WebSocketClient.h I changed it to:

#ifndef WEBSOCKETCLIENT_H #define WEBSOCKETCLIENT_H_

#include < string.h > #include < stdlib.h > #include < WString.h > #include < UIPEthernet.h > #include " Arduino.h"

It didn't work that way, Do I need to include it again else where?

I am using the Robot example in the pusher library, too many lines to post here so i thought it better to share with you the link directly.

Thanks again

samehhady avatar Dec 30 '13 05:12 samehhady

I tested ArduinoPusherLibrary with UIPEthernet today. Seems to be working fine. Just make sure you change the #include in WebSocketClient.h to use UIPEthernet.h.

rayshobby avatar Jan 18 '15 21:01 rayshobby

Unfortunately on an atmega328 I'm quickly running out of program space with both UIPEthernet and the PusherClient lib. A very basic sketch of about 30 lines with one bind() takes 96% of prog mem:

Sketch uses 29,566 bytes (96%) of program storage space. Maximum is 30,720 bytes.

I don't think I'll be able to use these libs together, sadly as using websocket was perfect for integration with other clients than arduino.

rawouter avatar Feb 10 '15 22:02 rawouter