The Internet of Things (IoT) refers to the many servers that store data uploaded from various devices (things) connected to the Internet, which can range from weather stations, to home appliances, or a farm animal with a biochip transponder. Even
dancing robotic quad choppers.
There are many services that provide IoT support. After experimenting with some, I settled on the SkyNet.im IoT server. It provides several simple ways to allow machine to machine communications, including MQTT, REST, and WebSockets. There are Python and JavaScript libraries to support it. The API for SkyNet is fairly simple, as is using the REST protocol. With the
curl utility, you can interface to SkyNet from shell commands.
First you need to install the curl program and since I will also be calling this from a C program, I also need the development support.
sudo apt-get install curl libcurl4-gnutls-dev
To create a new device on Skynet, issue the following command (changing the parameters as you see fit)
curl -X POST -d "type=raspberry-pi-example&myvariable=12345" http://skynet.im/devices
SkyNet returns a UUID and a security token. Save this info. The device id is used to identify the new device and the security token allows a little security so that only someone with the token can update the data for this device. If you really need to maintain security for the device, be sure to always update it using HTTPS. If you use HTTP, then the session is not encrypted and someone could intercept the token and use it themselves. Also, be aware that anyone can read your data.
To update the data for the device, issue this command. (All one line.)
curl -X PUT -d "token=PUT-YOUR-TOKEN-HERE&myvariable=5678online=true" http://skynet.im/devices/PUT-YOUR-UUID-HERE
To view the data for a device, issue this command.
curl –X GET http://skynet.im/devices/PUT-YOUR-UUID-HERE
The function listed below provides a simple interface to SkyNet, in C, using libcurl.