enabling the internet of things short range wireless and m2m

96
Enabling the Internet of Things Short Range Wireless and M2M

Upload: eli-wey

Post on 01-Apr-2015

229 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Enabling the Internet of Things Short Range Wireless and M2M

Enabling the Internet of Things

Short Range Wireless and M2M

Page 2: Enabling the Internet of Things Short Range Wireless and M2M

Our Expertise

Intelligent Embedded Wireless Communications

Bluetooth, 802.11, 802.15.4 (ZigBee), Wibree

Wireless agnostic scripting language

Middleware and Data Synchronisation

Low Power, High Efficiency Modules

Page 3: Enabling the Internet of Things Short Range Wireless and M2M

Serving an embedded market

Built in internet connectivity

Expertise in Automotive, Medical and Retail

Integrated Protocol stacks and protocol conversion

Fast time to market

Enabling over 5 million credit card transactions daily

Page 4: Enabling the Internet of Things Short Range Wireless and M2M

Things just want to connect…

My temperature is…My temperature is… Your Blood Pressure is…Your Blood Pressure is… I’ve just driven…I’ve just driven…

I’ve copied…I’ve copied… I can see…I can see… I’ve sold…I’ve sold…

Now there’s an easy, wireless way to do it.

Page 5: Enabling the Internet of Things Short Range Wireless and M2M

The Internet of Things

+ “Thing” + Internet

= M2MWelcome to the world of Cellular-Free communications.

Page 6: Enabling the Internet of Things Short Range Wireless and M2M

“Things” are “Host-free”

• Most machines have very limited host processing capability.• Using External Processors mean more power, more cost, greater time-

to-market and the need for expensive programming resource.• The Internet of Things need wireless processors that do everything.• EZURiO provides everything you need in one module.

Page 7: Enabling the Internet of Things Short Range Wireless and M2M

What Designers Ask

These are the Key Features for “Time to Market”

EZURiO

Does it wake up and take control?

Can it find and connect to an access point?

Can it tell the middleware its IP address?

Can it store read and data from sensors?

Can I get rid of an additional processor?

Can it run a user program?

Can it be programmed with simple tools?

Page 8: Enabling the Internet of Things Short Range Wireless and M2M

All you need in one package

EZURiO

Solution User accessible processor

Scripting Language

Integrated Antenna

Easy to integrate

Module 802.11b/g

Web Server

I/O and ADC

General Physical Size v. Small

Bluetooth Compatible

Simple Software Development Tools

Performance Power Consumption Low

Power Save Modes

EZURiO modules are pin compatible with Siemens GPRS MC55/56

Page 9: Enabling the Internet of Things Short Range Wireless and M2M

Enabling your “Thing”

Serial In >>> Wireless Out

• No host processing requirements – just send simple commands• Integrated 802.11 driver gives silicon independence• Integrated Bluetooth or TCP/IP stack • Access to I/O and ADC• AT Interface (Bluetooth)• Interpreter (802.11) to run scripts for data acquisition and wireless attachment

RS-232 Data & Commands

RF

Page 10: Enabling the Internet of Things Short Range Wireless and M2M

What’s in an EZURiO Module?

RAM

ARMProcessor + UWUART

Power Management

802.11 b/g

Flash

I/O

ConnectionScripting

Event Handling

Page 11: Enabling the Internet of Things Short Range Wireless and M2M

Non-volatile Memory

Our Module Architecture

ADC DAC GPIO High Speed UART

I/O Controller

UNIVERSAL WIRELESS

Scripting Interpreter

Web Server WirelessProtocol Stack

(TCP/IP + Driver)

Baseband

Radio

AES

Program Memory

UWScripts

128 bit Encryption

WEP / WPACompare “Standard”Wireless Module

Everything you need is in one module – it really is “Serial In >>> Wireless Out”

Flash Filing System

Page 12: Enabling the Internet of Things Short Range Wireless and M2M

802.11 Basics

Nick Hunn - CTO

Page 13: Enabling the Internet of Things Short Range Wireless and M2M

802.11b & g channels

US 11 channels

EU 13 channels

