SMQ IoT Tutorials and Examples
SMQ is an IoT protocol that lets you control and manage one to millions of IoT devices in real time from the same user interface. Broker instances are created programmatically on the server using Lua Server Pages. Since SMQ initiates the connection using HTTP(S), each broker instance is set up with a unique URL making it both easy and convenient to have one broker instance per customer. Isolating broker instances per customer greatly simplifies access control management design.
The SMQ documentation provides an introduction and a few basic hands-on examples.
The following examples are for the three SMQ tutorials:
A basic chat client
The basic HTML/JavaScript powered chat client that shows how to use publish and subscribe for sending messages to all connected clients and how to receive the published messages.
When running the example, open multiple browser windows. Text input is at the bottom of the chat page.
Improving the chat client
The improved chat client builds on the basic chat clients and shows how to use SMQ's one-to-one messages. Messages are still broadcasted to all connected clients, but one-to-one messages are used for building a list of all connected users. The user list is shown in the left pane and each list entry changes color when the user types.
When running the example, open multiple browser windows.
Device LED control
The device LED control example show how to use the SMQ IoT Protocol for designing a web based IoT device management user interface for controlling Light Emitting Diodes (LEDS) in one or multiple devices.
The SMQ LED web interface shows no connected devices. You must connect at least one SMQ C Client to your own SMQ broker. Download and compile the SMQ client C code as follows:
SMQ C Client
- Download the SMQ C Client Example from GitHub.
- Unzip to any directory.
- Using your favorite editor, open SMQ-master\examples\m2m-led.c and change the following:
#define SMQ_DOMAIN "http://simplemq.com"
to#define SMQ_DOMAIN "http://199.167.31.236"
- Compile the code for POSIX (such as Linux) by using the provided makefile.
- Start the led-smq executable -- i.e. start the compiled code.
- Click the /smq/ URL to open the web based LED management controller.
Experimenting with the server side code
The included ZIP file IoT.zip includes the SMQ IoT server code for the SMQ chat and SMQ LED examples. You may run the IoT examples as part of the main tutorial, but you may also run the IoT example separately.
Unzip IoT.zip, run the IoT in developer mode, and experiment with the code as follows:
mkdir IoT cd IoT unzip /home/mako/lspapps/examples/IoT.zip cd .. mako -l::IoT
This SMQ IoT example bundle and additional SMQ examples can be downloaded from GitHub.