DDP and Arduino

Update 1: I added "'s around the 1’s and it’s now saying it’s connected! This embarrassing. At least people are aware there’s an Arduino DDP library in the works. :joy:
Update 2: I’ve just written a quick README and pushed the repo onto GitHub at https://github.com/jesse-c/Arduino-DDP. smile As I said in the README, it’s specific to my thesis example. Also, the use of the timer and the style of listen() will change.

I’m working on a DDP client for Arduinos as part of my thesis. At the moment I have it making a websocket connection to server:port/websocket successfully using the Arduino-WebSocket library. When I send a well-formed connect message it fails and I can’t find out why! Is there a way I can find a more verbose log on why it failed? I’ve searched for a while and can’t find anything… Also, the connect messages aren’t showing up when using dd-analyzer like they do when going to server:port with a browser.

Here’s the output from my Arduino:

Connected to server
Client connected
Sending websocket upgrade headers
Analyzing response headers
Waiting...
Got Header: HTTP/1.1 101 Switching Protocols
Got Header: upgrade: websocket
Got Header: connection: Upgrade
Got Header: sec-websocket-accept: lC1PUH/PcUsVoRmYURv+7CQ/abk=
Got Header: 
Websocket established
Handshake successful
Sending data: {"msg":"connect","version":1,"support":[1]}
Received response: {"msg":"failed","version":"1"}

And yes, I’m of course going to release this as a library if I get it working. :slight_smile:

4 Likes

If you haven’t already, please put your work-in-progress on Github so we can collaborate. I’ve wanted to build an Arduino DDP client as well!

I’ve just written a quick README and pushed the repo onto GitHub at https://github.com/jesse-c/Arduino-DDP. :slight_smile: As I said in the README, it’s specific to my thesis example. Also, the use of the timer and the style of listen() will change.

Tanks for the lib !

The DDP::handshake return
"Handshake failed."

Do you know what i miss?

No problem, unfortunately it’s still very WIP! Would you posting your code? I’ll have a look.

@jsc

I realize this post is two months old, but I had to post to say: this is awesome. AWEsome! I’m following your progress, because how cool would it be to have your robot talk to your Meteor app?

Actually, I’m following your progress because I want to write a DDP library for AVR microcontrollers. I know your Arduino library can be adapted to work directly on an ATmega328 or something, using a bootloader or through other means. But some of my smaller microcontrollers (e.g. ATtiny series) are too small for C++ code.

Have you come across any really good DDP resources (blogs, tutorials, books) in your work?

@thebionicman Thanks for your enthusiasm! Unfortunately I haven’t done any work recently (just started my grad software engineering job) but hopefully we clean it up. Your enthusiasm makes me want to work on it too haha. There’s been a couple of forks but no pull requests yet. Follow-up the repo so you don’t miss out on any updates.

That’s really cool that you plan on building an AVR library. I think a difficulty you might come across is finding a good websocket and json libraries on AVR but I haven’t looked so there might be good ones! You’re right though about the smaller ones being, well, too small. Mostly for memory space (this is an issue even with Arduino Mega’s if you aren’t wise) and also processing speed to be able to process a messaging protocol in realtime if you the code isn’t optimised, and especially any libraries used.

As far as resources for understanding DDP itself, I was already familiar with messaging protocols so I didn’t look for many resources. I did a quick look now and found a blog post that might be useful.

For building the library, I simply had the spec open. I did look through the MDG’s JS implementation along with some other third-party ones but in the end I didn’t rely on them much at all.

Thanks, man! Your ability to get the project up while going to school inspired me. I’m studying electrical eng and plan to work in robotics ultimately. But I’ve found it difficult to find time for fun projects (hardware or software) while maintaining my GPA.

That’s an excellent point. I usually use the ATmega1284 series because all the AVR chips in roughly the same price range (cheap) and it’s in the deep end of the pool, in terms of capacity. Also, I haven’t learned to solder surface-mounted chips yet, so that’s a serious handicap. But yeah, I knew a DDP server was out of the question but thought I’d look into the possibility of running a DDP client on an AVR chip. ARM would be better, of course, but the learning curve is much steeper. I’m still trying to get on an intermediate level with AVR hardware/software.

That’s encouraging. I was listening to a podcast in which Matt DeBergalis gave an interview yesterday, and he said the DDP spec would fit on 3 pages if printed out. Specs don’t get much more concise than that, I suppose.

On a side note (sort of), I’m not sure what you’re studying, but have you worked with ROS (Robot Operating System) at all? Its core is also built around a pub/sub system, written in C++, and since I discovered and started working with Meteor a couple of weeks ago, I’ve been thinking about the intersection of these two frameworks.

They seem very similar in terms of their architecture, despite being from two different and distinct domains. I know I can’t be the first person to ponder that. I just wondered if you’d used ROS, and, if so, if you’d made anything that uses ROS and Meteor together.

I must admit, this project was a small part of my thesis so it wasn’t a true side project! It was the same for me though, trying to balance a good GPA vs. side projects! I graduated from software engineering a few weeks ago.

Solder? Just use a microwave. :joy: But yeah, soldering is an important skill, especially for electrical engineering.

Yup, the spec is super simple and easy to follow! Unfortunately I hadn’t heard of ROS at all but it does look quite interesting. Meteor’s tight use of DDP is great because again, DDP being such a simple pub/sub system it makes it easy to integrate with existing software/hardware.

@jsc please review the issue I posted on your github project. Thanks!

Hey @nspangler, I’ll try and get onto this soon but I can’t give an
ETA at the moment.

@jsc thanks, I really appreciate it!

Hi @jsc , I think there is some update related to the ArduinoJson?

1 Like