Japan 14 channels Channel Spacing – 5MHz

Cells (access points) can overlap as long as the transmitter in one does not result in overload in the adjacent cell.

This means the channels selected should be 25MHz apart.

16

11

11

11

1

16

•802.11 b & g operate at 2.4GHz – the same frequency band as Bluetooth and ZigBee.•The spectrum is divided into multiple channels, spaced 5MHz apart. •Access Points operate on a fixed, selected channel using DSSS. They do not frequency hop. •There is NO channel width specified, but a spectral mask of -30dm @ + 11MHz

Page 14: Enabling the Internet of Things Short Range Wireless and M2M

802.11 Architecture - Infrastructure

• BSSID - Unique Name – MAC Address

• SSID – Access Point Name

• BSS Type – Infrastructure Mode

“Clients” ASSOCIATE with Access Points.

All 802.11 devices have a unique 48 bit MAC address.

If Access Points have the same SSID and are connected to a backbone, then clients can ROAM between them.

Clients

Access Point

Infrastructure Mode

Page 15: Enabling the Internet of Things Short Range Wireless and M2M

802.11 Architecture – Ad-hoc

The Client starting the ad-hoc network acts as the “Access Point” to which other clients connect.

Devices can either connect in Infrastructure or ad-hoc mode. They cannot do both simultaneously.

Ad-hoc mode does not support Power Saving modes.

Ad-hoc is also known as IBSS (Independent Basic Service Set)

First Client Clients

Ad-hoc Mode

Page 16: Enabling the Internet of Things Short Range Wireless and M2M

Data Packets

Header Source Address

Destination Address

SSID Address

Payload Frame Check

Simplified 802.11 packet

Header Destination Address

Source Address

Data Frame Check

Symbol Rate Coding

802.11g

54 64QAM

48 64QAM

36 16QAM

24 16QAM

18 QPSK

12 QPSK

802.11b 11 CCK

802.11g9 BPSK

6 BPSK

802.11b

5.5 CCK

2 DQPSK

1 DBSPK

Only a relatively small part of each transmitted packet contains data.

A lot of the transmitted information is concerned with routing information, protocols and integrity checking.

The data rate is shared between all connected clients.

Real Data throughputs never match symbol rates.

Page 17: Enabling the Internet of Things Short Range Wireless and M2M

802.11 Range and Throughput

Range and throughput are closely linked – the more complex the coding scheme, the shorter the range.

0 5 10 15 20 25 30

54

48

36

24

18

12

11

9

6

5.5

2

1

802.11g only

Mixed 802.11b + 802.11g

Range (m) Throughput (Mbps)

Symbol Rate

0 20 40 60 80 100 120

54

48

36

24

18

12

11

9

6

5.5

2

1

Symbol Rate

Page 18: Enabling the Internet of Things Short Range Wireless and M2M

Throughput & Latency

• Throughput and latency are not related. They rarely go together

• Decide what is important:– Latency– Reliability (QoS)– Raw Data Rate

• Quoted data rates rarely reflect reality– They are symbol rates– They include packet overheads– They are relevant at short range in a lab environment

• The wireless industry loves “go-faster stripes”. Real applications rarely need high data rates. Don’t be sucked into the hype.

• Most M2M applications can only handle rates of around 115kbps at their interfaces. However, the data may travel over the air at a much higher rate, reducing the power consumption.

Page 19: Enabling the Internet of Things Short Range Wireless and M2M

Universal WirelessThe Wireless Development Platform

Tim Wheatley - VP Engineering

Page 20: Enabling the Internet of Things Short Range Wireless and M2M

What is Universal Wireless?

Allows HOSTLESS application development

Sophisticated web server integration allows machines to have a web presence

Enables rapid application prototyping and demonstration

A complete wireless application development platform

Compatibility across Ezurio modules

Not just a wireless module!

Page 21: Enabling the Internet of Things Short Range Wireless and M2M

Universal WirelessIn Action

Page 22: Enabling the Internet of Things Short Range Wireless and M2M

Basic Use of the Module

• The WISM Development Platform• The WISM file system• Immediate mode commands

