krohling / ArduinoWebsocketClient

Websocket client for Arduino
227 stars 72 forks source link

WiFly/UART support #5

Open perezd opened 12 years ago

perezd commented 12 years ago

I thought we could make this official, so I started a pull request.

So, the reliance on the WiFlySerial module (here: https://github.com/perezd/arduino-wifly-serial) makes our WiFlyClient shim very small.

Outstanding concerns:

  1. how do we get an instance of WiFlySerial into the ArduinoWebSocketClient? My WiFlyClient class expects an instance as part of its constructor, not sure what the best way is to accomplish this just yet. That bit of integration, I could use help with.
  2. does it work? :) I'm not super sharp with C++ so, I'd appreciate a thorough code review.

NOTE: lets not pull this into master yet, until we've got it working, just wanted this here for discussion purposes.

krohling commented 12 years ago

Hi Derek, I was hoping to take a look at this yesterday but didn't get the opportunity. I will be offline this weekend but will make reviewing this a priority for Monday. Thanks for putting this together and sorry for the delay.

-kevin

On Feb 10, 2012, at 4:08 PM, Derek Perez reply@reply.github.com wrote:

I thought we could make this official, so I started a pull request.

So, the reliance on the WiFlySerial module (here: https://github.com/perezd/arduino-wifly-serial) makes our WiFlyClient shim very small.

Outstanding concerns:

  1. how do we get an instance of WiFlySerial into the ArduinoWebSocketClient? My WiFlyClient class expects an instance as part of its constructor, not sure what the best way is to accomplish this just yet. That bit of integration, I could use help with.
  2. does it work? :)

You can merge this Pull Request by running:

git pull https://github.com/perezd/ArduinoWebsocketClient wifly-support

Or you can view, comment on it, or merge it online at:

https://github.com/krohling/ArduinoWebsocketClient/pull/5

-- Commit Summary --

  • initial sketches of the WiFlyClient integration.
  • simplified the API a bit, implemented what I believe to be the necessary API mapping. untested.
  • don't need path as part of the connect signature.
  • not sure that we need that .h

-- File Changes --

M WebSocketClient.cpp (39) M WebSocketClient.h (23) A WiFlyClient.cpp (40) A WiFlyClient.h (40)

-- Patch Links --

https://github.com/krohling/ArduinoWebsocketClient/pull/5.patch https://github.com/krohling/ArduinoWebsocketClient/pull/5.diff


Reply to this email directly or view it on GitHub: https://github.com/krohling/ArduinoWebsocketClient/pull/5

perezd commented 12 years ago

Cool, I've just committed some Debugging stuff we can take out later on. Also, trying to simplify the data type requirements here and there. Here's where I'm at right now, I'm trying to run this code: https://gist.github.com/4daf3c2a14c9e9a28d88

It appears to hang on the call to _client.connect() within the WebSocketClient.cpp, not sure what to do :(

Its possible that my C++ code doesn't work, at all. Something about the ampersands? I dunno, hoping you can help me get through this bit.

krohling commented 12 years ago

Hey perezd, I pulled this down, tried giving it a go today and unfortunately I ran into a few issues. First, I wanted to try testing out the WiFlySerial library to make sure things were working as expected on my device but I wasn't able to get any of the examples to build. I copied build output for WiFly_Test.pde below. I feel like having a working example of this library is a first step, let me know if I've possibly done something wrong here.

Also, the EchoExample.ino included with the ArduinoWebsocketClient wasn't building either. This appears to have been related to some missing include statements and a mismatch with the WebsocketClient constructor.

Some thoughts: -Regarding integration with WiFlySerial, perhaps an instance could be passed to the WebsocketClient via a constructor. Then inside the constructor the WebsocketClient will pass the WiFlySerial instance to an instance of WiFlyClient. -Another note, it's important that Ethernet users not have a compile dependency on the WiFlySerial classes so any include statements will need to be #ifdef 'ed out. -I think from a source code perspective the best way to add this dependency would eventually be via a git submodule.

_WiFly_Test build output_

WiFly_Test.cpp:9:23: error: Streaming.h: No such file or directory WiFly_Test.cpp: In function 'void setup()': WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "Free memory:"' WiFly_Test.pde:-1: error: 'endl' was not declared in this scope WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "Starting WiFly."' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "Free memory:"' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "WiFly begin mem:"' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "MAC: "' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "Leave:"' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "SSID Set :"' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "Passphrase Set :"' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "Joining... :"' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "Joined "' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "Join to "' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "IP: "' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "WiFly Sensors: "' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "WiFly Temp: "' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "WiFly battery: "' WiFly_Test.pde:-1: error: no match for 'operator<<' in 'Serial << "After Setup mem:"'

_EchoExample build output_

In file included from /libraries/ArduinoWebsocketClient/WiFlyClient.h:5, from /libraries/ArduinoWebsocketClient/WebSocketClient.h:37, from EchoExample.cpp:4: /libraries/ArduinoWebsocketClient/WiFlySerial.h:55:28: error: SoftwareSerial.h: No such file or directory /libraries/ArduinoWebsocketClient/WiFlySerial.h:57:23: error: Streaming.h: No such file or directory In file included from /libraries/ArduinoWebsocketClient/WiFlyClient.h:5, from /libraries/ArduinoWebsocketClient/WebSocketClient.h:37, from EchoExample.cpp:4: /libraries/ArduinoWebsocketClient/WiFlySerial.h:135: error: 'SoftwareSerial' does not name a type EchoExample:7: error: no matching function for call to 'WebSocketClient::WebSocketClient()' /libraries/ArduinoWebsocketClient/WebSocketClient.h:50: note: candidates are: WebSocketClient::WebSocketClient(WiFlySerial&) /libraries/ArduinoWebsocketClient/WebSocketClient.h:45: note: WebSocketClient::WebSocketClient(const WebSocketClient&)

perezd commented 12 years ago

I think you may be missing the dependencies of WiFlySerial, you need the following:

That should make the WiFlySerial project work better :) As for the example of it working, I've had mixed results with the examples folder, here is a gist of the exact code I use that is working 100% everytime: https://gist.github.com/bbcf140ff9aeebc9efc0

