Professional Documents
Culture Documents
Dr Valerio Selis
V.Selis@liverpool.ac.uk
Outline
• M2M in the IoT:
• Reference Architecture
• Abstraction
• MQTT messages
• MQTT subscriber with Paho-MQTT Python3
module
• Messages formatting with XML module
• Messages parsing with defusedxml module
• MQTT solutions for IoT
Gateway
M2M Device
and Gateway Local
domain Network
“Thing” “Thing”
M2M app M2M app
Communication Communication
Sensor Actuator
1
11/5/19
Ethernet
mqtt.eclipse.org
(137.135.83.217)
Communication
Sensor
Humidity and
Temperature
2
11/5/19
CONNECT ack
(Return Code)
SUBSCRIBE request
(topic, QoS 1)
SUBSCRIBE ack
(Granted QoS 1)
CONNECT command
(MQTT 3.1.1, Client ID, flags)
CONNECT ack
(Return code)
PUBLISH message
(topic, message)
PUBLISH message
(topic, message)
Communication
Actuator
LED
3
11/5/19
10
11
12
4
11/5/19
13
14
https://github.com/mqtt/mqtt.github.io/wiki/SYS-Topics
15
5
11/5/19
16
17
Gateway
M2M Device
and Gateway Local
domain Network
Wi-Fi Wi-Fi
18
6
11/5/19
19
20
21
7
11/5/19
22
23
24
8
11/5/19
root_element = ET.Element('sensor_data')
• Other elements can be added to the structure by using the
“SubElement” object:
child_element =
ET.SubElement(root_element, 'measurement')
parent tag
25
ET.SubElement(child_element,
tag 'temperature')
• Attributes can be added by using the “set” method:
subchild_element.set('type', 'double')
• The text can be added by using the “text” variable:
subchild_element.text = temp
data.temperature
26
27
9
11/5/19
28
29
30
10
11/5/19
Gateway
M2M Device
and Gateway Local
domain Network Is this the
best
approach?
MQTT publisher MQTT subscriber
Paho-MQTT Paho-MQTT
Wi-Fi Wi-Fi
Sensor (DHT11) Actuator (LED)
31
Global
Th
Cloud
ou
sa
Country/
nd
regional
s
Local/
metro
Fog
Mi
llio
ns
Premise/
site
Bi
Edge
llio
ns
Device
32
33
11
11/5/19
MQTT broker
Mosquitto
M2M Device Wi-Fi
and Gateway
domain
Local
Network
Wi-Fi Wi-Fi
Sensor (DHT11) Actuator (LED)
34
Gateway Gateway
M2M Device
Local Local
and Gateway
Network Network Is this the
domain
best
approach?
MQTT publisher MQTT subscriber
Paho-MQTT Paho-MQTT
Wi-Fi Wi-Fi
35
Summary
M2M in the IoT
36
12
11/5/19
Next class?
37
13