– at i 3– at+dir– at+del– at+run– Using the !function_name() syntax– !_flashdel()

• Using the UWTerminal Application– Downloading new scripts– Downloading web pages

Page 23: Enabling the Internet of Things Short Range Wireless and M2M

OBD - Basic Operation

Vehicle Simulator

OBD – Serial Converter

OBD Cable RS232

Physical COM Port

Page 24: Enabling the Internet of Things Short Range Wireless and M2M

OBD - Cable Replacement

Vehicle Simulator

OBD – Serial Converter

OBD Cable

WISMTCP/IP

Virtual COM Port

Page 25: Enabling the Internet of Things Short Range Wireless and M2M

Wireless OBD Interface

Cable replacement…….

Application complete!WLAN Module programmed to automatically attach to AP and PC and transfer data

Uses a commercial OBD scan tool (Gendan) with unmodified Gendan EngineCheck firmware

No additional microcontroller is needed to manage the application – UW does it all.

Based on examples, the complete application takes only a few hours to complete!

Page 26: Enabling the Internet of Things Short Range Wireless and M2M

OBD – Intelligent Cable Replacement

Vehicle Simulator

OBD – Serial Converter

OBD Cable

WISMTCP/IP

Page 27: Enabling the Internet of Things Short Range Wireless and M2M

Wireless OBD Interface

Intelligent cable replacement……

Application complete!WLAN Module retrieves the data from the machine, processes it and only reports key information

WISM module actively participates in the data gathering and display

No additional microcontroller is needed to manage the application – UW does it all.

Based on examples, the complete application takes only a few hours to complete!

Page 28: Enabling the Internet of Things Short Range Wireless and M2M

SMTP Client Interface

Implementation of a protocol in UWScript

Also shows the use of a custom command interface

WLAN module is programmed with comms related applications to remove the load from the host processor

Demonstrates the ability of the module to act as a ‘communication co-processor’

Command interface is tailored to the application – high and low level functions

Module could be made to emulate legacy solutions

Page 29: Enabling the Internet of Things Short Range Wireless and M2M

Powersaving

• Powersave Mode 0– No power saving enabled

• Powersave Mode 1– IEEE powersaving enabled

• Powersave Mode 5– WLAN disabled, CPU active

• Powersave Mode 6– WLAN disabled, CPU sleeping

Page 30: Enabling the Internet of Things Short Range Wireless and M2M

Firmware Upload

• Uploading firmware is managed by the UWLoad.exe executable.

• UWLoad.exe executable and sectormap.ini file must exist in same directory

• Set up correct port number for UWLoad (using command line parameter com=n)

• Reset the module when prompted.• Select the firmware file to load.• Firmware update will happen automatically.

Page 31: Enabling the Internet of Things Short Range Wireless and M2M

Firmware Upload Tutorial

• Unzip the firmware and UWLoad tool from the UW_rash_2 0 1 1_Full_Delivery.zip and UWLoad.zip file respectively.

• Setup a shortcut to the UWLoad.exe file. Right click on the shortcut and set the command line parameter com=n from the ‘properties’.

• Run UWLoad.exe• Select ‘Load’• Reset the module• Select the UW_rash_2.0.1.1.s file• Firmware upgrade should complete automatically.

Page 32: Enabling the Internet of Things Short Range Wireless and M2M

The Internet Protocols

Page 33: Enabling the Internet of Things Short Range Wireless and M2M

The Internet Protocol Family

ARPHardware

DriverRARP

ICMP IP IGMP

TCP UDP

UserApplication

UserApplication DHCP

UserApplication

UserApplication

Transport

Network

Link

Application

Page 34: Enabling the Internet of Things Short Range Wireless and M2M

FTP Client

TCP

IP

EthernetDriver

EthernetDriver

IP

TCP

FTP Server

FTP Protocol

TCP Protocol

IP Protocol

Ethernet Protocol

Peer to Peer Protocols

Page 35: Enabling the Internet of Things Short Range Wireless and M2M

Routers

FTP Client

TCP

IP

WLAN Driver

EthernetDriver

IP

TCP

FTP Server

FTP Protocol