You should be able to telnet to whatever IP address it gives you (check the serial output), on port 2000, and send it l key and h key, on their own lines, and have it send high/low signals to port 9, I'm using it to light up an led.

Good call on the ifdefs, I guess the thing to do is to checkout my fork/branch and commit changes to it? Definitely need a bit of guidance, I've not written for arduino/C++ before, really.

perezd commented 12 years ago

any updates?

krohling commented 12 years ago

Derek, You were right I was just missing some dependencies. I pulled those down and your gist built successfully! I went in and made some changes to add a couple of constructors to WebSocketClient specifically for configuring the WiFlyClient. This also required making a few changes to the WiFlyClient class as well, let me know what you think. Once that was done it was very easy to update the EchoExample to use the new WiFly classes. I committed all of this to the perezd-wifly-support branch.

Unfortunately while everything is compiling I wasn't able to successfully get my WiFly board to connect to a network. This could very well (probably) be a hardware issue on my end. Can you try running the WiFly_EchoExample and see if it works on your board?

P.S. I like your idea of making the WiFlyClient essentially mimic the Ethernet API methods and passing those through. As you stated, it's a thin shim.

Thanks, -kevin

On Feb 15, 2012, at 11:18 AM, Derek Perez wrote:

any updates?


Reply to this email directly or view it on GitHub: https://github.com/krohling/ArduinoWebsocketClient/pull/5#issuecomment-3986954

perezd commented 12 years ago

Hey Kevin, I'm going to be testing this out right now. I'll get back to you shortly, sorry for the delay!

perezd commented 12 years ago

So yeah, this is where I was at as well...I can't seem to figure out why this doesn't run, either. Do you know anyone we can get into this to peek at our work?

perezd commented 12 years ago

It seems like something goes wrong as soon as _client.connect happens, not sure how else to investigate :(

krohling commented 12 years ago

Yep, I'm seeing the same thing. On my device it gets stuck inside the call to _WiFly.begin() (inside WiFlyClient.initializeWiFly()). It's possible that I need to configure the tx/rx pins. Also, what Arduino board are you using? I'm on a Mega 2560 with rerouted pins 10-13 to 50-53.

Also, there was a patch to the official WiFly library posted today to support Arduino 1.0. I haven't tried it yet but it's promising: https://github.com/sparkfun/WiFly-Shield/issues/7

-kevin

On Feb 17, 2012, at 11:16 AM, Derek Perez wrote:

It seems like something goes wrong as soon as _client.connect happens, not sure how else to investigate :(


Reply to this email directly or view it on GitHub: https://github.com/krohling/ArduinoWebsocketClient/pull/5#issuecomment-4025986

alexbain commented 12 years ago

Running into the same problem - something around _client.connect.

Any new ideas on what's happening?

nilakshdas commented 11 years ago

Anything happening on this front?

krohling commented 11 years ago

I haven't had time to do anymore work on this. I'd love to hear if anyone was able to get it working though.