IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web...

81
IoT Physical Servers, Cloud Offerings and IoT Case Studies Mrs. K.M. Sanghavi

Transcript of IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web...

Page 1: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

IoT Physical Servers, Cloud Offerings and IoT Case Studies

Mrs. K.M. Sanghavi

Page 2: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Contents

• Communication API • Web Application Messaging Protocol (WAMP) :

Autobahn for IoT • Xively Cloud for IoT • Python Web Application Framework: Djanjo • Amazon Web Services for IoT • SkyNet IoT Messaging Platform • Case Studies

– Home Intrusion Detection – Weather Monitoring System – Air Pollution Monitoring – Smart Irrigation

Page 3: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Communication API

• Facilitate

– Data Transfer

– Information Transfer

– Service Transfer

• Support

– Publish Subscribe models

• Use

– Remote Procedure Call

Page 4: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• WebSocket is a network communication protocol, which is required for many advanced features.

• Why do we need WebSocket?

• The answer is that because the HTTP protocol has a flaw: communication only can be initiated by the client.

WebSocket

Page 5: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• For example, let's say we want to know the weather today: the server will return the results of the query only if the client makes a request to the server.

• The HTTP protocol doesn't allow the server to push information to the client actively.

WebSocket

Page 6: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Unidirectional

• Half duplex

• Stateless

• For each request, TCP connection has to be established first.

• Therefore, in order to find a better way, engineers invented WebSocket.

Problems with HTTP

Page 7: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• The biggest feature of the protocol is that the server can push information to the client actively, and the client can also send information to the server actively.

• It is a true two-way equal communication and is one of the server push technologies.

• It's based on the TCP protocol, and the implementation on the server side is relatively easy.

• It uses Publish – Subscribe communication model

WebSocket

Page 8: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• The data format is relatively light, and the performance overhead is small, but the communication is efficient

• Uses port number 443 and also 80

• Client can communicate with any server.

• The protocol identifier is ws (wss if encrypted) , and the URL is exactly the server's URL.

• ws://example.com:80/some/path

WebSocket

Page 9: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WebSocket

Page 10: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WebSocket

Is Great for Apps like :

Chat Trading

Multiplayer games Real – time charts

Page 11: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WAMP

Problem #1

• Its now no longer a time now to be static

• All the web applications need dynamism

• The web applications now should automatically get updated

• To solve this we use WAMP.

Page 12: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WAMP

• It is a subprotocol of WebSocket

• It is a routed protocol that means it requires a central router server to work.

• Enables different technologies,processes and machines to communicate with each other at real time.

• It offers two tools : Remote Procedure Call(RPC) and Pub / Sub

• Messages on WAMP are based on JSON format.

Page 13: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WAMP

Page 14: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WAMP

Page 15: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WAMP

Page 16: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WAMP

• Transport: Transport is a channel that connects two peers.

• Session: Session is a conversation between two peers that runs over a transport.

• Client: Clients are peers that can have one or more roles.

• In the publish–subscribe model, the Client can have the following roles:

–Publisher: Publisher publishes events (including payload) to the topic

maintained by the Broker.

–Subscriber: Subscriber subscribes to the topics and receives the events

including the payload.

•In the RPC model, the Client can have the following roles:

–Caller: Caller issues calls to the remote procedures along with call arguments.

–Callee: Callee executes the procedures to which the calls are issued by the

Caller and returns the results to the Caller.

Page 17: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

WAMP

• Router: Routers are peers that perform generic call and event routing.

• In the publish–subscribe model, the Router has the role of a Broker.

–Broker: Broker acts as a Router and routes messages published to a topic to all

the subscribers subscribed to the topic.

• In the RPC model, the Router has the role of a Dealer.

–Dealer: Dealer acts a router and routes RPC calls from the Caller to the

Callee and routes results from the Calleeto the Caller.