TCP Protocol

IP Protocol

WLAN Protocol

IP

Ethernet Driver

WLAN Driver

Ethernet Protocol

Wireless Medium Ethernet

IP Protocol

Page 36: Enabling the Internet of Things Short Range Wireless and M2M

Internet Addressing

• Each node on the network has an IP address– E.g 192.168.1.1, 213.246.148.49

• Statically or dynamically allocated (DHCP)• IP packets contain source address and destination

address.– Destination addresses ensure that packets reach the final

destination– Source address ensure that responses reach the originator

• IP addresses can change many times as a packet passes across the network– This is transparent to the user!

Page 37: Enabling the Internet of Things Short Range Wireless and M2M

Physical Addressing

• Each physical device on the network has a hardware address (MAC address)

• The MAC address is used either by the hardware interface or by the driver to identify ‘interesting’ packets

• Interesting packets are passed up the stack for further processing.

• Packets are addressed by both physical and IP addresses.

• Mapping between physical / IP addresses is handled by ARP protocol.

Page 38: Enabling the Internet of Things Short Range Wireless and M2M

Ports

• Many applications can be implemented that use the underlying TCP/IP stack structure.

• Applications are identified by port numbers• There are many pre-allocated port numbers for well

known applications – 80 – HTTP– 21 – FTP– 25 – SMTP

• ‘User’ port numbers can lie in the range 1024 – 65535

Page 39: Enabling the Internet of Things Short Range Wireless and M2M

Data Encapsulation

FTP Client

TCP

IP

EthernetDriver

User Data Packet

User Data Packet

User Data Packet

User Data Packet

TCP Header

TCP Header

TCP Header

IP Header

IP HeaderEthernet Header

Ethernet Tail

Port numbers, sequence number, CRC

IP addresses, TOS, Protocol etc

MAC addresses CRC

Page 40: Enabling the Internet of Things Short Range Wireless and M2M

Internet Protocol (IP)

• Deals with delivery of a payload to the destination• Supplies source and destination addresses• Specifies type of service – which defines how the packet

is routed• Packet delivery is not guaranteed• Works packet by packet – no concept of a connection• Packet ordering is not guaranteed• Higher layer protocols must deal with this…..

Page 41: Enabling the Internet of Things Short Range Wireless and M2M

Transmission Control Protocol (TCP)

• Provides – Reliable stream delivery of ordered data

– Virtual circuit connections

– Full duplex connections

• A connection is defined by a pair of end points – An endpoint is a (host, port) pair

– eg 145.23.4.3., 1876154.23.5.6, 345

• Connection establishment is by three way handshake• Connection terminates by a modified three way handshake

– Asymmetric release

– Symmetric release

Page 42: Enabling the Internet of Things Short Range Wireless and M2M

Address Resolution Protocol

• IP address must map onto physical address• Host must somehow discover the physical address of

a target host on the same network given the target’s IP address

• ARP– Host broadcast ARP request containing target IP address – Target responds with ARP reply containing physical address

• Machines cache IP to physical address bindings– Broadcast is expensive – A cache prevents frequent broadcast– Entries must be removed after a fixed time to enable

replacement of hardware

Page 43: Enabling the Internet of Things Short Range Wireless and M2M

Dynamic Host Configuration Protocol (DHCP)

• Main application of DHCP is distribution of IP addresses• Used by the module to request and obtain a dynamic IP

address from the router (access point). • Also used to provide gateway mask, gateway IP address

and primary and secondary DNS IP addresses.• Typically runs immediately after physical connection is

established with the router (i.e after attaching to the AP).

Page 44: Enabling the Internet of Things Short Range Wireless and M2M

An Overview of Sockets

Page 45: Enabling the Internet of Things Short Range Wireless and M2M

Client Server Model

• TCP/IP networking operates on a client server model.• One end operates as a server

– Offers a service to clients– Example is a web server

• One or more clients makes contact with the server and uses the service.

Page 46: Enabling the Internet of Things Short Range Wireless and M2M

Sockets (1)

• A socket is used to establish a data connection between two devices.

• Uses the client / server model• Analagous to making a telephone call to a business

