Bluetooth Low Energy – kostengünstig und

Transcrição

Bluetooth Low Energy – kostengünstig und
Bluetooth Low Energy – kostengünstig und
energieeffizient
Andreas Rüst
Dozent für angewandte Computertechnik
Zürcher Hochschule für angewandte Wissenschaften
Institute of Embedded Systems
8401 Winterthur
[email protected]
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
Institute of Embedded Systems – InES
•
•
•
•
FPGA-based systems for network
communication
Time synchronization and high
availability Networks
Real-Time-Ethernet, safe and
dependable Systems
Wireless Communication
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
2
InES – Wireless Communication
Solutions for Energy-Efficient and Autonomous Embedded Systems
• Energy harvesting
• Power management
• Low-power technologies
• Mesh network topologies
• RFID sensor networks (RSN)
• Standard and proprietary wireless protocols
• Wireless IP connectivity
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
3
Bluetooth Low Energy – BLE
•
Bluetooth SIG
– Special Interest Group
– www.bluetooth.org
•
Bluetooth Low Energy
– Seit 2009 Teil der Bluetooth Spezifikation
– BLUETOOTH SPECIFICATION Version 4.1
•
Bluetooth Smart
– Marketingbegriff für BLE
•
Bluetooth Smart Ready Device
– Dual Mode Stack
– kann so wohl mit Bluetooth Classic (BR/EDR) als auch mit BLE
Geräten kommunizieren
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
4
Inhalt
•
Übersicht und Funktion
– Was ist BLE?
– Geräterollen
– BLE Schichten und ihre Funktion
•
Umsetzung in der Praxis
– Peripherals
– Central Devices
– App-Entwicklung: Android / iOS / Windows
– Praktische Erfahrungen
– Zertifizierung
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
5
Was ist BLE?
•
Neue Technologie
– "blank sheet of paper design"
– Unterschiedlich zu Bluetooth Classic (BR/EDR)
– tiefere Datenraten
<< 230 kbit/s
– gleiche Antenne und RF Komponenten
•
Einfache Peripherals
– optimiert für ultra low power und low cost
– Betrieb mit Knopfzellen
– Spitzenstrom
< 10 - 20 mA
– 'Erholungszeit' für Batterie
•
~230 mAh
Central Devices
– mehr Speicherplatz
– höhere Energieressourcen
central
peripheral
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
6
Was ist BLE? – Konzepte
•
Kurze Pakete
– kleine Pufferspeicher
– einfachere TX Kalibration; RX nur kurz einschalten
•
Verbindungslose Kommunikation möglich
•
Verbindungen
– schneller Aufbau und Abbau
– keine Verbindungen auf Vorrat
– einfache Sterntopologie
client
server
wants data
has data
•
Einfaches Client – Server Protokoll
– zustandslos
•
Einfache, atomare Services
– Baublöcke für aufwendigere Anwendungen
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
7
Geräterollen: Broadcaster – Observer
•
Einfacher, verbindungsloser Betrieb
– Beacons
– Broadcaster sendet (Advertising)
– Observer als Empfänger
– eingeschränkter Rückkanal möglich
O
B
O
B
B
O
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
8
Geräterollen: Peripheral – Central
Verbindungsorientierte Anwendungen
•
Peripheral
– einzelne Verbindung
– Slave
– i.d.R. Server  stellt Daten zur Verfügung
– Beispiel Datenlogger
•
Central
– mehrere gleichzeitige
Verbindungen
– Sterntopologie
– Master
– i.d.R. Client
P
C
P
P
P
source: MSR / Colourbox
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
9
BLE Schichten
•
Controller und Host
– HCI Standardisierte Schnittstelle zwischen den Stack-Teilen
Application
OS specific API
GAP – Generic Access Profile
GATT – Generic Attribute Profile
Host
Attribute Protocol
Security Manager
L2CAP – Logical Link Control
Host Controller
Interface (HCI)
Link Layer
Controller
Physical Layer
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
10
BLE Schichten – Physical Layer
•
•
•
•
•
Lizenzfreies 2.4 GHz ISM Band - Industrial Scientific Medical
GFSK Modulation mit Frequency Hopping
3 Advertising Kanäle und 37 Data Kanäle
Nominale Bitrate von 1 Mbit/s
Output Power von 0.01 mW (-20 dBm) bis 10 mW (10 dBm)
source: Bluetooth SIG
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
11
BLE Schichten – Link Layer
•
Device Discovery und Verbindungsaufbau
– Slave sendet periodische
Advertisement Pakete
– Master scannt Kanäle
– Master sendet Connection Request
mit Verbindungsparametern
– Master beginnt Verbindung
M
connection request
connected
S
Zeiten sind Beispiele
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
S
S
connectable,
bondable?
available services
source: Nordic
12
BLE Schichten – Link Layer
•
•
Connection Event
– Alternierende Pakete Master – Slave und Slave – Master
– Anzahl Pakete variabel
– Pakete max. 31 Octets plus 10 Octets overhead
Connection Interval
– zwischen 7.5 ms und 4 s
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
source: Bluetooth SIG
13
BLE Schichten – L2CAP
Logical Link Control and Adaptation Protocol
•
Protokoll Multiplexer
– Segmentation und Reassembly von Paketen
– von Bluetooth Classic übernommen
•
BLE Protokolle
– Attribute Protocol (ATT)
– LE L2CAP Signaling Protocol
– Security Manager Protocol
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
14
BLE Schichten – Security Manager
•
AES-128 Encryption Engine
•
Pairing
– Authentication mit temporären Schlüsseln
• Just Works
• Passkey Entry
6-stellige Zahl
• Out Of Band
z.B. NFC1)
– Generierung und Austausch von Schlüsseln
•
Nutzung der Schlüssel für
• Authorization
• Integrity
• Confidentiality
• Privacy
•
Zugang zu gewissen Attributen
Nachricht nicht modifiziert
Abhörsicherheit
Anonymität der Geräte
Bonding
– Speichert Schlüssel und zugehörige Identität für späteren Gebrauch
1) Near
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
Field Communication
15
BLE Schichten – Attribute Protocol (ATT)
•
Server stellt seine Daten über Attribute zur Verfügung
Client
write
Server
read
Handle
Type
Value
0x0108 Battery Level
53 %
0x0117
Tx Power
-8 dBm
0x0136 Device Name "My Sensor"
0x013A
My Value
117
find
notify / indicate
•
Attribute Protocol
– Einfach und zustandslos
– Gewisse Anfragen erfordern Antwort oder Bestätigung
– Auf andere Anfragen erfolgt keine Antwort oder Bestätigung
– Eine Anfrage aufs Mal
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
16
BLE Schichten – Attribute Protocol (ATT)
•
Attribute
– Handle
– Type
– Value
eindeutige ID/Adresse des Attributes
codiert als 16-bit UUID1)
Wert des Attributes
Server
0 – 512 Bytes lang
• Attribute Access Permissions
– readable
– writeable
– readable & writeable
Handle Type (UUID)
Value
0x0108 Battery Level
53 %
0x0117
Tx Power
-8 dBm
0x0136 Device Name "My Sensor"
0x013A
My Value
117
• Zugriff auf Attribute Values kann zusätzliche Rechte erfordern
– Authentication
– Authorization
– Encryption / pairing
1)
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
Universally Unique Identifier bezogen auf 128-bit Bluetooth Base UUID
17
BLE Schichten – GATT
Generic Attribute Profile
Profile
•
Strukturiert Menge der Attribute auf Server
– Hierarchischer Aufbau
•
Definiert Prozeduren für Zugriff durch Client
– z.B. Discovery: Was bietet der Server an?
Service A
Characteristic
(properties)
Value
Descriptor
…
•
Characteristic
– Value mit optionalen Descriptors (z.B. Einheit)
•
Service
– Gruppe verschiedener Characteristics
– Erfüllt atomare Basisfunktionalität
Beispiel 'Current Time Service'
•
Characteristic
(properties)
Value
Descriptor
Service B
Profile
– umfasst einen oder mehrere Services
– realisiert einen 'use case'
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
Service C
18
BLE Schichten – GATT Services
•
Bluetooth SIG Standard Services (Auswahl)
– Jeder Service enthält Characteristics
– 'Assigned Numbers' ab 0x1800
– Eigene Services können definiert werden
Alert
Notification
Service
Current Time
Service
Battery Service
Heart Rate
Device
Information
Blood Pressure
Generic Access
(GAP)
Bond
Management
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
Generic
Attribute
(GATT)
Tx Power
Device
Link Loss
Information
Service
Device
Information
Immediate Alert
Service
Scan
Parameters
19
BLE Schichten – GATT Profile
•
Mehrere Services bilden ein Profile
– Beispiel Proximity Profile
•
GATT Discovery
– Client stellt fest, welche Services/Characteristics Server anbietet
GATT Client
GATT Server
GATT
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
20
BLE Schichten – GATT Profile
•
Beispiele von Standard Profilen
– Liste wird laufend erweitert
– Eigene Profile können erstellt werden
Alert
Notification
Profile
Health
Thermometer
Profile
My own
Profile 1
Proximity
Profile
My own
Profile 2
Heart Rate
Profile
Find Me
Profile
Time Profile
Phone Alert
Status Profile
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
Health
Thermometer
Profile
21
BLE Schichten – GAP Generic Access Profile
GAP definiert die schichtübergreifende Grundfunktionalität aller
Bluetooth Geräte
•
Rollen und zugehörige Prozeduren
– Central – Peripheral
– Observer – Broadcaster
•
Discovery
– Prozeduren für das Auffinden von BLE Geräten
•
Verbindungsarten
– Prozeduren für Auf- und Abbau
•
Sicherheit
– Prozeduren für Bonding
•
GAP Service
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
22
BLE Schichten – GATT Generic Attribute
Profile
•
Beispiel 'Attributes of Peripheral My_BLE_dev'
– Battery Level 53 %
Handle
0x0001
0x0002
0x0003
0x0004
0x0005
0x0006
0x0007
0x0008
0x0009
0x000A
0x000B
0x000C
0x000D
UUID
0x2800
0x2803
0x2A00
0x2803
0x2A01
0x2803
0x2A04
0x2800
0x2800
0x2803
0x2A19
0x2904
0x2902
Value
GATT Primary Service Declaration 0x1800
GATT Characteristic Declaration
…
Device Name
My_BLE_dev
GATT Characteristic Declaration
…
Appearance
Generic Tag
GATT Characteristic Declaration
…
Preferred Connection Parameters …
GATT Primary Service Declaration 0x1801
GATT Primary Service Declaration 0x180F
GATT Characteristic Declaration
…
Battery Level
53
Characteristic Presentation Format uint8, percentage
Client Characteristic Configuration notification enabled
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
GAP
service
0x1800
GATT
service
0x1801
Battery
service
0x180F
23
Peripherals – Chips
•
Beispiele von Evaluationsboards
– Chips 1.50 – 2.00 USD @ 1000 Stück
TI Keyfob
ST BlueNRG
Nordic PCA10001
source: Texas Instruments
Dialog
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
EM Microelectronic
24
Peripherals – Module
•
Zertifizierte Module mit BLE Stack und GATT-basierten Profilen
•
Beispiel Bluegiga
– eigene Applikation auf Modul möglich
• SDK oder Script Sprache
– API über UART
– Definition eigener Profile
– Master und Slave Mode
•
Beispiel Stollmann
– vorgegebene Profile
– mit AT Kommandos steuerbar
– Punkt-zu-Punkt als Kabelersatz
– 15 Euro Einzelpreis
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
25
Central Devices – Smart Phones
•
Verbreitung in Smart Phones ist ein entscheidender Vorteil für BLE
– Gleiche RF Komponenten wie Bluetooth Classic
Tablets / Smart Phones
iOS 7.0.4
z.B. Apple iPad 3
Android 4.4 KitKat, z.B.
Nexus 7, generation 2013
source: geek4share.com
Objective-C
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
Windows 8 / 8.1
source: http://www.cultofandroid.com
Java
C++, C#, VB, JavaScript
26
Central Devices – Dongles
•
HW-Module mit BLE Stack
– BLE Controller / BLE Host
•
Applikation auf Desktop-PC,
Laptop, Embedded PC, etc.
•
API über Virtual COM Port
•
Konfigurationen und Profile
auf Dongle speicherbar
•
Diverse Anbieter
~20 CHF / Einzelpreis
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
Dongles
TI dongle CC2540
Bluegiga dongle
BLED112
Virtual COM Port
Host application development with API
27
App-Entwicklung
•
Beispielapplikationen für alle Betriebssysteme
– Application Accelerator (Bluetooth SIG)
https://developer.bluetooth.org/Pages/bluetooth-smartdevelopers.aspx
– Registration notwendig
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
28
App-Entwicklung – Android
•
Google Play Developer
– einmalig 25 $
– SDK
• Eclipse IDE (BETA Android Studio based on IntelliJ IDEA)
• Android Virtual Device (Simulator für Nexus Geräte)
• Android SDK Manager
– Test Environment
– Distribution über Play Store
•
Android 4.4
– Central und Observer werden unterstützt
– Keine Unterstützung für Peripheral / Broadcaster  Android 5
Beispiele BLE Methoden
mBluetoothAdapter = bluetoothManager.getAdapter();
mBluetoothAdapter.startLeScan(mLeScanCallback);
mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
29
App-Entwicklung – Android
•
Android Developers
– https://developer.android.com/guide/topics/connectivity/bluetooth-le.html
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
30
App-Entwicklung – iOS
•
iOS Developer Program
– 99 USD / Jahr
– SDK
• Xcode Development Environment
• iOS Simulator
• iOS Developer Library
–
–
–
–
•
Test Environment
Distribution über App Store
Erfordert Apple MAC
Tutorials von Apple
iOS 7
– unterstützt Central/Peripheral sowie Observer/Broadcaster
Beispiele BLE Methoden
scanForPeripheralsWithServices:options:
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
31
iOS – Reference Documents
•
iOS Developer Library
– https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/C
onceptual/CoreBluetooth_concepts/AboutCoreBluetooth/Introduction.html
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
32
App-Entwicklung – Windows
•
Windows
– IDE: Visual Studio 2013 (Windows 8.1)
– C++, C#, VB, JavaScript
– Windows (Phone) Store, Developer Account 90 CHF (Firma)
•
Windows 8.1 / Windows RT 8.1 / Windows Phone 8.1
– Keine APIs für BLE Device Discovery und Pairing
• Muss vorgängig über OS Settings erfolgen
– Nur Central Role (GATT Client)
•
Windows Dev Center
– http://msdn.microsoft.com/enus/library/windows/hardware/jj159880%28v=vs.85%29.aspx
•
Windows 10 ??
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
33
Praktische Erfahrungen – Entwicklungshilfe
•
Sniffer
– Aufzeichnen aller Protokollbits einer Verbindung
– z.B. mit 'CC2540 USB Dongle' von Texas Instruments
und zugehöriger PC Software
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
34
Praktische Erfahrungen – Erreichbare
Datenraten
•
•
•
•
Nominal 1 Mbit/s
– Protokoll erlaubt bis zu 230 kbit/s Payload
N: Anzahl gleichzeitiger
Verbindungen
Von Evaboard zu Evaboard
– bis 180 kbit/s gemessen
Nexus 7
Android
Android
– kurze CI möglich
– Peak @ 60 kbit/s
– ungleiche Datenraten
Beispiel N = 5
Connection
Interval
(CI) [ms]
iOS
– erlaubt keine kurzen CI
– Peak @ 30 kbit/s
– Peak gleichzeitig auf bis zu
5 Verbindungen erreichbar
erreichte
Datenrate
Peripheral
zu Central
[kbit/s]
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
iPad3
iOS
N=1
N=5
N=1
N=5
7.5
12.5
37.5
37.5
59.2
61.4
29.8
29.6
−
13.0
29.6
−
11.8
29.7
−
11.1
29.4
−
12.0
29.6
Messungen mit TI Keyfobs
35
Praktische Erfahrungen – Energieverbrauch
•
Beispiel
 Erreichbarkeit kostet viel Energie
