\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{{[}deleted{]}} \pdfinfo{ /Title (iot.pdf) /Creator (Cheatography) /Author ({[}deleted{]}) /Subject (IoT Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{IoT Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{{[}deleted{]}} via \textcolor{DarkBackground}{\uline{cheatography.com/96251/cs/22917/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}{[}deleted{]} \\ \uline{cheatography.com/deleted-96251} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 20th May, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{3.2.2.5 - Install and Configure IoT Devices}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Part 1. Setting up the Home Network}} \newline % Row Count 1 (+ 1) Step 1: Set up the wired network \newline % Row Count 2 (+ 1) Connect FastEthernet on Home Switch to Home Gateway using a coper straight-through cable. \newline % Row Count 4 (+ 2) Connect FastEthernet0 on PC -\textgreater{} FastEthernet on HomeSwitch \newline % Row Count 6 (+ 2) Set IPConfig of PC to DHCP \newline % Row Count 7 (+ 1) Step 2: Set up the wireless network \newline % Row Count 8 (+ 1) Home Gateway -\textgreater{} Config -\textgreater{} Internet -\textgreater{} select DHCP \newline % Row Count 9 (+ 1) Home Gateway -\textgreater{} Wireless -\textgreater{} change SSID to MyHome Gateway, auth to WPA2-PSK, use CiscoIoT as passphrase \newline % Row Count 12 (+ 3) Laptop -\textgreater{} Desktop -\textgreater{} PC Wireless -\textgreater{} Connect -\textgreater{} select MyHomeGateway -\textgreater{} connect \newline % Row Count 14 (+ 2) Step 3: Connect the IoT devices to the network \newline % Row Count 15 (+ 1) Connect Coffee Pot to FastEthernet using copper straight-through cable \newline % Row Count 17 (+ 2) Coffee Pot -\textgreater{} Config -\textgreater{} FastEthernet0 -\textgreater{} select DHCP \newline % Row Count 19 (+ 2) Lamp/Ceiling Fan -\textgreater{} Config -\textgreater{} Wireless0 -\textgreater{} connect to MyHomeGateway \newline % Row Count 21 (+ 2) {\bf{Part 2. Interacting with IoT devices}} \newline % Row Count 22 (+ 1) Step 1: Acces the IoT devices locally \newline % Row Count 23 (+ 1) Click Alt + Lamp a few times, how many settings does the lamp have: 3 \newline % Row Count 25 (+ 2) Alt + Lamp Switch: 2 \newline % Row Count 26 (+ 1) Alt + Ceiling Fan: 3, Switch: 2 \newline % Row Count 27 (+ 1) Alt + Coffee Pot: 2, Swtich: 2 \newline % Row Count 28 (+ 1) Step 2: Configure the IoT devices for remote access \newline % Row Count 30 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{3.2.2.5 - Install and Configure IoT Devices (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Lamp/Ceiling Fan/Coffee Pot -\textgreater{} Config -\textgreater{} IoE Server heading -\textgreater{} Remote server: \newline % Row Count 2 (+ 2) Server address: www.register.pka \newline % Row Count 3 (+ 1) Username: admin \newline % Row Count 4 (+ 1) Password: admin \newline % Row Count 5 (+ 1) -\textgreater{} connect \newline % Row Count 6 (+ 1) Step 3: Access the IoT devices remotely \newline % Row Count 7 (+ 1) Laptop/Smartphone -\textgreater{} Desktop -\textgreater{} Webbrowser -\textgreater{} www.register.pka -\textgreater{} login with admin:admin \newline % Row Count 9 (+ 2) Devices can be controlle% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Coffee Pot ins Internet h{\"a}ngen}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Netcat starten: `nc -l 1234` \newline % Row Count 1 (+ 1) Javascript Code beim Coffee Pot unter Advanced -\textgreater{} Programming einfügen: \newline % Row Count 3 (+ 2) var state = 0; \newline % Row Count 4 (+ 1) var client = new RealTCPClient(); \newline % Row Count 5 (+ 1) var coffeestatus = {[}"Off","On"{]}; \newline % Row Count 6 (+ 1) function setup() \{ \newline % Row Count 7 (+ 1) // 17 Zeilen ... \newline % Row Count 8 (+ 1) setState(state); \newline % Row Count 9 (+ 1) client.connect("ip", 1234); \newline % Row Count 10 (+ 1) \} \newline % Row Count 11 (+ 1) // 10 Zeilen ... \newline % Row Count 12 (+ 1) function setState(newState) \{ \newline % Row Count 13 (+ 1) // 10 Zeilen; client.send als letzte Zeile einfügen: \newline % Row Count 15 (+ 2) client.send(getName()+": "+coffeestatus{[}state{]}+"\textbackslash{}n"); \newline % Row Count 17 (+ 2) \} \newline % Row Count 18 (+ 1) Netcat bekommt nun (nach Neustart und Cofee Pot Stop/Start/Altclick) Nachrichten% Row Count 20 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Mozilla Webthings Gateway}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Lubuntu in VM Winstallieren, Firefox in der VM starten, Mozilla Webgateway installieren und starten, im Browser auf Configseite gehen.% Row Count 3 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Codeexample}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Dependency installieren: `pip install webthing` \newline \newline from \_\_future\_\_ import division \newline from webthing import (Action, Event, Property, SingleThing, Thing, Value, \newline WebThingServer) \newline import logging \newline import time \newline import uuid \newline \newline \# Ein Event dass Überhitzung indiziert \newline class OverheatedEvent(Event): \newline \newline def \_\_init\_\_(self, thing, data): \newline Event.\_\_init\_\_(self, thing, 'overheated', data=data) \newline \newline \newline \# eine Action, welche die Lampe "faden" l{\"a}sst \newline class FadeAction(Action): \newline \newline def \_\_init\_\_(self, thing, input\_): \newline Action.\_\_init\_\_(self, uuid.uuid4().hex, thing, 'fade', input\_=input\_) \newline \newline def perform\_action(self): \newline time.sleep(self.input{[}'duration'{]} / 1000) \newline \seqsplit{self.thing.set\_property('brightness'}, self.input{[}'brightness'{]}) \newline \seqsplit{self.thing.add\_event(OverheatedEvent(self.thing}, 102)) \newline \newline \newline def make\_thing(): \newline \# lamp thing erstellen, kann ein/aus geschalten werden, hat verschiedene properties \newline thing = Thing( \newline \seqsplit{'urn:dev:ops:my-lamp-1234'}, \newline 'My Lamp', \newline {[}'OnOffSwitch', 'Light'{]}, \newline 'A web connected lamp' \newline ) \newline \newline thing.add\_property( \newline Property(thing, \newline 'on', \newline Value(True), \newline metadata=\{ \newline '@type': 'OnOffProperty', \newline 'title': 'On/Off', \newline 'type': 'boolean', \newline 'description': 'Whether the lamp is turned on', \newline \})) \newline thing.add\_property( \newline Property(thing, \newline 'brightness', \newline Value(50), \newline metadata=\{ \newline '@type': 'BrightnessProperty', \newline 'title': 'Brightness', \newline 'type': 'integer', \newline 'description': 'The level of light from 0-100', \newline 'minimum': 0, \newline 'maximum': 100, \newline 'unit': 'percent', \newline \})) \newline \newline \seqsplit{thing.add\_available\_action(} \newline 'fade', \newline \{ \newline 'title': 'Fade', \newline 'description': 'Fade the lamp to a given level', \newline 'input': \{ \newline 'type': 'object', \newline 'required': {[} \newline 'brightness', \newline 'duration', \newline {]}, \newline 'properties': \{ \newline 'brightness': \{ \newline 'type': 'integer', \newline 'minimum': 0, \newline 'maximum': 100, \newline 'unit': 'percent', \newline \}, \newline 'duration': \{ \newline 'type': 'integer', \newline 'minimum': 1, \newline 'unit': 'milliseconds', \newline \}, \newline \}, \newline \}, \newline \}, \newline FadeAction) \newline \newline \seqsplit{thing.add\_available\_event(} \newline 'overheated', \newline \{ \newline 'description': \newline 'The lamp has exceeded its safe operating temperature', \newline 'type': 'number', \newline 'unit': 'degree celsius', \newline \}) \newline \newline return thing \newline \newline \newline def run\_server(): \newline \# thing erstellen \newline thing = make\_thing() \newline \newline \# webserver starten \newline \# If adding more than one thing, use MultipleThings() with a name. \newline \# In the single thing case, the thing's name will be broadcast. \newline server = \seqsplit{WebThingServer(SingleThing(thing)}, port=8888) \newline try: \newline logging.info('starting the server') \newline server.start() \newline except KeyboardInterrupt: \newline logging.info('stopping the server') \newline server.stop() \newline logging.info('done') \newline \newline \newline if \_\_name\_\_ == '\_\_main\_\_': \newline logging.basicConfig( \newline level=10, \newline format="\%(asctime)s \seqsplit{\%(filename)s:\%(lineno)s} \%(levelname)s \%(message)s" \newline ) \newline \# server starten \newline run\_server()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}