Lecture 5 - ioT Programming Languages
Lecture 5 - ioT Programming Languages
Languages
2
IoT Architectures
3
Cloud, Fog, Edge
4
Cloud Computing
5
Fog Computing
6
Edge
7
Application Logic (for IoT devices)
8
Webservers from and IoT Perspective
9
Client Pull
10
Server Push
11
IoT
Programming
Languages
12
IoT Languages
13
Embedded Languages
Embedded Languages
support low-level coding to exploit the
underlying hardware,
support in-line assembly code,
flag dynamic memory-allocation and recursion,
provide exclusive access to I/O registers
Common Languages include C, C++, (micro)Python,
Rust
14
Order of Importance
15
Carrier Language / Protocols
16
Data Storage
17
Data Analysis
18
Creating a Balanced IoT Application
19
Server Side
Programming
20
IoT Server Side Languages
General Characteristics:
Web oriented programming language:
Any scripting language or CGI that supports
HTTP, HTTPS, TCP/IP or related protocols.
PHP, NodeJS, ASP, JSP etc.
Receive and process requests.
Respond if necessary, or acknowledge.
There is no client-side scripting.
No JS involved for the IoT device,but may be
used for client-side application
21
PHP Basics
Hypertext Preprocessor
Allows for the creation of dynamic websites.
PHP scripts run and generate HTML to be
rendered by a web browser.
Can respond to a request via a URL and return
information to an IoT device.
Messages for IoT devices can be simple without
any styling required for results to be rendered.
22
Why use PHP for IoT?
23
Why use PHP for IoT?
24
Re-introducing some PHP Basics
25
Re-introducing some PHP Basics
26
Re-introducing some PHP Basics
Strings can be single quoted (literal)
echo 'this is a $var';
output: this is a $var
Double quoted will print variables
$var = ‘string’;
echo “this is a $var”;
output: this is a string
Strings can be concatenated with .
$s1 = “Hello”;
$s2 = “World”;
$echo $s1 . ” “ . $s2;
output: Hello World
27
Re-introducing some PHP Basics
Operators
Arithmetic: +, -, *, /, %
Setting variable: =
Comparison: ==, ===, !=, !==, <, > <=, >=
Bit: &, |, ^, ~, <<, >>
Logical Operators
$a and $b
$a or $b
$a xor $b
!$a;
$a && $b;
$a || $b;
28
End Node
Interaction
29
Sending data to the server
30
URL Encoding
temp=value1&humidity=value2&location=port+arthur
31
Get Method
http://123.com/test.php?temp=value1&humidity=value2
32
GET disadvantages
33
GET example
34
Requests example
import requests
server = 'http://iotserver.com/test.php'
payload = {'num' : '6'}
r = requests.get(server, params = payload)
print(r.text)
35
POST Method
36
POST disadvantages
37
Requests example
import requests
server = 'http://iotserver.com/test.php'
payload = {'num': '6'}
r = requests.post(url, data = payload)
print(r.text)
38
Coming up...
Next week:
More on IoT server
programming, protocols and
languages.