– Client calls the switchboard number for the business

– Switchboard operator answers the call

– Call is put through to an extension for the call to be handled

– Switchboard returns to listening out for more clients to call in.

• The ‘telephone number’ of the server is the IP address and the port number– 192.168.1.1:1056

• Typically the server will hand the connection to another port for the remainder of the call

Page 47: Enabling the Internet of Things Short Range Wireless and M2M

Sockets (2)

Port 12567

Port 12568

Port 12569

Port 12570

Port 12571

Port 1342ServerIP Address: 213.246.148.49

Client 1

Page 48: Enabling the Internet of Things Short Range Wireless and M2M

Sockets (3)

Port 12567

Port 12568

Port 12569

Port 12570

Port 12571

Port 1342ServerIP Address: 213.246.148.49

Client 2

Client 1

Page 49: Enabling the Internet of Things Short Range Wireless and M2M

Sockets (4)

• Stages in creating socket:– Server:

• Create socket

• Bind socket to the listening port number

• Listen on the socket

• Accept incoming connections from clients

– Client:• Create socket

• Connect socket to server

Page 50: Enabling the Internet of Things Short Range Wireless and M2M

Universal WirelessBasics and Concepts

Page 51: Enabling the Internet of Things Short Range Wireless and M2M

UW WISM – Software Architecture

WiFi Driver Layer

WiFi Firmware

TCP/IP StackWiFi Control

Interface

WiFi Driver Abstraction

Layer

HTTP Server TAR (Tokeniser Abstraction Routines)

Flash File SystemTokeniser /

Interpreter

Page 52: Enabling the Internet of Things Short Range Wireless and M2M

Interactive Mode

When the module is not running a script

Simple AT commands allow file manipulation

UW commands can be run in interactive mode

at+dir: display filesat+run: run named scriptat i n: display version informationat+cmp: Start / end script compilationat+del: delete named script

Page 53: Enabling the Internet of Things Short Range Wireless and M2M

UW Language Basics

UW is a basic-like programming language

Scripts are simple text files

UwTerminal application is provided toSimplify the development process

autorun script – if present is run automatically on power on

Factory default script – installed at the factory, runs on power on – cannot be changed.

Page 54: Enabling the Internet of Things Short Range Wireless and M2M

Universal WirelessLanguage Overview

Tim Wheatley - VP Engineering

Page 55: Enabling the Internet of Things Short Range Wireless and M2M

UW Concepts - Streams

• Manage the flow of data around the module• Data devices act as data source / sinks

– E.g UART, UW script, TCP socket

• Bridge connects data source with a data sink and vice-versa

• Currently bridges are always 2-way i.e both data source and data sink are connected

• Provides flexibility for future expansion– Other data devices could be created – CAN bus, files, ADC for

example

Page 56: Enabling the Internet of Things Short Range Wireless and M2M

UW Concepts - Streams

UART

UW Script

Socket

Data Device 1

Data Device 2

STDIN

STDOUT

Page 57: Enabling the Internet of Things Short Range Wireless and M2M

UW Concepts - Streams

• By default a UW script creates one data device– stdout: All output created by print is sent to stdout– stdin: Input to the script is read from stdin

• After reset, stdin and stdout are bridged to the UART data device.

Page 58: Enabling the Internet of Things Short Range Wireless and M2M

UW Concepts – Events (1)

• Events are asynchronous inputs to a UWScript• Avoid the need for polling in scripts

– Waitevent – tests in an ‘infinite loop’ or until an event handler returns 0

– pollevent

• When an event occurs a pre-installed handler is called– onevent evstdin call stdin_handler

Page 59: Enabling the Internet of Things Short Range Wireless and M2M

UW Concepts – Events (2)

• Supported events are:– EVSTDIN : Data has arrived on stdin– EVRXBRKON : Break condition on UART detected– EVRXBRKOFF : Break condition on UART released– EVWEB : Web server has generated

event– EVSEARCH : Access point search is complete– EVSOCKETCLOSE : Socket has been closed– EVLINK : Change in WLAN link status

