Top Banner
Lecture #10 MQTT Android Things 2020
18

Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Jul 31, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Lecture #10 MQTT

Android Things 2020

Page 2: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

MQTTMessage Queue Telemetry Transport

Page 3: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

• Publish-subscribe.

• A message broker is required.

• Standard: ISO/IEC PRF 20922.

• Developed in 1999 (and released royalty free in 2010).

• Small code footprint.

• Limited network bandwidth / constrained environments.

• Data agnostic.

Page 4: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Model

Page 5: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Broker Benefits

• Eliminates insecure connections.

• Easily scales.

• Manages client connect states.

• Reduce network strain.

Page 6: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

What is a broker

Page 7: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

What is a broker

• Software running on a computer.

• Running on premise or on the cloud.

• Self-Built or 3rd party hosted.

• Open source or proprietary.

Page 8: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes
Page 9: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes
Page 10: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes
Page 11: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes
Page 12: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Connecting to the broker

Page 13: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Publishing to a topic

Page 14: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Subscribing to a topic• Example:

• Topic #1: home/groundfloor/kitchen/temperature

• Topic #2: office/conferenceroom/luminance

• Wild cards

• Single-level:

• home/groundfloor/+/temperature (to subscribe to all the temperature readings in all the rooms of the ground floor)

• Multi-level:

• home/groundfloor/# (to subscribe to all the readings in all the rooms of the ground floor, not only the temperature)

Page 15: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Quality of Service

• 0: The broker/client will deliver the message once, with no confirmation.

• 1: The broker/client will deliver the message at least once, with confirmation required.

• 2: The broker/client will deliver the message exactly once by using a four step handshake.

Page 16: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Last will and testament

Page 17: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Learn More

• Learn more: mqtt.org

• Software: mqtt.org/software

• Recommended broker (C): Mosquitto (mosquitto.org)

• Lots of good tutorials out there on Android Things, Python, Java and Mobile.

Page 18: Lecture #10 MQTTdan/at/Lecture10.pdf · Lecture #10 MQTT Android Things 2020. MQTT Message Queue Telemetry Transport ... Python, Java and Mobile. Lecture outcomes

Lecture outcomes

• MQTT Protocol details.

• Create MQTT Raspbian and Android Things clients.

• How to control from a mobile app the IoT devices using MQTT.