Difference between revisions of "BBB WebSockets"
(→Copying to Development Host)
(→Download and Build)
|Line 25:||Line 25:|
After a short time cmake
After a short time cmake figured out the configuration of the BBB and generated a Makefile. So issue
...build $] make
...build $] make
Revision as of 15:08, 10 December 2015
WebSocket is an add-on to the ordinary HTTP protocol. The client can ask for an "upgraded" connection. If the server responds correctly you have a connection similar to TCP from the web client (the web browser) and the server.
In the event that a program controls some attached hardware or the like from the BBB there are several possibilities fro exchanging information with a web client acting as the user interface (UI). It is possible to launch Apache on the BBB and use for instance PHP to write a program that will respond with the requested data to the UI. There are several other ways to launch a server that enables communication between the UI and the controlling software. But why not built it into the controlling software itself?
On libwebsockets.org is a light weight library for C programs. It is quite stable and rather well documented.
Download and Build
On the BBB issue
$] git clone git://git.libwebsockets.org/libwebsockets
in a suitable directory.
Read the README.build.md file.
Create a build directory in the libwebsockets directory.
Change directory into the build directory.
If SSL should not be included - e.g. because SSL is not installed on the BBB - issue this command
...build $] cmake .. -DLWS_WITH_SSL=0
After a short time cmake has figured out the configuration of the BBB and generated a Makefile. So issue
...build $] make ...build $] make install
where the first command builds the library and the second installs it so it will be available on the BBB.
Copying to Development Host
Probably the software in where the libwebsockets are going to be used resides on a more convenient computer like a laptop. If the cross compiler environment has been set-up on the development host the libraries and include files must be copied to that host.
Copy (scp) the lib/libwebsockets.* to the development host into the directory where the controlling software is built, e.g. ~/workspaces/BBBcontroller/lib
Copy (scp) the lib/Headers/*.h files to the include directory for the project on the devlopment host.
Now everything should be ready for development. I.e. set-up the libraries in the setting f the project as shown below.
Note: There are other libraries in the picture that has nothing to do with the libwebsocket
Using the library
Over at Martin Sikora's blog there are a few pages that can jump start the development using libwebsockets.
Read and follow the instructions and soon you will take over and develop your own solution.