IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo...

34
Internet of Things! Discuss with your board

Transcript of IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo...

Page 1: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Internet of Things!Internet of Things!Discuss with your board

Page 2: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

How many languages in IOT?How many languages in IOT?

Page 3: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

The web discuss in HTTP (typically)The web discuss in HTTP (typically)

Page 4: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

and my board?and my board?

Page 5: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

HTTPMQTT

LWM2MCOAP

UDP/IPTCP/IP

Page 6: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

The HTTP nature

Not connected

Client/ServerClient/Server

String based

Page 7: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW
Page 8: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Formats, parsers and low resources

We have just 2k bytes of RAM...

Ok, we have to proxy all things...

We also have to drink a couple of beers...

Beeeeeerrrr!!!

Page 9: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Board is connected directly using TCP/IP

● Connected protocol (we can discuss about this)

● New application support (we have to design it)

● New application formats (we have to design it)● New application formats (we have to design it)

● No error management (we have to design it)

● No re-connect on failures (we have to design it)

Page 10: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Users uses HTTP resources

● Resources basedo GET http://domain.tld/a-path

● Existing applicationso Browsers, Api clients etc...

● Existing formatso HTML, JSON, XML etc...

● Response code (eg. error management)o 4xx Client errorso 5xx Server errors

Page 11: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

How the board is connected to users

Page 12: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Not Connected → Connected

BoardProxy

Connected TCP/IPSTREAM

User 1

BoardProxy

User 2

Other cloud services

Page 13: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

How the proxy works

TCP/IP Module

Golang ChannelHTTPServer

s.writeChannel <- data[0]

ON/OFF LED

ModuleGolang Channel

Serverdata = <-s.writeChannel

Page 14: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

The flip-side of the discussionThe flip-side of the discussion

Page 15: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

The proxy cannot contact users at anytimeusers at anytime

Page 16: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

How the board is connected to users

Page 17: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

HTTP Client/Server model can be a problem!

● Unable to discuss with users at anytime…o Cannot shows any board figure (any nature)

● How to add the missing method?o HTTP Pollingo HTTP Long Pollingo HTTP Chunked responseso Web Sockets

● Change the application layer?o MQTT - Telemetry Transport

Page 18: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Just grab the server code! Golang!func main() {

router := mux.NewRouter()

server := proxy.Server{

Router: router,

HttpServer: &http.Server{

Addr: "0.0.0.0:8082",

Handler: router,

},},

BoardServer: &board.Server{

Addr: "0.0.0.0:9005",

},

}

server.ListenAndServe()

}

https://github.com/wdalmut/iot-http-to-low-level

Page 19: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Embedded Side

● Now the server side is up and running● I’ve still to solve the embedded side

problem…Excuse me Sir,

● How to Continue???o First I have to choose a platformo Then I have to choose a development

environment

Excuse me Sir, what do you mean Platform???

Page 20: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Which Platform?

● The Platform, in this case, is the electronic object that will embed our application

● IoT = Internet Of Things● In many cases “Small Things”...● In many cases “Small Things”...● Not much space… we have to make it as small as

possible

● Use a Microcontroller

Page 21: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

What About TCP/IP Interface?

● TCP/IP is a pretty much complicated protocol● It has been developed during ‘70 by a group of

engineers

● You don’t want to do it again...

● Use a Tcp/Ip Module● Wiznet W5100

Page 22: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

HW Setup

Wiznet

Microcontroller

LEDs

Page 23: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Looking for an Environment

● Lots of Environment for Microcontroller C code development

● Very complicated to use and understand● C language is pretty complex● C language is pretty complex

Page 24: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Just Make It Simple...

● What about a Graphic Environment?● It will reduce the code overhead and simplify application

development :-)

● Yes, it is scalable if you use it in the right way…● Yep, it could be debugged like a text based…● Yeah, it can be simulated as well…● Sure, it could… OK, please somebody stop the

questioning engineer!!!

Page 25: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Make it simple...and Smart

● We are going to use flowcode for the development of embedded side

● Flowcode is a Graphic Integrated Development Environment (or G-IDE)Environment (or G-IDE)

● It looks like a flowchart, but allow you to program microcontrollers FLASH memory

Page 26: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Make it veeery simple...

Pretty Cool, Ah?

Page 27: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Using a Component

● Inside Flowcode a lot of complex problems could be easily solved using a component

● A component is a set of API that allow you to interface a complex peripheral inside your flowchartcomplex peripheral inside your flowchart

● In Flowcode, CAN, USB, Ethernet are all components● Besides APIs, components require also an initial

configuration, in the form of, so called, “extra properties”● A component is added to a project simply

Dragging&Dropping it inside the project itself

Page 28: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Configure Ethernet Component

GateWay Address

SubNet MaskSubNet Mask

Our Node Address

Page 29: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

TCP/IP Management 1

Page 30: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

TCP/IP Management 2

Page 31: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

And it Works!!!

Amazing!!!

Beeeerr!!!

Page 32: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Wants only Graphics???

Page 33: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Code References

Embedded Code:● www.francescoficili.com

Golang Server Implementation:Golang Server Implementation:● https://github.com/wdalmut/iot-http-to-low-level

Labview Server Implementation:● www.francescoficili.com

Page 34: IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo FRQILJXUDWLRQ LQ WKH IRUP RI VR FDOOHG ³H[WUD SURSHUWLHV´ $ FRPSRQHQW LV DGGHG WR D SURMHFW

Learn More

FlowCode: ● Product Website: http://www.matrixtsl.com/flowcode/● Italian Course: http://www.elettronicain.it/MyMain/corsi/

Golang:● https://golang.org/