From e4bdeee49319bc5570dfa0e998e4e68f3c33ee8c Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 13 Jun 2018 20:02:36 +0200 Subject: wip --- slides/.gitignore | 3 ++ slides/Makefile | 7 +++ slides/TODO.md | 5 +++ slides/connected-arduino.md | 93 ++++++++++++++------------------------- slides/images/mqtt-seq.pdf | Bin 0 -> 12113 bytes slides/images/mqtt-seq.pgf | 46 +++++++++++++++++++ slides/images/pp-template | 8 +++- slides/images/qtikz-template.pgs | 3 ++ 8 files changed, 102 insertions(+), 63 deletions(-) create mode 100644 slides/.gitignore create mode 100644 slides/TODO.md create mode 100644 slides/images/mqtt-seq.pdf create mode 100644 slides/images/mqtt-seq.pgf (limited to 'slides') diff --git a/slides/.gitignore b/slides/.gitignore new file mode 100644 index 0000000..d8071c4 --- /dev/null +++ b/slides/.gitignore @@ -0,0 +1,3 @@ +*.tmp.tex +*.log +*.aux diff --git a/slides/Makefile b/slides/Makefile index 4f2b761..e92b20f 100644 --- a/slides/Makefile +++ b/slides/Makefile @@ -72,6 +72,13 @@ $(BUILD_DIR)/%.revealjs.md.d: %.md | $(BUILD_DIR) %-reveal.html: %.revealjs.md $(RUN_PANDOC_REVEALJS) -o $@ $< +images/%.pdf: images/%.pgf | images/pp-template Makefile + images/pp-template $< > $(patsubst %.pgf,%.tmp.tex,$<) + TEXINPUTS=./:images/tikzuml-v1.0-2016-03-29: \ + xelatex -output-directory=images \ + -jobname $(notdir $(basename $@)) \ + $(patsubst %.pgf,%.tmp.tex,$<) + images/%.pdf: images/%.tex | images/pp-template Makefile images/pp-template < $< > $(patsubst %.tex,%-full.tex,$<) xelatex -output-directory=images $(patsubst %.tex,%-full.tex,$<) diff --git a/slides/TODO.md b/slides/TODO.md new file mode 100644 index 0000000..ae81edd --- /dev/null +++ b/slides/TODO.md @@ -0,0 +1,5 @@ +Slide: *Device and application architecture with MQTT* + +* Add one-way pointers for TCP, keep existing as MQTT messaging. + Illustrates that everyone connects to the broker, but messages can + be pushed. Contrast to HTTP. diff --git a/slides/connected-arduino.md b/slides/connected-arduino.md index 6a6b5e7..79ba123 100644 --- a/slides/connected-arduino.md +++ b/slides/connected-arduino.md @@ -292,6 +292,36 @@ Version 3.1.1 er den som gjelder, V 3.1 er rar, de andre finnes ikke \end{center} ) +## MQTT Topic + +The temperature sensor: + +* Publishes on: + * `myapp/$device-id/temperature` + * `myapp/$device-id/humidity` + * `myapp/$device-id/altert` +* Subscribes to: + * `myapp/$device-id/command` + +The central application: + +* Subscribes to: + * `myapp/#/temperature` + * `myapp/#/humidity` +* Publishes on: + * `myapp/$device-id/command` + +::: notes + +Typical first round of implementation. + +Commands can be: +* load new firmware (maybe an URL and firmware signature). +* Set new calibration values +* Change reading interval, altert levels (autonomous operation) + +::: + ## MQTT - Implementations * Mosquitto @@ -334,12 +364,13 @@ Agents have one of two roles: * *Client* * Publishes *messages* * Subscribes / unsubscribes to *topics* + * Keep alive * *Broker* (aka Server) * Handles network connections * Keeps subscriptions * Manages client - * Disconnects + * Timeouts and disconnects * *(last) will* * Persistence of retained messages @@ -359,36 +390,6 @@ Push vs pull, central applications can push to clients ::: -## MQTT - The protocol - MQTT Packet - -* Size oriented -* Flags indicate type of remaining bytes - * Packet type - * Topic name - * Payload - -::: notes - -Only packet type + flags (1 byte) is required, everything else is optional. - -The size field is variable length encoded, 0-127 bytes is 1 byte, 128-16383 use 2 bytes etc, up to 4 bytes for 256MB payload. - -::: - -## MQTT Connect - -* `CONNECT` - * `clientId` - * `username` - * `password` - * `keepAlive` - - - -* Keep alive - * `PINGREQ` - * `PINGRESP` - ## MQTT - The protocol - MQTT Topic * Topic name: `foo/bar/baz` @@ -441,36 +442,6 @@ Broker * `$app/$device/online` * `0` -## MQTT Topic - -The temperature sensor: - -* Publishes on: - * `myapp/$device-id/temperature` - * `myapp/$device-id/humidity` - * `myapp/$device-id/altert` -* Subscribes to: - * `myapp/$device-id/command` - -The central application: - -* Subscribes to: - * `myapp/#/temperature` - * `myapp/#/humidity` -* Publishes on: - * `myapp/$device-id/command` - -::: notes - -Typical first round of implementation. - -Commands can be: -* load new firmware (maybe an URL and firmware signature). -* Set new calibration values -* Change reading interval, altert levels (autonomous operation) - -::: - ## MQTT on Arduino PubSubClient is our MQTT client implementation. diff --git a/slides/images/mqtt-seq.pdf b/slides/images/mqtt-seq.pdf new file mode 100644 index 0000000..bcee05d Binary files /dev/null and b/slides/images/mqtt-seq.pdf differ diff --git a/slides/images/mqtt-seq.pgf b/slides/images/mqtt-seq.pgf new file mode 100644 index 0000000..8001ec1 --- /dev/null +++ b/slides/images/mqtt-seq.pgf @@ -0,0 +1,46 @@ +\begin{tikzpicture} +\begin{umlseqdiag} + +\umlactor{Device} +\umlactor{Broker} +\umlactor{Central} + +\begin{umlcall}[op={sub(dev/\#/online)}]{Central}{Broker} +\end{umlcall} + +\begin{umlcall}[dt=15, op={con(dev/123/online, 0)}]{Device}{Broker} \end{umlcall} +\begin{umlcall}[dt=5, name=pub,op={pub(dev/123/online, 1)}]{Device}{Broker} \end{umlcall} + +%\begin{umlcallself}[dt=5, op={terminate()}]{Device}\end{umlcallself} + +%\umlnote{death}{woop} +\umlnote[x=-3,y=-2]{sb-pub}{After this the device drops off the Wi-Fi} + + +\begin{umlcall}[dt=10, op={pub(dev/123/online, 0)}]{Broker}{Central} \end{umlcall} + +%\umlsdnode[dt=20]{Central} +%\umlsdnode[dt=5]{Broker} +%\begin{umlcall} +%\end{umlcall} + +\iffalse +\begin{umlcall}{A}{C} + \begin{umlcall}{C}{A} + \end{umlcall} + + \begin{umlcall}[dt=10]{B}{C} + \begin{umlcall}{C}{B} + \end{umlcall} + + \begin{umlcall}[return=1]{B}{C} + \end{umlcall} + \end{umlcall} + + \begin{umlcall}[dt=20, return=1]{A}{C} + \end{umlcall} + +\end{umlcall} +\fi +\end{umlseqdiag} +\end{tikzpicture} diff --git a/slides/images/pp-template b/slides/images/pp-template index 8021025..3e51cc9 100755 --- a/slides/images/pp-template +++ b/slides/images/pp-template @@ -1,8 +1,12 @@ #!/bin/bash +set -e + echo '\documentclass[preview]{standalone} \usepackage{blindtext} -\usepackage[utf8]{inputenc} +%\usepackage[utf8]{inputenc} \usepackage{tikz} +\usepackage{tikz-uml} +%\usepackage{pgf-umlsd} \usetikzlibrary{ angles, arrows, @@ -24,5 +28,5 @@ echo '\documentclass[preview]{standalone} \usepackage{fontspec} \setsansfont{Verdana} \begin{document}' -cat - +cat "$1" echo '\end{document}' diff --git a/slides/images/qtikz-template.pgs b/slides/images/qtikz-template.pgs index edb322b..c2fd323 100644 --- a/slides/images/qtikz-template.pgs +++ b/slides/images/qtikz-template.pgs @@ -2,7 +2,10 @@ \documentclass[preview]{standalone} \usepackage{blindtext} \usepackage[utf8]{inputenc} +\usepackage[english]{babel} \usepackage{tikz} +\usepackage{tikz-uml} +\usepackage{pgf-umlsd} \usetikzlibrary{ angles, arrows, -- cgit v1.2.3