Page 60: Enabling the Internet of Things Short Range Wireless and M2M

UW Concepts – Events (3)

• Examples of event use:– Detecting a break condition on the UART to interrupt a data

connection. – Detecting a change in the WLAN link status (loss of connection

for example) and taking appropriate remedial action.– Detecting a socket being closed by the remote end allowing a

clean socket close at the module.

Page 61: Enabling the Internet of Things Short Range Wireless and M2M

UW Concepts – Web Server (1)

• WISM web server is fully integrated with UW scripts• Allows a UW script to generate dynamic web content

– <?UW“keyword(param)"?>– Anything in quotes is passed to the script as part of a EVWEB

event– Script writes HTML strings that are dynamically inserted into the

web page using webecho command

Page 62: Enabling the Internet of Things Short Range Wireless and M2M

UW Concepts – Web Server (2)

• Forms posted from the web browser are passed to the script for processing– Allows the user to interact with the script – Forms are passed as a list of parameter / values– Script interprets parameter and acts on the basis of value

Page 63: Enabling the Internet of Things Short Range Wireless and M2M

Tutorial 2 – Cable Replacement

• Navigate to Tutorials directory• Download script file ‘tutorial_2.uws’• This script establishes a TCP server on port number

1000• Run the script• Wait until the IP address for the module is reported• Open another UWTerminal session• Select the TCP Socket option• Enter the IP address of the module and the port number• Verify that the connection is made and that characters

can be transferred.

Page 64: Enabling the Internet of Things Short Range Wireless and M2M

Variable Declaration

Types are:uword, sword

ulong, slongstring

Declaration syntax:uword uwValue1slong slReturnstring stIpString

Variable declarations can be anywhere in a script – but variables must be declared before use

Page 65: Enabling the Internet of Things Short Range Wireless and M2M

Variable Scope

Global: variables are declared in the main body of the script

Local: Variables are declared in a subroutine or function

Super Global Variables: Declared outside the script and last all the time the module is on.

Page 66: Enabling the Internet of Things Short Range Wireless and M2M

Variable Casting

Sometimes a variable of one type needs to be made into another type

e.g. if a routine returns a variable of one type which is then used as a parameter for another.

xxCASTyy() – converts a variable of type yy to type xx e.g uwVar = uwCASTsl(slVar) converts a signed long into a unsigned integer

Page 67: Enabling the Internet of Things Short Range Wireless and M2M

Expressions

  *     Multiply       /     Divide       %   Modulus       +    Addition       -     Subtraction       <<  Arithmetic Shift Left       >>  Arithmetic Shift Right       <    Less Than       <=  Less Than Or Equal       >    Greater Than       >=  Greater Than Or Equal      ==  Equal To       !=   Not Equal To       &    Bitwise AND       ^     Bitwise XOR (exclusive OR)       |      Bitwise OR       &&  Logical AND       ^^    Logical XOR       ||     Logical OR 

Page 68: Enabling the Internet of Things Short Range Wireless and M2M

Looping

for i = 1 TO 50 statements….next

i = 0while (i < 50) statements….. i = i + 1endwhile

Page 69: Enabling the Internet of Things Short Range Wireless and M2M

Conditional Execution

if expression then statements……elseif expression then statementselse statementsendif

select varnamecase n statements….case m statements….case else statements….endselect

Page 70: Enabling the Internet of Things Short Range Wireless and M2M

Output from a Script

Print – outputs characters to the stdout stream

Prints variables separated by ‘;’ e.g. print uwVal; slVal2; val3 print “This is a string”; uwVal; “\n”

print stVariable

Page 71: Enabling the Internet of Things Short Range Wireless and M2M

Subroutines

subroutine name(var1, var2….varn) statementsendsub

Variables passed by referenceor by valuee.g testsub(uword byref par1) testsub(uword byval par2)Default is by value…..

Page 72: Enabling the Internet of Things Short Range Wireless and M2M

Functions

function retvar name (var1, var2…varn) statementsendfunc var

Page 73: Enabling the Internet of Things Short Range Wireless and M2M

Events

onevent EVRXBRKON call brkhandlewaitevent – waits for eventspollevent – polls for events

