WebSockets

I created a project to experiment with web sockets. In addition to the mBed code you will need the client side code which is in the .zip file below.

The demo code can run a common anode RGB connect to p23(red), P22(green) and P21(blue). The color of the LED can be sent by sending a ASCII-HEX rrggbb string message through the WebSocket. The demo will also send a temperature measurement of an 10K RTC sensor connected to GND with a 10K pull on p20.

I modified the HTTP server found in the Cookbook to support the WebSockets.

Import programWebSockets2

Embedded WebSockets Experiment

/media/uploads/nandgate/experiment.zip


2 comments on WebSockets:

16 Dec 2011

So the MBED is the server ? ....... and the client side code resides on the MBED server and is executed by the local client .... Is that correct ? 99guspuppet

16 Dec 2011

Joanne, Yes that is correct. The MBed is HTTP server with WebSockets capability. The client side code (HTML, CSS, JavaScript, images, etc) reside in the File System on the MBed. When a client request a page it loads those resources. When the JavaScript code (running on the client) initiates a WebSocket, the MBed accepts the connection and starts communicating real time information over the WebSocket. Note that the WebSocket connections bi-directional.

Please log in to post comments.