GithubHelp home page GithubHelp logo

wolu / socket.io-arduino-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from billroy/socket.io-arduino-client

0.0 2.0 0.0 180 KB

A socket.io client for the Arduino Ethernet shield

License: MIT License

C++ 100.00%

socket.io-arduino-client's Introduction

SocketIO Arduino Client, an Arduino client for connecting and messaging with Socket.io servers

Based on Kevin Rohling's arduino websocket client modified to work with socket.io servers. Along the way, all uses of the String class were replaced with fixed char buffers so as to use less memory.

The bitlashsocketio.ino example provides an integration with Bitlash on the Arduino and a node.js example server that can be used to send Bitlash commands over the Websocket fabric to the Arduino, and see its output in reply.

Kevin's documentation is reproduced hereinafter, with changes as needed.

Caveats

This library doesn't support every inch of the Websocket spec, most notably the use of a Sec-Websocket-Key. Also, because Arduino doesn't support SSL, this library also doesn't support the use of Websockets over https. If you're interested in learning more about the Websocket spec I recommend checking out the Wikipedia Page. Now that I've got that out of the way, I've been able to successfully use this to connect to several hosted Websocket services, including: echo.websocket.org and pusherapp.com.

Installation instructions

Clone this repo into your Arduino Sketchbook directory under libraries, then restart the Arduino IDE so that it notices the new library. Now, under File\Examples you should see SocketIOClient.

How To Use This Library

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "echo.websocket.org";
WebSocketClient client;

void setup() {
  Serial.begin(9600);
  Ethernet.begin(mac);
  client.connect(server);
  client.setDataArrivedDelegate(dataArrived);
  client.send("Hello World!");
}

void loop() {
  client.monitor();
}

void dataArrived(WebSocketClient client, char *data) {
  Serial.println("Data Arrived: " + data);
}

Examples

There example included with this library, EchoExample, will connect to echo.websocket.org, which hosts a service that simply echos any messages that you send it via Websocket. This example sends the message "Hello World!". If the example runs correctly, the Arduino will receive this same message back over the Websocket and print it via Serial.println.

socket.io-arduino-client's People

Contributors

billroy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.