diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-06-10 15:07:17 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-06-10 15:07:17 +0200 |
commit | cb0a365c25cfb60f5c7c073232e5c6bef9fc9064 (patch) | |
tree | 57b664214607fdd5c6f8e398613baae86963395c /slides/what-is-iot-reveal.html | |
parent | 5ec40ac294aa8f092b3f70dca1cb6d103699a995 (diff) | |
download | iot-workshop-ndc-2018-cb0a365c25cfb60f5c7c073232e5c6bef9fc9064.tar.gz iot-workshop-ndc-2018-cb0a365c25cfb60f5c7c073232e5c6bef9fc9064.tar.bz2 iot-workshop-ndc-2018-cb0a365c25cfb60f5c7c073232e5c6bef9fc9064.tar.xz iot-workshop-ndc-2018-cb0a365c25cfb60f5c7c073232e5c6bef9fc9064.zip |
o Removing old stuff.
Diffstat (limited to 'slides/what-is-iot-reveal.html')
-rw-r--r-- | slides/what-is-iot-reveal.html | 848 |
1 files changed, 0 insertions, 848 deletions
diff --git a/slides/what-is-iot-reveal.html b/slides/what-is-iot-reveal.html deleted file mode 100644 index dc069b9..0000000 --- a/slides/what-is-iot-reveal.html +++ /dev/null @@ -1,848 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <meta name="generator" content="pandoc"> - <meta name="author" content="Trygve Laugstøl <trygvis@trygvis.io>"> - <title>IoT Workshop</title> - <meta name="apple-mobile-web-app-capable" content="yes"> - <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> - <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"> - <link rel="stylesheet" href="./bower_components/reveal.js/css/reveal.css"> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; position: absolute; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; } -pre.numberSource a.sourceLine:empty - { position: absolute; } -pre.numberSource a.sourceLine::before - { content: attr(data-line-number); - position: absolute; left: -5em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - color: #aaaaaa; - } -pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } -div.sourceCode - { } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span.al { color: #ff0000; font-weight: bold; } /* Alert */ -code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ -code span.at { color: #7d9029; } /* Attribute */ -code span.bn { color: #40a070; } /* BaseN */ -code span.bu { } /* BuiltIn */ -code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ -code span.ch { color: #4070a0; } /* Char */ -code span.cn { color: #880000; } /* Constant */ -code span.co { color: #60a0b0; font-style: italic; } /* Comment */ -code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ -code span.do { color: #ba2121; font-style: italic; } /* Documentation */ -code span.dt { color: #902000; } /* DataType */ -code span.dv { color: #40a070; } /* DecVal */ -code span.er { color: #ff0000; font-weight: bold; } /* Error */ -code span.ex { } /* Extension */ -code span.fl { color: #40a070; } /* Float */ -code span.fu { color: #06287e; } /* Function */ -code span.im { } /* Import */ -code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ -code span.kw { color: #007020; font-weight: bold; } /* Keyword */ -code span.op { color: #666666; } /* Operator */ -code span.ot { color: #007020; } /* Other */ -code span.pp { color: #bc7a00; } /* Preprocessor */ -code span.sc { color: #4070a0; } /* SpecialChar */ -code span.ss { color: #bb6688; } /* SpecialString */ -code span.st { color: #4070a0; } /* String */ -code span.va { color: #19177c; } /* Variable */ -code span.vs { color: #4070a0; } /* VerbatimString */ -code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ - </style> - <link rel="stylesheet" href="./bower_components/reveal.js/css/theme/black.css" id="theme"> - <!-- Printing and PDF exports --> - <script> - var link = document.createElement( 'link' ); - link.rel = 'stylesheet'; - link.type = 'text/css'; - link.href = window.location.search.match( /print-pdf/gi ) ? './bower_components/reveal.js/css/print/pdf.css' : './bower_components/reveal.js/css/print/paper.css'; - document.getElementsByTagName( 'head' )[0].appendChild( link ); - </script> - <!--[if lt IE 9]> - <script src="./bower_components/reveal.js/lib/js/html5shiv.js"></script> - <![endif]--> - - - -</head> -<body> - <div class="reveal"> - <div class="slides"> - -<section id="title-slide"> - <h1 class="title">IoT Workshop</h1> - <p class="author">Trygve Laugstøl <trygvis@trygvis.io></p> -</section> - -<section><section id="nodemcu" class="title-slide slide level1"><h1>NodeMCU</h1></section><section id="nodemcu-hardware" class="slide level2"> -<h2>NodeMCU hardware</h2> -<p><img data-src="images/NodeMCU-–-Board-de-desarrollo-con-módulo-ESP8266-WiFi-y-Lua-4.jpg" /></p> -</section><section id="nodemcu-hardware-1" class="slide level2"> -<h2>NodeMCU hardware</h2> - -</section><section id="esp8266-software-layers" class="slide level2"> -<h2>ESP8266 software layers</h2> - -</section><section id="esp8266-arduino" class="slide level2"> -<h2>ESP8266 + Arduino</h2> -<ul> -<li>Standard Arduino IDE</li> -<li>ESP8266 Arduino core -<ul> -<li>https://github.com/esp8266/Arduino</li> -</ul></li> -</ul> -</section><section id="arduino-ide" class="slide level2"> -<h2>Arduino IDE</h2> -<p><img data-src="images/arduino-ide.png" /></p> -</section><section id="arduino-code-structure" class="slide level2"> -<h2>Arduino code structure</h2> -<div class="sourceCode" id="cb1"><pre class="sourceCode .c++"><code class="sourceCode cpp"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="dt">void</span> setup() {</a> -<a class="sourceLine" id="cb1-2" data-line-number="2"> <span class="co">// Called once</span></a> -<a class="sourceLine" id="cb1-3" data-line-number="3">}</a> -<a class="sourceLine" id="cb1-4" data-line-number="4"></a> -<a class="sourceLine" id="cb1-5" data-line-number="5"><span class="dt">void</span> loop() {</a> -<a class="sourceLine" id="cb1-6" data-line-number="6"> <span class="co">// Called repeatedly</span></a> -<a class="sourceLine" id="cb1-7" data-line-number="7">}</a></code></pre></div> -<aside class="notes"> -<p>MCU programming is often structured into:</p> -<ul> -<li>Configure -<ul> -<li>CPU</li> -<li>GPIO ports</li> -<li>MCU’s peripherals</li> -<li>The rest of the board</li> -<li>Configure application and callbacks.</li> -</ul></li> -<li>Sleep</li> -</ul> -<p>Arduino chooses to run the cpu at 100% instead of the sleep step..</p> -</aside> -</section><section id="arduino-file-structure" class="slide level2"> -<h2>Arduino file structure</h2> -<pre><code>foo/ - foo.ino - config.h</code></pre> -<aside class="notes"> -<p><code>foo.ino</code> must always be in a <code>foo</code> directory.</p> -<p>config.h is created by “new tab”.</p> -</aside> -</section><section id="generic-arduino-apis" class="slide level2"> -<h2>Generic Arduino APIs</h2> -<div class="sourceCode" id="cb3"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="co">// Pin: D0, D1, etc.</span></a> -<a class="sourceLine" id="cb3-2" data-line-number="2"><span class="co">// Mode: OUTPUT, INPUT, INPUT_PULLUP</span></a> -<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="dt">void</span> pinMode(<span class="dt">uint8_t</span> pin, <span class="dt">uint8_t</span> mode);</a> -<a class="sourceLine" id="cb3-4" data-line-number="4"></a> -<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="co">// State: HIGH, LOW, true/false, 1/0</span></a> -<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="dt">void</span> digitalWrite(<span class="dt">uint8_t</span> pin, <span class="dt">uint8_t</span> state);</a> -<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="dt">int</span> digitalRead(<span class="dt">uint8_t</span> pin);</a> -<a class="sourceLine" id="cb3-8" data-line-number="8"></a> -<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="dt">unsigned</span> <span class="dt">long</span> now millis();</a> -<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="dt">unsigned</span> <span class="dt">long</span> now micros();</a></code></pre></div> -</section><section id="esp-arduino-apis" class="slide level2"> -<h2>ESP Arduino APIs</h2> -<div class="sourceCode" id="cb4"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="kw">class</span> {</a> -<a class="sourceLine" id="cb4-2" data-line-number="2"> <span class="dt">void</span> restart();</a> -<a class="sourceLine" id="cb4-3" data-line-number="3"> <span class="dt">uint32_t</span> getFreeHeap();</a> -<a class="sourceLine" id="cb4-4" data-line-number="4"> <span class="dt">uint32_t</span> getChipId();</a> -<a class="sourceLine" id="cb4-5" data-line-number="5"></a> -<a class="sourceLine" id="cb4-6" data-line-number="6"> ...</a> -<a class="sourceLine" id="cb4-7" data-line-number="7">} ESP;</a> -<a class="sourceLine" id="cb4-8" data-line-number="8"></a> -<a class="sourceLine" id="cb4-9" data-line-number="9"><span class="co">// Usage</span></a> -<a class="sourceLine" id="cb4-10" data-line-number="10">ESP.restart();</a></code></pre></div> -</section><section id="esp-arduino-apis-1" class="slide level2"> -<h2>ESP Arduino APIs</h2> -<div class="sourceCode" id="cb5"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="kw">class</span> {</a> -<a class="sourceLine" id="cb5-2" data-line-number="2"> String macAddress();</a> -<a class="sourceLine" id="cb5-3" data-line-number="3"></a> -<a class="sourceLine" id="cb5-4" data-line-number="4"> <span class="dt">wl_status_t</span> status();</a> -<a class="sourceLine" id="cb5-5" data-line-number="5"> <span class="dt">int32_t</span> RSSI();</a> -<a class="sourceLine" id="cb5-6" data-line-number="6"></a> -<a class="sourceLine" id="cb5-7" data-line-number="7"> IPAddress localIP();</a> -<a class="sourceLine" id="cb5-8" data-line-number="8"> IPAddress subnetMask();</a> -<a class="sourceLine" id="cb5-9" data-line-number="9"> IPAddress gatewayIP();</a> -<a class="sourceLine" id="cb5-10" data-line-number="10"> IPAddress dnsIP(<span class="dt">uint8_t</span> dns_no = <span class="dv">0</span>);</a> -<a class="sourceLine" id="cb5-11" data-line-number="11"></a> -<a class="sourceLine" id="cb5-12" data-line-number="12"> ...</a> -<a class="sourceLine" id="cb5-13" data-line-number="13">} WiFi;</a> -<a class="sourceLine" id="cb5-14" data-line-number="14"></a> -<a class="sourceLine" id="cb5-15" data-line-number="15"><span class="co">// Usage:</span></a> -<a class="sourceLine" id="cb5-16" data-line-number="16"></a> -<a class="sourceLine" id="cb5-17" data-line-number="17">Serial.println(WiFi.localIP().toString());</a></code></pre></div> -<aside class="notes"> -<p>http://arduino-esp8266.readthedocs.io/en/latest/libraries.html</p> -</aside> -</section></section> -<section><section id="what-is-iot" class="title-slide slide level1"><h1>What is IoT</h1></section><section id="what-is-iot-1" class="slide level2"> -<h2>What is IoT</h2> -<ul> -<li>Not “a computer connected to the internet” -<ul> -<li>Then it is really just another computer connected to the internet</li> -</ul></li> -<li>Must be something else -<ul> -<li>It is simply devices that are resource constrained -<ul> -<li>Usually in more than one way</li> -</ul></li> -</ul></li> -<li>Autonomous operation, the connection might not be permanent</li> -</ul> -</section><section id="iot-is-just-a-concept" class="slide level2"> -<h2>IoT is just a concept</h2> -<ul> -<li><em>The Internet of Things (IoT) is the network of physical devices, vehicles, home appliances and other items embedded with electronics, software, sensors, actuators, and connectivity which enables these objects to connect and exchange data.</em><a href="#/fn1" class="footnote-ref" id="fnref1"><sup>1</sup></a></li> -</ul> -</section><section id="what-is-an-iot-device" class="slide level2"> -<h2>What is an IoT Device?</h2> -<aside class="notes"> -<p>As for their definition.</p> -<p>What differentiates a computer from an IoT device?</p> -</aside> -</section><section id="what-is-an-iot-device-1" class="slide level2"> -<h2>What is an IoT Device?</h2> -<ul> -<li>Constrained in (one or more of): -<ul> -<li>Memory</li> -<li>CPU</li> -<li>Network bandwidth and/or latency</li> -<li>Storage</li> -</ul></li> -<li>Has connectivity -<ul> -<li>Bluetooth</li> -<li>Wi-Fi</li> -<li>NB-IoT</li> -<li>LTE Cat-M</li> -<li>LoRA</li> -<li>Proprietary radio</li> -</ul></li> -</ul> -<aside class="notes"> -<p>Might not have:</p> -<ul> -<li>RTC</li> -</ul> -<p>Extra features:</p> -<ul> -<li>IR</li> -<li>UART</li> -<li>CAN</li> -</ul> -<p>Sparkfun and Adafruit etc sell modules with all of these technologies.</p> -</aside> -</section><section id="iot-devices---bluetooth-45-chips" class="slide level2"> -<h2>IoT Devices - Bluetooth 4/5 chips</h2> -<table> -<thead> -<tr class="header"> -<th style="text-align: left;">Chip</th> -<th style="text-align: left;">CPU</th> -<th style="text-align: left;">Freq</th> -<th style="text-align: left;">RAM</th> -<th>Flash</th> -<th style="text-align: left;">Price</th> -</tr> -</thead> -<tbody> -<tr class="odd"> -<td style="text-align: left;">nRF52810</td> -<td style="text-align: left;">Cortex-M4</td> -<td style="text-align: left;">64 MHz</td> -<td style="text-align: left;">24k</td> -<td>192k</td> -<td style="text-align: left;">$1.88</td> -</tr> -<tr class="even"> -<td style="text-align: left;">nRF52832</td> -<td style="text-align: left;">Cortex-M4F</td> -<td style="text-align: left;"></td> -<td style="text-align: left;">32k</td> -<td>256k</td> -<td style="text-align: left;">$2.54</td> -</tr> -<tr class="odd"> -<td style="text-align: left;"></td> -<td style="text-align: left;"></td> -<td style="text-align: left;"></td> -<td style="text-align: left;">64k</td> -<td>512k</td> -<td style="text-align: left;">$2.59</td> -</tr> -<tr class="even"> -<td style="text-align: left;">nRF52840</td> -<td style="text-align: left;">Cortex-M4F</td> -<td style="text-align: left;"></td> -<td style="text-align: left;">256k</td> -<td>1024k</td> -<td style="text-align: left;">$3.85</td> -</tr> -</tbody> -</table> -<ul> -<li>nRF52810: High performance, entry-level Bluetooth 4/ANT/2.4GHz SoC</li> -<li>nRF52832: High performance Bluetooth 4/ANT/2.4GHz SoC</li> -<li>nRF52840: Advanced multi-protocol System-on-Chip Supporting: Bluetooth 5, ANT/ANT+, 802.15.4 and 2.4GHz proprietary</li> -</ul> -<aside class="notes"> -<p>All quantities are 1000 pieces</p> -<p>nRF51: https://www.digikey.no/products/en/rf-if-and-rfid/rf-transceiver-ics/879?k=nrf51822</p> -<p>nRF52832: these have different packagings, not only difference price</p> -<p>https://www.digikey.no/products/en/rf-if-and-rfid/rf-transceiver-ics/879?FV=1c0001%2Cffe0036f&quantity=3000&ColumnSort=1000011&page=1&k=nrf52832&pageSize=500&pkeyword=nrf52810</p> -<p>nRF52810: High performance, entry-level Bluetooth 4/ANT/2.4GHz SoC nRF52832: High performance Bluetooth 4/ANT/2.4GHz SoC nRF52840: Advanced multi-protocol System-on-Chip Supporting: Bluetooth 5, ANT/ANT+, 802.15.4 and 2.4GHz proprietary</p> -</aside> -</section><section id="iot-devices---lora" class="slide level2"> -<h2>IoT Devices - LoRA</h2> -<h3 id="modules">Modules</h3> -<table> -<thead> -<tr class="header"> -<th>Module</th> -<th>Data Rate</th> -<th style="text-align: left;">Price</th> -</tr> -</thead> -<tbody> -<tr class="odd"> -<td>RN2483A-I/RM104</td> -<td></td> -<td style="text-align: left;">$12.05 @ 250</td> -</tr> -<tr class="even"> -<td>CMWX1ZZABZ-078</td> -<td>SX1276</td> -<td style="text-align: left;">$10.74 @ 1000</td> -</tr> -<tr class="odd"> -<td>RF-LORA-868-SO</td> -<td>SX1272</td> -<td style="text-align: left;">$16.55 @ 1000</td> -</tr> -</tbody> -</table> -<h3 id="chips">Chips</h3> -<table> -<thead> -<tr class="header"> -<th>Chip</th> -<th style="text-align: left;">Price</th> -</tr> -</thead> -<tbody> -<tr class="odd"> -<td>SX1281</td> -<td style="text-align: left;">$3.23</td> -</tr> -<tr class="even"> -<td>SX1272</td> -<td style="text-align: left;">$4.25</td> -</tr> -<tr class="odd"> -<td>SX1276</td> -<td style="text-align: left;">$4.25</td> -</tr> -<tr class="even"> -<td>SX1279</td> -<td style="text-align: left;">$4.74</td> -</tr> -</tbody> -</table> -<aside class="notes"> -<p>These modules require an external MCU, so does the chips.</p> -</aside> -</section><section id="iot-devices---nb-iot" class="slide level2"> -<h2>IoT Devices - NB-IoT</h2> -<table> -<thead> -<tr class="header"> -<th>Module</th> -<th>Price</th> -</tr> -</thead> -<tbody> -<tr class="odd"> -<td>uBlox SARA-N210</td> -<td>~$10 @ 100</td> -</tr> -<tr class="even"> -<td>Sierra Wireless HL7800_1103933</td> -<td>$15.72</td> -</tr> -</tbody> -</table> -</section><section id="iot-devices---wi-fi" class="slide level2"> -<h2>IoT Devices - Wi-Fi</h2> -<table> -<thead> -<tr class="header"> -<th style="text-align: left;">Chip</th> -<th style="text-align: left;">CPU</th> -<th style="text-align: left;">Freq</th> -<th style="text-align: left;">ROM</th> -<th style="text-align: left;">RAM</th> -<th style="text-align: left;">Price</th> -</tr> -</thead> -<tbody> -<tr class="odd"> -<td style="text-align: left;">ESP8266</td> -<td style="text-align: left;">Tensilica L106</td> -<td style="text-align: left;">160 MHz</td> -<td style="text-align: left;">N/A</td> -<td style="text-align: left;">~50 kB</td> -<td style="text-align: left;">< $1</td> -</tr> -</tbody> -</table> -<p>ESP32 - dual cpu, Wi-Fi, Bluetooth 4 ESP32-D0WDQ6 2x Xtensa @ 160MHz $ 4.53 @ 10</p> -<aside class="notes"> -<p>The ESP8266’s RAM depends on which firmware stack is used. Physical is probably 128k or most likely 64k.</p> -</aside> -</section><section id="esp8266-details---power-usage" class="slide level2"> -<h2>ESP8266 details - Power usage</h2> -<table style="width:61%;"> -<colgroup> -<col style="width: 37%" /> -<col style="width: 23%" /> -</colgroup> -<thead> -<tr class="header"> -<th>State</th> -<th style="text-align: right;">Current usage</th> -</tr> -</thead> -<tbody> -<tr class="odd"> -<td>Off</td> -<td style="text-align: right;">0.5 µA</td> -</tr> -<tr class="even"> -<td>Deep sleep with RTC</td> -<td style="text-align: right;">20 µA</td> -</tr> -<tr class="odd"> -<td>Light sleep (with Wi-Fi)</td> -<td style="text-align: right;">1 mA</td> -</tr> -<tr class="even"> -<td>Sleep with peripherials</td> -<td style="text-align: right;">15 mA</td> -</tr> -<tr class="odd"> -<td>TX</td> -<td style="text-align: right;">170 mA</td> -</tr> -</tbody> -</table> -<aside class="notes"> -<p>Datasheet page 18</p> -</aside> -</section></section> -<section><section id="going-back-to-basics" class="title-slide slide level1"><h1>Going back to basics</h1></section><section id="what-is-the-internet-again" class="slide level2"> -<h2>What is the internet again?</h2> -</section><section id="tcpip-layers" class="slide level2"> -<h2>TCP/IP Layers</h2> - -</section><section id="packet-encapsulation" class="slide level2"> -<h2>Packet encapsulation</h2> - -</section><section id="network-interface" class="slide level2"> -<h2>Network interface</h2> -<ul> -<li>Ethernet -<ul> -<li>10BASE5, 10BASE2, 10BASE-T / 100BASE-TX / 1000BASE-TX</li> -</ul></li> -<li>Wi-Fi -<ul> -<li>802.11a/b/g/n</li> -</ul></li> -<li>RS-232</li> -</ul> -<aside class="notes"> -<p>Ethernet: Hubs and switches (that act on this level) is not on it’s own layer. It is more of a implementation detail in the architecture diagram.</p> -<p>RS-232 signaling is used in <em>all</em> MCUs, many have several ports available. It is extremely flexible, both used for implementing applications and debugging. Frequently an easy way to hack embedded devices. “USB dongles”, “USB TTL” all use RS-232 signaling.</p> -<p>Note that this only applies to its logical signals, not voltage levels. The signaling does not specify any max data rate, very high rates (>= 1Mbps) is often supported.</p> -</aside> -</section><section id="internet" class="slide level2"> -<h2>Internet</h2> -<ul> -<li>IP</li> -<li>ICMP</li> -</ul> -</section><section id="transport" class="slide level2"> -<h2>Transport</h2> -<ul> -<li>TCP</li> -<li>UDP</li> -<li>SCTP</li> -<li>QUIC</li> -</ul> -</section><section id="layer-7-application-layer" class="slide level2"> -<h2>Layer 7: Application Layer</h2> -<ul> -<li>HTTP</li> -<li>DNS</li> -<li>MQTT</li> -<li>CoAP</li> -<li>(everything else..)</li> -</ul> -</section><section id="details-ip-header" class="slide level2"> -<h2>Details: IP Header</h2> - -</section><section id="details-udp-header" class="slide level2"> -<h2>Details: UDP Header</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> -<ul> -<li><em>Message Queuing Telemetry Transport</em></li> -<li><a href="https://en.wikipedia.org/wiki/MQTT">Wikipedia: MQTT</a></li> -</ul> -<aside class="notes"> -<p>MQTT is <em>the</em> standard for IoT applications (and lots of other useful stuff to). Using HTTP is just silly.</p> -<p>Supports SSL, and requires TCP.</p> -<p>Has UDP-like semantics with “fire and forget” but on a higher level (the message always have to be delivered and ACKed by the broker, not it’s final recipient.</p> -<p>Version 3.1.1 er den som gjelder, V 3.1 er rar, de andre finnes ikke (før standardisering).</p> -</aside> -</section><section id="device-and-application-architecture-with-mqtt" class="slide level2"> -<h2>Device and application architecture with MQTT</h2> - -</section><section id="mqtt---implementations" class="slide level2"> -<h2>MQTT - Implementations</h2> -<ul> -<li>Mosquitto</li> -<li>Eclipse Paho</li> -<li>RabbitMQ</li> -<li>ActiveMQ</li> -</ul> -<aside class="notes"> -<p>RabbitMQ has a separate connector that must be installed Not sure about ActiveMQ but it is at least a part of the project so it is releases at the same time.</p> -</aside> -</section><section id="mqtt-cloud-connectors" class="slide level2"> -<h2>MQTT Cloud Connectors</h2> -<ul> -<li>Cloud -<ul> -<li>Amazon IoT</li> -<li>Google Cloud IoT</li> -<li>Microsoft Azure IoT</li> -<li>CloudMQTT (at Heroku)</li> -</ul></li> -<li>DIY -<ul> -<li>ThingMQ</li> -<li>HiveMQ</li> -</ul></li> -</ul> -<aside class="notes"> -<p>In between are:</p> -<ul> -<li>self hosted</li> -<li>Generic bridges</li> -</ul> -</aside> -</section><section id="mqtt---the-protocol" class="slide level2"> -<h2>MQTT - The protocol</h2> -<p>Agents have one of two roles:</p> -<ul> -<li><em>Client</em> -<ul> -<li>Publishes <em>messages</em></li> -<li>Subscribes / unsubscribes to <em>topics</em></li> -</ul></li> -<li><em>Broker</em> (aka Server) -<ul> -<li>Handles network connections</li> -<li>Keeps subscriptions</li> -<li>Manages client -<ul> -<li>Disconnects</li> -<li><em>(last) will</em></li> -</ul></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> -<p>Push vs pull, central applications can push to clients</p> -</aside> -</section><section id="mqtt---the-protocol---mqtt-packet" class="slide level2"> -<h2>MQTT - The protocol - MQTT Packet</h2> -<ul> -<li>Size oriented</li> -<li>Flags indicate type of remaining bytes -<ul> -<li>Packet type</li> -<li>Topic name</li> -<li>Payload</li> -</ul></li> -</ul> -<aside class="notes"> -<p>Only packet type + flags (1 byte) is required, everything else is optional.</p> -<p>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.</p> -</aside> -</section><section id="mqtt-connect" class="slide level2"> -<h2>MQTT Connect</h2> -<ul> -<li><code>CONNECT</code> -<ul> -<li><code>clientId</code></li> -<li><code>username</code></li> -<li><code>password</code></li> -<li><code>keepAlive</code></li> -</ul></li> -</ul> -<!-- --> -<ul> -<li>Keep alive -<ul> -<li><code>PINGREQ</code></li> -<li><code>PINGRESP</code></li> -</ul></li> -</ul> -</section><section id="mqtt---the-protocol---mqtt-topic" class="slide level2"> -<h2>MQTT - The protocol - MQTT Topic</h2> -<ul> -<li>Topic name: <code>foo/bar/baz</code></li> -<li>Topic filter -<ul> -<li><code>foo/bar/?</code></li> -<li><code>foo/#</code></li> -</ul></li> -</ul> -</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>Broker</p> -<ol type="1"> -<li><em>To all subscribers</em> <code>PUBLISH</code> -<ul> -<li><code>$app/$device/online</code></li> -<li><code>0</code></li> -</ul></li> -</ol> -</section><section id="mqtt-topic" class="slide level2"> -<h2>MQTT Topic</h2> -<p>The temperature sensor:</p> -<ul> -<li>Publishes on: -<ul> -<li><code>myapp/$device-id/temperature</code></li> -<li><code>myapp/$device-id/humidity</code></li> -<li><code>myapp/$device-id/altert</code></li> -</ul></li> -<li>Subscribes to: -<ul> -<li><code>myapp/$device-id/command</code></li> -</ul></li> -</ul> -<p>The central application:</p> -<ul> -<li>Subscribes to: -<ul> -<li><code>myapp/#/temperature</code></li> -<li><code>myapp/#/humidity</code></li> -</ul></li> -<li>Publishes on: -<ul> -<li><code>myapp/$device-id/command</code></li> -</ul></li> -</ul> -<aside class="notes"> -<p>Typical first round of implementation.</p> -<p>Commands can be: * load new firmware (maybe an URL and firmware signature). * Set new calibration values * Change reading interval, altert levels (autonomous operation)</p> -</aside> -</section><section id="mqtt-on-arduino" class="slide level2"> -<h2>MQTT on Arduino</h2> -<p>PubSubClient is our MQTT client implementation.</p> -<div class="sourceCode" id="cb6"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb6-1" data-line-number="1">WiFiClient wifiClient;</a> -<a class="sourceLine" id="cb6-2" data-line-number="2">PubSubClient mqtt(wifiClient);</a> -<a class="sourceLine" id="cb6-3" data-line-number="3"></a> -<a class="sourceLine" id="cb6-4" data-line-number="4"><span class="dt">void</span> callback(<span class="dt">char</span>* topic,</a> -<a class="sourceLine" id="cb6-5" data-line-number="5"> byte* payload,</a> -<a class="sourceLine" id="cb6-6" data-line-number="6"> <span class="dt">unsigned</span> <span class="dt">int</span> length);</a> -<a class="sourceLine" id="cb6-7" data-line-number="7"></a> -<a class="sourceLine" id="cb6-8" data-line-number="8"><span class="dt">void</span> setup() {</a> -<a class="sourceLine" id="cb6-9" data-line-number="9"> <span class="co">// Configure WiFi</span></a> -<a class="sourceLine" id="cb6-10" data-line-number="10"> mqtt.setServer(mqtt_server, <span class="dv">1883</span>);</a> -<a class="sourceLine" id="cb6-11" data-line-number="11"> mqtt.setCallback(callback);</a> -<a class="sourceLine" id="cb6-12" data-line-number="12">}</a></code></pre></div> -</section><section id="mqtt-on-arduino-1" class="slide level2"> -<h2>MQTT on Arduino</h2> -<div class="sourceCode" id="cb7"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb7-1" data-line-number="1"><span class="dt">void</span> loop() {</a> -<a class="sourceLine" id="cb7-2" data-line-number="2"> <span class="cf">if</span> (!mqtt.connected())</a> -<a class="sourceLine" id="cb7-3" data-line-number="3"> reconnect();</a> -<a class="sourceLine" id="cb7-4" data-line-number="4"> <span class="cf">else</span></a> -<a class="sourceLine" id="cb7-5" data-line-number="5"> mqtt.loop();</a> -<a class="sourceLine" id="cb7-6" data-line-number="6"> <span class="co">// Do work</span></a> -<a class="sourceLine" id="cb7-7" data-line-number="7">}</a> -<a class="sourceLine" id="cb7-8" data-line-number="8"></a> -<a class="sourceLine" id="cb7-9" data-line-number="9"><span class="dt">void</span> reconnect() {</a> -<a class="sourceLine" id="cb7-10" data-line-number="10"> <span class="cf">while</span> (!mqtt.<span class="fu">connect</span>(client_id));</a> -<a class="sourceLine" id="cb7-11" data-line-number="11"></a> -<a class="sourceLine" id="cb7-12" data-line-number="12"> mqtt.subscribe(topic_pattern);</a> -<a class="sourceLine" id="cb7-13" data-line-number="13">}</a></code></pre></div> -<aside class="notes"> -<p>This is blocking!</p> -</aside> -</section><section id="assignment" class="slide level2"> -<h2>Assignment</h2> -<ul> -<li><code>mqtt</code></li> -</ul> -</section><section id="mqtt-topic-architecture" class="slide level2"> -<h2>MQTT topic architecture</h2> -<p>The central application is split:</p> -<ul> -<li>An aggregating agent: -<ul> -<li><code>myapp/#/temperature</code></li> -<li><code>myapp/#/humidity</code></li> -</ul></li> -<li>Emailing agent -<ul> -<li><code>myapp/$device-id/altert</code></li> -</ul></li> -<li>Publishes on: -<ul> -<li><code>myapp/$device-id/command</code></li> -</ul></li> -</ul> -</section><section id="mqtt-topic-architecture-1" class="slide level2"> -<h2>MQTT topic architecture</h2> - -</section><section id="mqtt-topic-architecture-2" class="slide level2"> -<h2>MQTT topic architecture</h2> - -</section><section id="mqtt---patterns" class="slide level2"> -<h2>MQTT - Patterns</h2> -<ul> -<li>Combining MQTT and HTTP</li> -<li>Using web sockets transport</li> -</ul> -</section><section id="assignment-1" class="slide level2"> -<h2>Assignment</h2> -<ul> -<li><code>mqtt2</code></li> -</ul> -</section><section id="assignment-2" class="slide level2"> -<h2>Assignment</h2> -<ul> -<li><code>mqtt3</code></li> -</ul> -<aside class="notes"> -<p>discussion: how to connect these two devices?</p> -</aside> -</section></section> -<section class="footnotes"> -<hr /> -<ol> -<li id="fn1"><p> Wikipedia “Internet of Things”<a href="#/fnref1" class="footnote-back">↩</a></p></li> -</ol> -</section> - </div> - </div> - - <script src="./bower_components/reveal.js/lib/js/head.min.js"></script> - <script src="./bower_components/reveal.js/js/reveal.js"></script> - - <script> - - // Full list of configuration options available at: - // https://github.com/hakimel/reveal.js#configuration - Reveal.initialize({ - // Push each slide change to the browser history - history: true, - - // Optional reveal.js plugins - dependencies: [ - { src: './bower_components/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } }, - { src: './bower_components/reveal.js/plugin/zoom-js/zoom.js', async: true }, - { src: './bower_components/reveal.js/plugin/notes/notes.js', async: true } - ] - }); - </script> - </body> -</html> |