Event handler return code:0 – waitevent is terminated, script moves on to next instructionnon 0 – continue waiting for events

Page 74: Enabling the Internet of Things Short Range Wireless and M2M

Tutorial Number 3

• Open tutorial_3.uws file in notepad• This simple script file prints a single line ‘Hello World”• Modify the script to print Hello World 10 times –

download and test• Modify the script to print Hello World and the number of

times it has been printed– Hello World 2– Hello World 3– Etc

Page 75: Enabling the Internet of Things Short Range Wireless and M2M

Tutorial Number 4

• Open tutorial_4.uws• This script waits for an RX break event• Modify the RX break event handler to print ‘RX break

ON’• Modify the script to monitor the RX break OFF event and

add a handler to print ‘RX break OFF’• How can the script be modified to exit when the RX

break OFF condition is detected?• Modify the script to count the number of RX break ON

events and to exit after 10 events have been detected.

Page 76: Enabling the Internet of Things Short Range Wireless and M2M

String Manipulation Functions

A rich set of string manipulationfunctions is provided – here aresome of the key ones…..

left$, right$, mid$strcmpstrposstrroleftstrvaldec

Page 77: Enabling the Internet of Things Short Range Wireless and M2M

Handling STDIN

When data arrives on STDINan event is generated – EVSTDIN Event handler reads data fromstream and typically looks for end of line

EVSTDIN is generated whencharacters are transferred fromUART to STDIN stream –may be one or more……

Page 78: Enabling the Internet of Things Short Range Wireless and M2M

String Matching

It is often useful to match astring against a number ofalternatives

e.g command look up

TableInit: sets up tableTableAdd: Adds entry in tableTableLookup: Looks up a string in the table and returns associated value

Page 79: Enabling the Internet of Things Short Range Wireless and M2M

Tutorial Number 5

• Open tutorial_5.uws• This script implements a simple command line interface

for the module.• Experiment with the commands that it provides.• Add a new command ‘search’ which performs a WLAN

search and prints the results– Hint: the _wlansearchdump() built in function does a search and

prints the results

• Make this an ‘autorun’ script and verify that the command line interface works from power on

Page 80: Enabling the Internet of Things Short Range Wireless and M2M

Universal WirelessWireless LAN Extensions

Page 81: Enabling the Internet of Things Short Range Wireless and M2M

WLAN Searching

_wlansearchnet() – Searches for access points and populates table with results:

Following functions allow table to be scanned:_wlansearchfor()_wlansearchquery()_wlansearchquery$()

AP Name MAC Add Type Frequency Security RSSI

AP_1 2714 Infra 2412000000 OFF 195

AP_2 3245 Infra 2437000000 ON 207

AP_3 13567 ad-hoc 2467000000 OFF 163

Page 82: Enabling the Internet of Things Short Range Wireless and M2M

WLAN Management

_wlanxxx() Functions:Connection:

_wlanattach()_wlandetach()

Security: _wlansecurity() _wlankey() _wlanauth()Regionalisation: _wlanregionset() _wlanregionget()

Page 83: Enabling the Internet of Things Short Range Wireless and M2M

Tutorial 6

• Script_Demo10 searches for all access points and then looks for a named access point in the results.

• If the AP is present then it connects and waits to get an IP address.

• Modify this script to search for and attach to the “Uplands Broadband” access point.

• Once this works – modify the script to search for all “Uplands Boardband” access points and then attach to the one with the largest RSSI value. – Hint – the _wlansearchquery(n, 3) returns the RSSI value for the

nth AP that has been found

Page 84: Enabling the Internet of Things Short Range Wireless and M2M

WLAN Ad-Hoc Networks (1)

Ad-hoc WLAN networks allow modules to communicate without using an access point.

First module to join an ad-hoc network will create it

Subsequent modules connect as if they are joining an access point

Channel must be selected – take care of the regionalisation!

Power-saving does not work in an ad-hoc network

Page 85: Enabling the Internet of Things Short Range Wireless and M2M

WLAN Ad-Hoc Networks (2)

Page 86: Enabling the Internet of Things Short Range Wireless and M2M