– Advertising pro Intervall
20 nWh
auf 3 Kanälen
– 400 Byte Daten (P -> C)
360 nWh
mit Discovery
– CRC2032  225 mAh @ 3V = 675 mWh entspricht
• 400 Tage Advertising bei 1s Intervall oder
• 2 Millionen Mal Daten übertragen
GATT Discovery
Data (notification)
Leistung Peripheral
Advertising
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
36
Zertifizierung
Regionale Regulatorische Anforderungen
•
•
Funk
– Europa (CE) EN 300 328
Data transmission equipment operating
in the 2,4 GHz ISM band and using
wide band modulation techniques
EMV
– Europa (CE) EN 301 489-1&17 ElectroMagnetic Compatibility (EMC)
standard for radio equipment and
services
•
Diverse andere Funk und EMV Standards für
– USA, Kanada, Japan, South Korea, Australien, China
•
Plus Sicherheitsanforderungen
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
37
Zertifizierung
•
Bluetooth SIG Qualifikation
– Basierend auf Referenzdesign und Profile eines Herstellers
source: http://processors.wiki.ti.com/index.php/How_to_Certify_your_Bluetooth_product
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
38
Zertifizierung
Bluetooth SIG Qualifikation
– erlaubt Tragen des Bluetooth Logos
•
Bedingung Firmenmitgliedschaft bei Bluetooth SIG
– Adopter
• Gebührenfrei
• erlaubt Registrierung einzelner Mitarbeiter
• Zugang zu technischen Infos
– Associate
• 7'500 USD bis 100 M USD Firmenumsatz
•
•
Listing Fee (Declaration ID)
– 8'000 USD Adopter
– 4'000 USD Associate
– 2'500 USD für Umsätze kleiner als 1M USD
Qualification and Listing Process
–
https://www.bluetooth.org/en-us/test-qualification/qualification-overview/listingprocess-updates
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
39
Schlussfolgerung – BLE
•
Verbindungslos
– Broadcaster - Observer
•
Verbindung (Sterntopologie)
– Central - Peripheral
•
Peripherals / Broadcaster
– ultra low power und low cost
central
peripheral
•
Central / Observer
– mehr Speicher und Energie; Riesige Verbreitung in Smart Phones
•
Einfaches Client – Server Protokoll
– zustandslos
•
Einfache, atomare Services
– Baublöcke für aufwendigere Anwendungen (Profiles)
Bluetooth Low Energy | Andreas Rüst | 18.11.2014 | © Electrosuisse
40

Documentos relacionados