In the ”Internet of Things” (IoT) vision the physical world blends with virtual one, while machine-to-machine interaction improve our daily life. Clearly, how these virtual objects are exposed to us is critical, so that their user interface must be designed to support the easiness of usage that is driven by the users’ needs, which is different from what machines requires. These two requirements must be solved, and an integrated solution should emerge, if we want to bring the IoT to the 50 billions network that is predicted to became in the next years.
In this talk, you will see how these requirements cannot be met by the same communication protocol, as the user interfaces dictates a way of communication that is no suitable for the "machines". We will analyze what are the state-of-art protocols for both machines and users, and finally we will propose a solution to solve this problem.
22. We can supercharge our house with hubot
How
module.exports = (robot) ->
robot.respond /what’s the temperature?/i, (msg) ->
msg.http("http://mchouse.it/temperature")
.header("Accept", "application/json")
.get() (err, res, body) ->
msg.send JSON.parse(body)
23. In order to ask our temp
to hubot, we need to:
1. sense the temp
2. get the temp on the web
3. build a web API
24. From Hubot, I want to do
the equivalent of:
>: curl http://mchouse.it/temp
What about JSON
25. We are building an API
In Italy,
“API” means
“bees”
http://www.flickr.com/photos/theseanster93/4056815767
39. Binary vs REST
M2M protocols are “Things” should
ad-hoc, and interact with our
researchers and lives, and all the
businesses focus on technology should
low level problems. be built to make
them easy to use.
40. • binary protocol • devices exposed
to the web
• publish/subscribe
• REST architecture
• topics as the
naming system • URIs as the
naming system
• royalty free
• syndication
• open source
implementations
46. on Arduino: Setup
String server = String("qest.me");
PubSubClient client =
PubSubClient(server,
1883,
callback);
47. on Arduino: publishing
if (!client.connected()) {
client.connect("arduino");
}
client.loop();
char s[10];
itoa(get_temperature(), s, 10);
client.publish("temp", s);
48. on Arduino: publishing
if (!client.connected()) {
client.connect("arduino");
}
client.loop();
This is called a topic,
and it is where we publish
chars[10]; MQTT.
things on
itoa(get_temperature(), s, 10);
client.publish("temp", s);
52. QEST
HTTP Clients MQTT Clients
• MQTT broker
• REST interface
REST Server MQTT Server
• HTTP semantics QEST
• no QoS Data Layer
• built in node.js
• crafted by me Redis
53. QEST : MQTT to REST
• retains every message received
client.publish("temp", "30");
• every topic has its own URI: /topics/<NAME>
curl -H "Accept: txt"
http://qest.me/topics/temp
54. QEST : REST to MQTT
• transform every HTTP PUT received to a
MQTT message
curl -X PUT -d '{ "housetemp": 42 }'
-H "Content-Type: application/json"
http://qest.me/topics/temp
• devices can listen directly to MQTT topics
void callback(char* topic, byte*
payload, int length) {
...
}
PubSubClient(server, 1883, callback);
client.subscribe("temp");
55. state-of-art QEST-based
approach to IoT apps solution to IoT apps
Web App Web App
Bridge
QEST
IoT
Device
3 2 1 0 9 8 7 6 5 4 3 2 1 0
GND
SCL
AREF
SDA
1 1 1 1 DIGITAL
RX
TX
PWM
PWM
PWM
PWM
PWM
PWM
L
TX
Arduino UNO ON
Broker
RX
1
ICSP
www.arduino.cc
RESET
IOREF
POWER ANALOG IN
3V3
5V Gnd Vin 0 1 2 3 4 5
Device
3 2 1 0 9 8 7 6 5 4 3 2 1 0
GND
SCL
AREF
SDA
1 1 1 1 DIGITAL
RX
TX
PWM
PWM
PWM
PWM
PWM
PWM
L
TX
RX
Arduino UNO ON
1
ICSP
www.arduino.cc
RESET
IOREF
POWER ANALOG IN
3V3
5V Gnd Vin 0 1 2 3 4 5
56. QEST : Scalability
HTTP/MQTT Clients
Load Balancer
REST Server MQTT Server REST Server MQTT Server
QEST
Data Layer
... QEST
Data Layer
Redis
57. Do you like
Spaghetti
Code?
JavaScript Apps are
often a mess
We mix logic with
presentation with
persistance.
Is QEST different?
http://www.flickr.com/photos/mpirotta/4944504834
58. QEST:
Built BDD-style, with
Cucumber-js and mocha
Continuous Integration
based on Travis-CI
Written in CoffeeScript
Patches are welcome!
http://www.flickr.com/photos/mpirotta/4944504834
59. Let’s ask something
to my house!
http://www.flickr.com/photos/oneaustin/1261907803
61. Security Issues
• What devices can a user monitor?
• What devices can 'listen' to the
state of other devices?
• Who can access the devices state?
• Is the communication secure?