• Application code: Application code runs on the Clients (Publisher, Subscriber, Callee or

Caller).

Page 18: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

AUTOBAHN for IoT

Open source(MIT) real-time framework

Framework for WAMP and WebSocket i.e Web, Mobile and IoT

Compatible with Python 2.7

Supports TLS(Transport Layer Security) (secured WebSocket)

Page 19: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

AUTOBAHN for IoT

Client

Roles for Pub/Sub

Roles for RPC

Subscriber

Publisher

Callee

Caller

Router

Roles for Pub/Sub

Roles for RPC

Broker

Dealer

Transport

Session

Communication channel

Page 20: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Autobahn framework working

WAMP Application deploy on

client

Client publishes the

event

Client messages to the router

Router runs on server and

sends the events to the Subscriber /

Callee

Page 21: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Autobahn Installation for WAMP

Installation

• $ sudo apt-get install python-twisted python-dev

• $ sudo apt-get install python-pip

• $ sudo pip install-upgrade twisted

• $ sudo pip install-upgrade autobahn

Implementation

• $ git clone https://github.com/tavendo/AutobahnPython.git

Page 22: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Xively Cloud

It is an IoT Cloud Platform

Builds , manages and derive business value from connected products

Provides cloud base API

It is a PAAS via RESTful API

Supports messaging service based on MQTT

Page 23: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Xively Concepts

Xively device: It is your “device” or the IoT project you are building. Consider it as an envelope containing the data.

Channels: It is the streaming coming from your sensors. Usually, the channel number is equal to the sensor number (as long as you want to monitor them all).

Page 24: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Sending data to Xively and monitoring

Adding the “device” to our account

Define the channels

Use the Xively library for your device

Send data to Cloud

Run the Code

Create a dashboard using the data stored in Xively.

Page 25: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Adding the “device” to our account

Page 26: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Define the channels

Page 27: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Add Xively library to the device

#include <b64.h> #include <HttpClient.h> #include <SPI.h> #include <Ethernet.h> #include <HttpClient.h> #include <Xively.h> #include "DHT.h“ #define DHTPIN 2 #define DHTTYPE DHT11 byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; EthernetClient client;

Page 28: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Add Xively library to the device

IPAddress ip(192, 168, 1, 40); // Arduino IP Add IPAddress myDns(8,8,8,8); IPAddress myGateway(192,168,1,1); int moisturePin = 0; int lightPin = 3; DHT dht(DHTPIN, DHTTYPE); // Xively setup char xivelyKey[] = "your_Xively_key_here"; char lightId[] = "Light"; char tempId[] = "Temperature"; char pressId[] = "Humidity"; char moistId[] = "Moisture";

Page 29: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Add Xively library to the device

XivelyDatastream datastreams[] = {

XivelyDatastream(lightId, strlen(lightId), DATASTREAM_FLOAT),

XivelyDatastream(tempId, strlen(tempId),DATASTREAM_FLOAT),

XivelyDatastream(pressId, strlen(pressId),DATASTREAM_FLOAT),

XivelyDatastream(moistId, strlen(moistId),DATASTREAM_FLOAT)

};

XivelyFeed feed(739668463, datastreams, 4);

XivelyClient xivelyclient(client);

Page 30: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Add Xively library to the device

