IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo...
Transcript of IOT - Embed to HTTP.pptx [Sola lettura] · %hvlghv $3,v frpsrqhqwv uhtxluh dovr dq lqlwldo...
Internet of Things!Internet of Things!Discuss with your board
How many languages in IOT?How many languages in IOT?
The web discuss in HTTP (typically)The web discuss in HTTP (typically)
and my board?and my board?
HTTPMQTT
LWM2MCOAP
UDP/IPTCP/IP
The HTTP nature
Not connected
Client/ServerClient/Server
String based
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!!!
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)
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
How the board is connected to users
Not Connected → Connected
BoardProxy
Connected TCP/IPSTREAM
User 1
BoardProxy
User 2
Other cloud services
How the proxy works
TCP/IP Module
Golang ChannelHTTPServer
s.writeChannel <- data[0]
ON/OFF LED
ModuleGolang Channel
Serverdata = <-s.writeChannel
The flip-side of the discussionThe flip-side of the discussion
The proxy cannot contact users at anytimeusers at anytime
How the board is connected to users
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
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
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???
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
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
HW Setup
Wiznet
Microcontroller
LEDs
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
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!!!
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
Make it veeery simple...
Pretty Cool, Ah?
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
Configure Ethernet Component
GateWay Address
SubNet MaskSubNet Mask
Our Node Address
TCP/IP Management 1
TCP/IP Management 2
And it Works!!!
Amazing!!!
Beeeerr!!!
Wants only Graphics???
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
Learn More
FlowCode: ● Product Website: http://www.matrixtsl.com/flowcode/● Italian Course: http://www.elettronicain.it/MyMain/corsi/
Golang:● https://golang.org/