WLAN Power Management (1)

IEEE Power saving – AP allows the terminal to sleep when no dataIs transferred.

Terminal wakes on a regular basis to check if data has arrived or to send data

AP stores data to be sent to the terminal until the terminal wakes up.

If there is no data to be transferred then the terminal wakes for a veryshort time allowing significant reduction in average power.

This is an AP managed power saving mode – not available in ad-hoc

Page 87: Enabling the Internet of Things Short Range Wireless and M2M

WLAN Power Management (2)

_psmodeset(0) – No power saving – module is awake all the time (~210mA)

_psmodeset(1) – WLAN chipset uses IEEE powersaving – must be attached (~45mA).

_psmodeset(5) – WLAN chipset disabled – enables low power when module is not attached (~30mA).

_psmodeset(6) – WLAN chipset disabled, MCU disabled. Module woken by user defined I/O pin(s) (~3mA).

Page 88: Enabling the Internet of Things Short Range Wireless and M2M

Universal WirelessSocket Extensions

Page 89: Enabling the Internet of Things Short Range Wireless and M2M

High Level Sockets

High level Interfaces: _socktcpserver() – sets up a server at the specified IP address and port

_socktcpclient() – connects to a server at specified IP address and port

Page 90: Enabling the Internet of Things Short Range Wireless and M2M

Bridging

Functions: _netio(), stdio() and uartio() are used to get stream handles unbridge() disconnects an existing bridge

bridge() bridges between two streams

Page 91: Enabling the Internet of Things Short Range Wireless and M2M

Low Level Sockets

A full set of socket API functions areprovided.

Allow finer control over sockets

A more complex interface

_socktcpcreate(), _sockudpcreate()_sockconnect(), _sockbind()_socklisten(), _sockaccept()_sockclose()

_socksendto(), _socksendall(), _sockrecv(), _sockrecvfrom()

Page 92: Enabling the Internet of Things Short Range Wireless and M2M

Universal WirelessWeb Server Extensions

Page 93: Enabling the Internet of Things Short Range Wireless and M2M

Dynamic Web Page Content

_webevget(): Gets the cause of the web event (either dynamic web content or post)

_webfname(): Returns the string from the <?UW”string”?> command embedded in the web page.

_webecho(): Outputs HTTP strings to the browser

_webevend(): Indicates that web processing is complete.

Page 94: Enabling the Internet of Things Short Range Wireless and M2M

Handling Web Posts

Typically a POST from a browser is a list of parameters and values:

_webgetnumpostel(): Returns the number of parameters that have been sent

_webgetelement(): Gets a parameter from the list

Page 95: Enabling the Internet of Things Short Range Wireless and M2M

Example Web Script

'// get the cause of the web event slRes = _webEvGet(evCause)

if ( evCause == 1 ) then '// get the name and argument list of the script/function for this event occuring slRes = _webFNameGet(tag) '// retrieve the name first findChar = "(" charPos = STRPOS( tag, findChar, 0 )

scriptname = LEFT$(tag, UWCASTSL(charPos)) '// then get the args - in this case there can be only one startPos = UWCASTSL(charPos) findChar = ")" charPos = STRPOS( tag, findChar, startPos ) arg1 = MID$( tag, startPos+1, (UWCASTSL(charPos) - startPos - 1) ) if mStrCompare(scriptName, "OBDGetData") == 0 then OBDGetData( UWCASTSL(STRVALDEC(arg1)) ) slRes = _WebEvEnd() exitfunc 1 elseif mStrCompare(scriptName, "ExitScript") == 0 then slRes = _WebEvEnd() exitfunc 0 endif elseif ( evCause == 2 ) then numElements = _webGetNumPostEl() result = _webGetElement(0, name, value) if mStrCompare(value, "ResetMIL") == 0 then

ResetMIL()endif

endif '// we have finished so end the web event slRes = _WebEvEnd()

This section deals with dynamiccontent

This section deals with postsFrom the browser

Page 96: Enabling the Internet of Things Short Range Wireless and M2M

Market LeaderWireless technology solutions

{End statement}