From f9d95f812b53fcb365522babe39d518b01a7b624 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 21 Apr 2018 14:20:40 +0200 Subject: wip --- Makefile | 17 +++++- refresh | 18 ++++++ toc.md | 3 +- what-is-iot-reveal.html | 73 +++++++++++++++++++---- what-is-iot-slides.pdf | Bin 67939 -> 175848 bytes what-is-iot-slides.tex | 150 +++++++++++++++++++++++++++++++++++++++++------- what-is-iot-text.pdf | Bin 80980 -> 238625 bytes what-is-iot.md | 65 ++++++++++++++++++--- 8 files changed, 279 insertions(+), 47 deletions(-) create mode 100755 refresh 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 @@ -
@@ -273,13 +272,9 @@

Details: IP

- -

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.

-

Lecture: ESP8266 aka NodeMCU aka ESP-12

ESP8266 software layers

-

Lecture: MQTT

MQTT

@@ -305,16 +300,17 @@
  • Broker (aka Server)
    • Handles network connections
    • -
    • Keeps subscription state
    • +
    • Keeps subscriptions
    • Manages client
      • Disconnects
      • (last) will
    • -
    • Persistence
    • +
    • Persistence of retained messages
  • -

    MQTT - The protocol

    +
    +

    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
      • +
    • +
    + +
    +

    MQTT - The protocol - Will message

    +

    Message sent when you disconnect

    +

    Client #1:

    +
      +
    1. CONNECT +
        +
      • WILL TOPIC: $app/$device/online
      • +
      • WILL PAYLOAD: 0
      • +
    2. +
    3. PUBLISH +
        +
      • $app/$device/online
      • +
      • 1
      • +
    4. +
    5. DISCONNECT
    6. +
    +

    +

    Broker

    +
      +
    1. PUBLISH +
        +
      • $app/$device/online
      • +
      • 0
      • +
    2. +

    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

    @@ -428,7 +477,7 @@
  • Amazon IoT
  • Google Cloud IoT
  • Microsoft Azure IoT
  • -
  • CloudMQTT
  • +
  • CloudMQTT (at Heroku)
  • DIY
      diff --git a/what-is-iot-slides.pdf b/what-is-iot-slides.pdf index 59b1f24..0f1e961 100644 Binary files a/what-is-iot-slides.pdf and b/what-is-iot-slides.pdf 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}{} @@ -617,14 +721,16 @@ 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 Binary files a/what-is-iot-text.pdf and b/what-is-iot-text.pdf 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 -- cgit v1.2.3