void setup() { Serial.begin(9600); Serial.print("Starting..."); setupNet(); dht.begin(); } void loop() { float soilHum = analogRead(moisturePin); soilHum = (1023 - soilHum) * 100 /1023; Serial.println("Soil Humidty: " + String(soilHum)); // Read light float volts = analogRead(lightPin) * 5.0 / 1024.0; float amps = volts /10000.0;

Page 31: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Add Xively library to the device

float microamps = amps * 1000000; float lux = microamps * 2.0; Serial.println("Lux: " + String(lux)); float h = dht.readHumidity(); float temp = dht.readTemperature(); Serial.println("Temp: " + String(temp,2)); Serial.println("Hum: " + String(h,2)); // Prepare to send data datastreams[0].setFloat(lux); datastreams[1].setFloat(temp); datastreams[2].setFloat(h); datastreams[3].setFloat(soilHum); int ret = xivelyclient.put(feed, xivelyKey); Serial.println("Client returns ["+String(ret)+"]"); delay(5000); }

Page 32: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Add Xively library to the device

void setupNet() {

Serial.println("Set up network access.....");

if (Ethernet.begin(mac) == 0) {

Serial.println("Failed to configure Ethernet using DHCP");

// try to congifure using IP address instead of DHCP:

Ethernet.begin(mac,ip,myDns,myGateway);

}

}

Page 33: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Add Xively library to the device

• XivelyDatastream that holds the four stream we send to Xively platform.

• Each channel defined previously using Xively interface corresponds to a XivelyDatastream.

• Remember to use in the data stream the same name used in the Xively interface.

Page 34: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Xively data

Page 35: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Creating dashboard

• Use Freeboard.io. This is a free IoT dashboard tool that can be integrated with Xively easily.

• It helps us to represent the information stored in Xively using charts.

Page 36: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Creating dashboard..connect freeboard.io

• Connecting Freeboard.io to Xively.

• This can be done easily using API Key.

Page 37: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Creating dashboard..create chart

• Create charts connecting them to the Xively channels covered before.

Page 38: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Creating dashboard..create your dashboard

• Create dashboard

Page 39: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Django

K M Sanghavi

Page 40: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Why Django framework and what is it

MVC-MVT Architecture

HandOn Django

Building Blocks of Django

Django Project Web Application

Agenda

Page 41: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Why Django framework

Django is a python framework which a code library that provide tools

and libraries to simplify common web development operations.

A framework provides a structure and common methods to make a

life of a web app developer much easier for flexible , scalable and

maintainable web applications

Page 42: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

What is Django framework

It is a high level and has MVC-MVT style based architecture

It is written in powerful python

language

Page 43: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Features of Django

Page 44: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Django MVC-MVT Architecture

It is slightly different from MVC, as here Django takes part of Controller itself .

The template is either HTML or forms mixed with Django Template

Language(DTL)

Page 45: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Django MVT

The developer provides the model, the view and template then just maps

it to the URL and Django provides service to the user.

Page 46: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Hands On

Let’s create a Web App Using Django…on Linux

Page 47: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Update the System

$ sudo apt-get update

• Install Django

$ sudo apt-get install python-django

• Check if Django is Installed

$ django-admin --version

Django Installation

Page 48: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Open the terminal and create a directory

$ mkdir ks1

• Change the directory to the newly formed directory

$ cd ks1

• Create the Django Project

ks1 $ django-admin startproject Kfirst

This will create Kfirst folder with following structure

Django Web App..Create Project

Kfirst/ manage.py Kfirst/ _init_.py settings.py urls.py wsgi.py

Page 49: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Django Project Structure

Kfirst/

manage.py

KFirst/ _init_.py settings.py urls.py wsgi.py

Kfirst folder is just the project container / directory. We can rename it to anything we like

This Kfirst folder is actual python package of your project wchich contains some default files

Page 50: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Change the directory to the Kfirst

$ cd Kfirst

• Run the Server

ks1/Kfirst/ $ python manage.py runserver

• Go to the browser and type

localhost:8000

The following o/p is shown on browser window

Django Web App…RunServer

Page 51: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Create the App

ks1/Kfirst $ python manage.py startapp Kfirstapp

This adds certain files into Kfirstapp folder

• Register the Kfirstapp it with our Django project “Kfirst".

– To do so, update INSTALLED_APPS tuple in the settings.py file of your project Kfirst\Kfirst (add your app name)

Django Web App…Create App

INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ‘Kfirstapp', )

Page 52: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Initiate the database, to have access to admin interface

ks1/Kfirst $ python manage.py syncdb

• Open the Kfirst/urls.py and you should have something like −

Django Web App…Admin Interface

from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns(‘ ‘, url(r'^admin/', include(admin.site.urls)), )

Page 53: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Django Web App…Admin Interface

• Run the Server #ignore if server is already running ks1/Kfirst/ $ python manage.py runserver

• Go to the browser and type localhost:8000/admin/

The following o/p is shown on browser window

Page 54: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Open the Kfirstapp/views.py and add as per following −

Django Web App…Create View

from django.http import HttpResponse def hello(request): text = """<h1>welcome to my app !</h1>""" return HttpResponse(text)

Page 55: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Open the myproject/urls.py and add as per following −

Django Web App…URL Mapping

from django.conf.urls import patterns, include, url from django.contrib import admin from Kfirstapp import views admin.autodiscover() urlpatterns = patterns(‘ ‘, url(r'^admin/', include(admin.site.urls)), url(r'^hello/$', views.hello, name=‘hello')

)

Page 56: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Django Web App…Access Web App

• Run the Server #ignore if server is already running ks1/Kfirst/ $ python manage.py runserver

• Go to the browser and type localhost:8000/hello

Page 57: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Hands On

Let’s create a Web App Using Django…on Windows

Page 58: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Install Python – https://python.org/downloads/

• Check if Python is Installed $ python –version

• If O/P is Python 3.x.x …python has been installed

• Install Django $ pip install django

• verify your Django installation by executing $ django-admin --version

$ If O/P is 2.1.7…Django has been installed

For Django Installation..On Windows

Page 59: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Open the command prompt and create a directory

$ mkdir ks1

• Change the directory to the newly formed directory

$ cd ks1

• Create the Django Project

ks1 $ django-admin startproject Kfirst

This will create Kfirst folder with following structure

Django Web App..Create Project ..On Windows

Kfirst/ manage.py Kfirst/ _init_.py settings.py urls.py wsgi.py

Page 60: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Change the directory to the Kfirst

$ cd Kfirst

• Run the Server

ks1/Kfirst/ $ python manage.py runserver

• Go to the browser and type

localhost:8000

The following o/p is shown on browser window

Django Web App…RunServer..On Windows

Page 61: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python
Page 62: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Create the App in another command-prompt in Kfirst folder ks1/Kfirst $ python manage.py startapp Kfirstapp

This adds certain files into Kfirstapp folder

• Register the Kfirstapp it with our Django project “Kfirst". – To do so, update INSTALLED_APPS tuple in the settings.py file

(in Kfirst\Kfirst folder)

(add your app name)

Django Web App…Create App…On Windows

INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ‘Kfirstapp', )

Page 63: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Initiate the database, to have access to admin interface …(Run this command in the project folder)

ks1/Kfirst $ python manage.py migrate

• Open the Kfirst/Kfirst/urls.py and you should have something like −

Django Web App…Admin Interface..on Windows

from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = [ path(‘admin/', admin.site.urls), ]

Page 64: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Django Web App…Admin Interface.. On Windows

• Run the Server #ignore if server is already running ks1/Kfirst/ $ python manage.py runserver

• Go to the browser and type localhost:8000/admin/

The following o/p is shown on browser window

Page 65: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python
Page 66: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Open the Kfirstapp/views.py and add as per following −

Django Web App…Create View…On windows

from django.http import HttpResponse def hello(request): text = """<h1>welcome to my app !</h1>""" return HttpResponse(text)

Page 67: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• To call the view, we need to map it to a URL - and for this we need a URLconf.

• To create a URLconf in the Kfirstapp directory, create a file called urls.py. Your app directory should now look like:

URL Mapping…On windows

from django.urls import path from .import views urlpatterns= [ path(‘ ‘, views.hello, name=‘hello’), )

Page 68: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

• Change the urls.py in Kfirst\Kfirst folder.

from django.urls import include, path from django.contrib import admin urlpatterns = [ path('admin/', admin.site.urls), path('Kfirstapp/', include(‘Kfirstapp.urls’)),

)

URL Mapping…On windows

Page 69: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Django Web App…Access Web App

• Run the Server #ignore if server is already running ks1/Kfirst/ $ python manage.py runserver

• Go to the browser and type localhost:8000/Kfirstapp

• This is the final output.

Page 70: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Amazon Web Services

• What is AWS • Why to Use AWS • AWS Service Overview • Cost of AWS • Future of AWS

Page 71: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Amazon Web Services

Global Cloud Platform

Used by 80% of fortune 500 Companies

Infrastructure as a service

Platform as a service

Software as a service

Cloud Storage PLatform

Page 72: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Why to Use AWS

Per Hour Billing Easy Sign Up

Simple Billing Stable

Trusted Vendor

Page 73: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

AWS Service Overview

Elastic Cloud Compute (EC2)

• Gives PAAS Service as per requirements

Virtual Private Cloud(VPC)

• Allows to create networks and allows servers to be in those networks

Simple Storage Service(S3)

• Gives Opportunity to Upload and Store filesi.e File Storage and Sharng service

Relational Database Service(RDS)

• Allows to Run and manage database on cloud

AutoScaling

• Adds Capacity on a fly to the ELB , so as to let the application never down due to load

Route 53

• It has DNS Routing Service

Elastic Load Balanacer(ELB)

• Gives Opportunity to Load Balance in the coming traffic to multiple machines; so that web app can scale up to any number of users

Page 74: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

AWS Service Overview

Elastic Cloud Compute (EC2)

• Gives PAAS Service as per requirements

Virtual Private Cloud(VPC)

• Allows to create networks and allows servers to be in those networks

Simple Storage Service(S3)

• Gives Opportunity to Upload and Store filesi.e File Storage and Sharng service

Relational Database Service(RDS)

• Allows to Run and manage database on cloud

AutoScaling

Route 53

• It has DNS Routing Service

Elastic Load Balanacer(ELB)

• Gives Oppurtunity to Load Balance in the coming traffic to multiple machines; so that web app can scale up to any number of users

Page 75: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Cost of AWS

• Per Hour Billing • Region Wise Billing • Term specific billing • Spot Resources…Bidding

Page 76: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Future of AWS

• 64 Services there in total • Focus on Machine Learning • Focus on SAAS products • Reduction in Costs

Page 77: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

SKYNET ..IOT MESSAGING PLATFORM

K M Sanghavi

Page 78: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

Skynet

■ Open source

■ Instant Messaging (IM) service for connected devices and services

■ Launched recently.

■ Cloud-based MQTT-powered network

■ Scales to meet any needs whether the nodes are smart home devices, sensors, cloud resources, drones, Arduinos, Raspberry Pis, among others.

■ Powered by Node.JS,

■ Combines IoT with Artificial Intelligence

■ Supports Pub/SUb

Page 79: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

■ When nodes and devices register with Skynet, they are assigned a unique id known as a UUID along with a security token

■ Upon connecting your node or device to Skynet, you can query and update devices on the network and send machine-to-machine (M2M) messages in an RPC-style fashion.

■ Real time M2M communication is what Skynet aims for.

■ SkyNet runs as an IoT platform-as-a-service (PaaS) as well as a private cloud through Docker

Skynet

Page 80: IoT Physical Servers, Cloud Offerings and IoT Case …...Contents •Communication API •Web Application Messaging Protocol (WAMP) : Autobahn for IoT •Xively Cloud for IoT •Python

■ With SkyNet platform, we are able to save a ton of work by not having to develop our own communication tools, authentication scheme, or backend service to handle the streams of data

■ Instead, our devices simply turn on, authenticate and connect with SkyNet automatically, and we are able to start passing data securely

Skynet