aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-04-21 14:20:40 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-04-21 14:20:40 +0200
commitf9d95f812b53fcb365522babe39d518b01a7b624 (patch)
tree4ce70660cfa8f146e11dfd153d83ec9a22dc01e0
parenta1035c3f39c0952e09571be076bf6a4cb2fb966c (diff)
downloadiot-workshop-ndc-2018-f9d95f812b53fcb365522babe39d518b01a7b624.tar.gz
iot-workshop-ndc-2018-f9d95f812b53fcb365522babe39d518b01a7b624.tar.bz2
iot-workshop-ndc-2018-f9d95f812b53fcb365522babe39d518b01a7b624.tar.xz
iot-workshop-ndc-2018-f9d95f812b53fcb365522babe39d518b01a7b624.zip
wip
-rw-r--r--Makefile17
-rwxr-xr-xrefresh18
-rw-r--r--toc.md3
-rw-r--r--what-is-iot-reveal.html73
-rw-r--r--what-is-iot-slides.pdfbin67939 -> 175848 bytes
-rw-r--r--what-is-iot-slides.tex150
-rw-r--r--what-is-iot-text.pdfbin80980 -> 238625 bytes
-rw-r--r--what-is-iot.md65
8 files changed, 279 insertions, 47 deletions
diff --git a/Makefile b/Makefile
index 2f8da55..5761bbb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
P=what-is-iot
# Madrid Pittsburgh boxes
-SLIDE_THEME=boxes
+SLIDE_THEME?=boxes
PDFS=$(P)-text.pdf $(P)-slides.pdf
HTMLS=$(P)-reveal.html
@@ -49,10 +49,10 @@ $(P).md: Makefile
%-text.pdf: %.beamer.md
$(RUN_PANDOC_TEXT) -o $@ $<
-%-slides.pdf: %.beamer.md
+%-slides.pdf: %.beamer.md .var/SLIDE_THEME
$(RUN_PANDOC_BEAMER) -o $@ $<
-%-slides.tex: %.beamer.md
+%-slides.tex: %.beamer.md .var/SLIDE_THEME
$(RUN_PANDOC_BEAMER) -o $@ $<
%.revealjs.md: %.md
@@ -66,6 +66,17 @@ images/%.pdf: images/%.tex | images/pp-template Makefile
xelatex -output-directory=images $(patsubst %.tex,%-full.tex,$<)
mv $(patsubst %.pdf,%-full.pdf,$@) $@
+
+VARS=SLIDE_THEME
+
+define refresh =
+.var/$(1)::
+ @mkdir -p .var
+ @./refresh $$@ $(1) $($(1))
+endef
+
+$(foreach var,$(VARS),$(eval $(call refresh,$(var))))
+
# Dependencies
$(P).md: images/IP-Header_eng.tex
$(P).md: images/ip-header.pdf
diff --git a/refresh b/refresh
new file mode 100755
index 0000000..eb12cb1
--- /dev/null
+++ b/refresh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -e
+
+file=$1
+key=$2
+value=$3
+
+if [[ -r $file ]]
+then
+ old=$(<"$file")
+fi
+
+if [[ $value != $old ]]
+then
+ echo $value > $file
+ echo Changed: $key
+fi
diff --git a/toc.md b/toc.md
index dd6db1d..df06a76 100644
--- a/toc.md
+++ b/toc.md
@@ -28,7 +28,8 @@
* MQTT - The protocol - MQTT Topic
* MQTT - The protocol - MQTT Packet
* MQTT - The protocol - MQTT Topic - more
- * MQTT - The protocol
+ * MQTT - The protocol - Retained message
+ * MQTT - The protocol - Will message
* MQTT - Patterns
* MQTT - Implementations
* MQTT Cloud Connectors
diff --git a/what-is-iot-reveal.html b/what-is-iot-reveal.html
index 3a5698e..6413627 100644
--- a/what-is-iot-reveal.html
+++ b/what-is-iot-reveal.html
@@ -29,7 +29,6 @@
<![endif]-->
-
</head>
<body>
<div class="reveal">
@@ -273,13 +272,9 @@
</aside>
</section><section id="details-ip-1" class="slide level2">
<h2>Details: IP</h2>
-
-<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
-
</section></section>
<section><section id="lecture-esp8266-aka-nodemcu-aka-esp-12" class="title-slide slide level1"><h1>Lecture: ESP8266 aka NodeMCU aka ESP-12</h1></section><section id="esp8266-software-layers" class="slide level2">
<h2>ESP8266 software layers</h2>
-
</section></section>
<section><section id="lecture-mqtt" class="title-slide slide level1"><h1>Lecture: MQTT</h1></section><section id="mqtt" class="slide level2">
<h2>MQTT</h2>
@@ -305,16 +300,17 @@
<li><em>Broker</em> (aka Server)
<ul>
<li>Handles network connections</li>
-<li>Keeps subscription state</li>
+<li>Keeps subscriptions</li>
<li>Manages client
<ul>
<li>Disconnects</li>
<li><em>(last) will</em></li>
</ul></li>
-<li>Persistence</li>
+<li>Persistence of retained messages</li>
</ul></li>
</ul>
<aside class="notes">
+<p>network connections: this includes removing closed sockets, client’s that doesn’t respons to timeouts and duplicate clients.</p>
<p>http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html</p>
<p>Subscriptions are not permanent. The connection is (unlike HTTP) stateful.</p>
<p>Some messages may be persistent, but only one per topic. You will often end up with a “proper” mq on the backend if queuing is needed.</p>
@@ -397,17 +393,70 @@
<aside class="notes">
</aside>
-</section><section id="mqtt---the-protocol-1" class="slide level2">
-<h2>MQTT - The protocol</h2>
+</section><section id="mqtt---the-protocol---retained-message" class="slide level2">
+<h2>MQTT - The protocol - Retained message</h2>
+<p>Message is kept by the server even after disconnect</p>
+<ul>
+<li><code>CONNECT</code></li>
+<li><code>PUBLISH</code>
+<ul>
+<li><code>RETAIN</code></li>
+<li><code>$app/$device/temperature</code></li>
+<li><code>22.3</code></li>
+</ul></li>
+<li><code>DISCONNECT</code></li>
+</ul>
+<p>Later on:</p>
+<ul>
+<li><code>SUBSCRIBE</code>
+<ul>
+<li><code>$app/#/temperature</code></li>
+</ul></li>
+<li><code>PUBLISH</code>
+<ul>
+<li><code>$app/$device/temperature</code></li>
+<li><code>22.3</code></li>
+</ul></li>
+</ul>
+<aside class="notes">
+<p>The last PUBLISH is an incoming message</p>
+</aside>
+</section><section id="mqtt---the-protocol---will-message" class="slide level2">
+<h2>MQTT - The protocol - Will message</h2>
+<p>Message sent when you disconnect</p>
+<p>Client #1:</p>
+<ol type="1">
+<li><code>CONNECT</code>
+<ul>
+<li><code>WILL TOPIC: $app/$device/online</code></li>
+<li><code>WILL PAYLOAD: 0</code></li>
+</ul></li>
+<li><code>PUBLISH</code>
+<ul>
+<li><code>$app/$device/online</code></li>
+<li><code>1</code></li>
+</ul></li>
+<li><code>DISCONNECT</code></li>
+</ol>
+<p>…</p>
+<p>Broker</p>
+<ol type="1">
+<li><code>PUBLISH</code>
+<ul>
+<li><code>$app/$device/online</code></li>
+<li><code>0</code></li>
+</ul></li>
+</ol>
</section><section id="mqtt---patterns" class="slide level2">
<h2>MQTT - Patterns</h2>
<p>Må utvides</p>
<p>Explain:</p>
<ul>
-<li>Message sizes with MQTT</li>
-<li>“will” messages</li>
<li>Push vs pull, central applications can push to clients</li>
<li>mostly mqtt, some http</li>
+<li>Client id - sparker ut gamle koblinger</li>
+<li>Keep alive / ping meldinger</li>
+<li>Alternative transporter - websockets(!)</li>
</ul>
</section><section id="mqtt---implementations" class="slide level2">
<h2>MQTT - Implementations</h2>
@@ -428,7 +477,7 @@
<li>Amazon IoT</li>
<li>Google Cloud IoT</li>
<li>Microsoft Azure IoT</li>
-<li>CloudMQTT</li>
+<li>CloudMQTT (at Heroku)</li>
</ul></li>
<li>DIY
<ul>
diff --git a/what-is-iot-slides.pdf b/what-is-iot-slides.pdf
index 59b1f24..0f1e961 100644
--- a/what-is-iot-slides.pdf
+++ b/what-is-iot-slides.pdf
Binary files differ
diff --git a/what-is-iot-slides.tex b/what-is-iot-slides.tex
index bf541c1..15841a0 100644
--- a/what-is-iot-slides.tex
+++ b/what-is-iot-slides.tex
@@ -361,9 +361,8 @@ maximum value is 64k, 65536.}
\end{frame}
-\hypertarget{lecture-esp8266-aka-nodemcu-aka-esp-12}{%
-\section{Lecture: ESP8266 aka NodeMCU aka
-ESP-12}\label{lecture-esp8266-aka-nodemcu-aka-esp-12}}
+\hypertarget{lecture-esp8266}{%
+\section{Lecture: ESP8266}\label{lecture-esp8266}}
\begin{frame}{ESP8266 software layers}
\protect\hypertarget{esp8266-software-layers}{}
@@ -423,7 +422,7 @@ Agents have one of two roles:
\item
Handles network connections
\item
- Keeps subscription state
+ Keeps subscriptions
\item
Manages client
@@ -435,11 +434,14 @@ Agents have one of two roles:
\emph{(last) will}
\end{itemize}
\item
- Persistence
+ Persistence of retained messages
\end{itemize}
\end{itemize}
-\note{http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
+\note{network connections: this includes removing closed sockets,
+client’s that doesn’t respons to timeouts and duplicate clients.
+
+http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
Subscriptions are not permanent. The connection is (unlike HTTP)
stateful.
@@ -537,22 +539,16 @@ altert levels (autonomous operation)}
\begin{itemize}
\tightlist
\item
- Very small
-\end{itemize}
-
-\begin{itemize}
-\tightlist
-\item
- Packet type + flags
+ Size oriented
\item
- Packet identifier
-\item
- Payload
+ Flags indicate type of remaining bytes
\begin{itemize}
\tightlist
\item
- Size
+ Packet type
+ \item
+ Topic name
\item
Payload
\end{itemize}
@@ -608,6 +604,114 @@ The central application is split:
\end{frame}
+\begin{frame}[fragile]{MQTT - The protocol - Retained message}
+\protect\hypertarget{mqtt---the-protocol---retained-message}{}
+
+Message is kept by the server even after disconnect
+
+\begin{itemize}
+\tightlist
+\item
+ \texttt{CONNECT}
+\item
+ \texttt{PUBLISH}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{RETAIN}
+ \item
+ \texttt{\$app/\$device/temperature}
+ \item
+ \texttt{22.3}
+ \end{itemize}
+\item
+ \texttt{DISCONNECT}
+\end{itemize}
+
+Later on:
+
+\begin{itemize}
+\tightlist
+\item
+ \texttt{SUBSCRIBE}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{\$app/\#/temperature}
+ \end{itemize}
+\item
+ \texttt{PUBLISH}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{\$app/\$device/temperature}
+ \item
+ \texttt{22.3}
+ \end{itemize}
+\end{itemize}
+
+\note{The last PUBLISH is an incoming message}
+
+\end{frame}
+
+\begin{frame}[fragile]{MQTT - The protocol - Will message}
+\protect\hypertarget{mqtt---the-protocol---will-message}{}
+
+Message sent when you disconnect
+
+Client \#1:
+
+\begin{enumerate}
+[1.]
+\tightlist
+\item
+ \texttt{CONNECT}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{WILL\ TOPIC:\ \$app/\$device/online}
+ \item
+ \texttt{WILL\ PAYLOAD:\ 0}
+ \end{itemize}
+\item
+ \texttt{PUBLISH}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{\$app/\$device/online}
+ \item
+ \texttt{1}
+ \end{itemize}
+\item
+ \texttt{DISCONNECT}
+\end{enumerate}
+
+\ldots{}
+
+Broker
+
+\begin{enumerate}
+[1.]
+\tightlist
+\item
+ \texttt{PUBLISH}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{\$app/\$device/online}
+ \item
+ \texttt{0}
+ \end{itemize}
+\end{enumerate}
+
+\end{frame}
+
\begin{frame}{MQTT - Patterns}
\protect\hypertarget{mqtt---patterns}{}
@@ -618,13 +722,15 @@ Explain:
\begin{itemize}
\tightlist
\item
- Message sizes with MQTT
-\item
- “will” messages
-\item
Push vs pull, central applications can push to clients
\item
mostly mqtt, some http
+\item
+ Client id - sparker ut gamle koblinger
+\item
+ Keep alive / ping meldinger
+\item
+ Alternative transporter - websockets(!)
\end{itemize}
\end{frame}
@@ -667,7 +773,7 @@ releases at the same time.}
\item
Microsoft Azure IoT
\item
- CloudMQTT
+ CloudMQTT (at Heroku)
\end{itemize}
\item
DIY
diff --git a/what-is-iot-text.pdf b/what-is-iot-text.pdf
index 8609058..ec4ad4d 100644
--- a/what-is-iot-text.pdf
+++ b/what-is-iot-text.pdf
Binary files differ
diff --git a/what-is-iot.md b/what-is-iot.md
index 3b1b570..da61d82 100644
--- a/what-is-iot.md
+++ b/what-is-iot.md
@@ -239,7 +239,9 @@ Note that the "total length" field is 16 bits, 2 bytes, it's maximum value is 64
![](images/IP-Header_eng.pdf)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# Lecture: ESP8266 aka NodeMCU aka ESP-12
+# Lecture: ESP8266
+
+!comment(aka NodeMCU aka ESP-12)
## ESP8266 software layers
@@ -274,14 +276,16 @@ Agents have one of two roles:
* *Broker* (aka Server)
* Handles network connections
- * Keeps subscription state
+ * Keeps subscriptions
* Manages client
* Disconnects
* *(last) will*
- * Persistence
+ * Persistence of retained messages
::: notes
+network connections: this includes removing closed sockets, client's that doesn't respons to timeouts and duplicate clients.
+
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
Subscriptions are not permanent. The connection is (unlike HTTP)
@@ -364,16 +368,62 @@ The central application is split:
:::
+## MQTT - The protocol - Retained message
+
+Message is kept by the server even after disconnect
+
+* `CONNECT`
+* `PUBLISH`
+ * `RETAIN`
+ * `$app/$device/temperature`
+ * `22.3`
+* `DISCONNECT`
+
+Later on:
+
+* `SUBSCRIBE`
+ * `$app/#/temperature`
+* `PUBLISH`
+ * `$app/$device/temperature`
+ * `22.3`
+
+::: notes
+
+The last PUBLISH is an incoming message
+
+:::
+
+## MQTT - The protocol - Will message
+
+Message sent when you disconnect
+
+Client #1:
+
+1. `CONNECT`
+ * `WILL TOPIC: $app/$device/online`
+ * `WILL PAYLOAD: 0`
+1. `PUBLISH`
+ * `$app/$device/online`
+ * `1`
+1. `DISCONNECT`
+
+Broker
+
+1. *To all subscribers* `PUBLISH`
+ * `$app/$device/online`
+ * `0`
+
## MQTT - Patterns
Må utvides
Explain:
-* Message sizes with MQTT
-* "will" messages
* Push vs pull, central applications can push to clients
* mostly mqtt, some http
+* Client id - sparker ut gamle koblinger
+* Keep alive / ping meldinger
+* Alternative transporter - websockets(!)
## MQTT - Implementations
@@ -395,7 +445,7 @@ Not sure about ActiveMQ but it is at least a part of the project so it is releas
* Amazon IoT
* Google Cloud IoT
* Microsoft Azure IoT
- * CloudMQTT
+ * CloudMQTT (at Heroku)
* DIY
* ThingMQ
@@ -410,9 +460,6 @@ In between are:
:::
-
-# Notes
-
# Assignments
## Assignment 1: Blink a led