1 Warsztaty praktyczne 27.04.2016-12:00-16:00 Dla aktywnych uczestników zestawy uruchomieniowe nrf52 DK. Uwaga: Ilość miejsc ograniczona. Napiszcie nam o swich zainteresowaniach i w jaki sposob organizowane warsztaty mogą być dla Was przydatne. Nie zapomnijcie wspomnieć o dotychczasowych doświadczeniach z programowaniem systemów wbudowanych oraz technologii BLE i NFC. W trakcie warsztatów będziecie potrzebowali: - własnego laptopa zdolnego do uruchomienia środowiska KEIL5. - smartfona z obsługą BLE i NFC (dla przykładow z NFC zalecany Windows lub Android).
Michał Grochala nrf52 Bluetooth low energy and NFC - introduction
3 Agenda What is Bluetooth Smart? BLE architecture BLE Link Layer Attribute Protocol Generic Attribute Profile BLE pairing What is NFC? Operating modes Device Types NDEF NFC use cases BLE pairing over NFC
4 Why Bluetooth Smart? (repetition) It s Low Power!!! Compared to WiFi, GSM/LTE, Standard Bluetooth Comparable with IEEE 802.15.4 (Zigbee, Thread), ANT It s supported by smartphones, tablets, PCs!!! Unlike IEEE802.15.4, ANT* Like WiFi, GSM/LTE, Standard Bluetooth It s cheap!!! development BOM (Bill of Materials) It s interoperable!!! Unlike WiFi, GSM/LTE, IEEE 802.15.4 (Zigbee, Thread)
5 What is Bluetooth? Part 1: essentials Standard for Personal Area Network based on Ericsson research Short range, low-power Frequency hopping spread spectrum (FHSS) 2.4 GHz ISM band Bluetooth Special Interest Group formed in 1998 20000+ SIG member companies Billions of products shipped Nordic Semiconductor is one of 11 SIG Board members
6 Bluetooth: terminology Traditional DMA Specification EasyDMA BR 1.1 (2002) Basic Rate (1 Mbit/s) EDR 2.0 (2004) Enhanced Data Rate (2 and 3 Mbit/s) HS 3.0 (2009) High Speed (Alternate MAC/PHY) LE 4.0 (2010) Low Energy (1 Mbit/s ultra low power) Bluetooth Smart 4.0 Single-mode, LE-only radio Bluetooth Smart Ready 4.0 Dual-mode, BR/EDR and LE dual radio nrf5x Series
7 Bluetooth LE: key features Small packets (27 bytes) Short RX and TX windows Race to idle Turn the radio on as seldom as possible Turn the radio off as soon as possible Connection in only 6 ms with fast teardown Coin-cell battery 1+ year Low memory footprint (8kB RAM on our nrf51822) Simple stateless protocol 128-bit AES encryption
8 What is Bluetooth? Part 2: Profile overview: Examples and roles HID over GATT: Human Interface Device Host (PC, tablet, phone) Device (keyboard, mouse, track pad) Heart Rate: Used in sports and in medicine Collector (PC, tablet, phone) Sensor (Heart Rate belt) Proximity: Proximity monitoring of two devices Monitor (PC, tablet, phone) Reporter (key fob, phone)
9 What is Bluetooth LE? Part 3. Architecture
10 Link Layer Responsible for advertising, scanning, and creating and maintaining connections State machine Standby Advertising necessary to be discoverable or connectable Scanning passive or active Initiating becomes master Connection master or slave Packet structure Advertising and data packets 40 channels 3 advertising and 37 data channels 128-bit AES encryption
11 Link Layer: Topology Slave Advertiser Initiator Master Scanner Scanner Connection Request Slave Advertiser Slave
12 Link Layer: Advertising and Scanning
13 Link Layer: Connection Advertises in all three channels RX period on each channel Stops advertising on consecutive channels when it receives a connection request Slave turns on its receiver and waits for a packet from the master If it receives a packet, the slave responds, and a connection is established When in a connection, the master sends first, and the slave responds Multiple packets can be sent every connection interval Connection interval can be from 7.5 ms to 4 seconds
14 Attribute Protocol Defines how a client can find and access the attributes on a server Operations Request Response Command Indication Confirmation Notification Attribute Labeled, addressable data Handle, type and value Permissions
15 Attribute Protocol: Client-Server Client Server Server Client Master Slave
16 Attribute Protocol: Operations Request Response Attr. Client Command Indication Confirmation Notification Server Attr. Attr. Attr.
17 Attribute Protocol: What is an attribute? Attribute handle uniquely identifies an attribute on a server Attribute type Universal Unique Identifier(UUID) 128-bit UUID 16-bit short UUID using Bluetooth Base 0000XXXX-0000-1000-8000-00805F9B34FB Attribute value state data, 0-512 bytes Permissions Readable, writeable, or both
18 Generic Attribute Profile (GATT) Defines a hierarchical grouping of attributes and procedures for discovery and access Profile Service Characteristic Attribute Procedures Discovery Client-initiated Server-initiated
19 Generic Attribute Profile: Hierarchy Profile one or more services Service one or more characteristics Include Primary and secondary Characteristic two or more attributes Declaration Value Descriptor
20 Generic Attribute Profile: Characteristic Characteristic two or more attributes Declaration Properties Value handle Type(UUID) Value Descriptor Declaration Value User Description Presentation Format Client Characteristic Configuration Descriptor
21 Generic Attribute Profile: Procedures Discovery Client-Initiated Reading a characteristic value Writing a characteristic value Reading a characteristic descriptor Writing a characteristic descriptor Server-Initiated Notification of a characteristic value Indication of a characteristic value
22 Generic Attribute Profile: Example Handle UUID Value 0x0001 0x2800 (Service) 0x1800 (GAP Service UUID) 0x0002 0x2803 (Characteristic) {0x02, 0x0003, 0x2A00} (Read, Value Handle, Device Name UUID) 0x0003 0x2A00 (Device Name UUID) My Device 0x0004 0x2800 (Service) 0x1801 (GATT Service UUID) 0x0005 0x2800 (Service) 0x180F (Battery Service UUID) 0x0006 0x2803 (Characteristic) {0x12, 0x0007, 0x2A19} (Read/Notify, Value Handle, Battery Level UUID) 0x0007 0x2A19 (Battery Level UUID) 0x00 (Battery Level Value) 0x0008 0x2902 (CCCD) 0x0000 0x0009 0x2800 (Service) 0x5AB20000-B355-4D8A-96EF-2963812DD0B8 (Proprietary Temperature Service UUID) 0x000A 0x2803 (Characteristic) {12, 0x000B, 0x5AB20001-B355-4D8A-96EF-2963812DD0B8} (Read/Notify, Value Handle, Proprietary Temperature UUID) 0x000B 0x5AB20001-B355-4D8A-96EF-2963812DD0B8 0x0000 (Temperature Value) (Proprietary Temperature UUID) 0x000C 0x2901 (User Description) Bedroom 0x000D 0x2904 (Presentation Format) {0x0E, 0xFE, 0x272F, 0x01, 0x010B} (signed 16-bit integer, -2, Celsius, Bluetooth SIG Assigned Numbers, Indoor) 0x000E 0x2902 (CCCD) 0x0000
23 Generic Access Profile: Overview Defines how devices discover, connect and bond with one another Roles Broadcaster Advertiser Observer Scanner Peripheral - Slave Central Master Modes and procedures Bonding saving encryption keys
24 Profiles: Overview Describes a particular use case, with two or more devices Defines the requirements of each device GAP and GATT features Services Bluetooth SIG profiles Proprietary
25 Bluetooth pairing Security Automatically connect Devices remember each other Connecting for the first time? Requires user intervention Why not use Out-of-Band pairing!
26 Bluetooth LE pairing options... Bluetooth Smart pairing 3 options currently: Passkey entry Complex and moderate security Just works Easy but not secure NFC OOB pairing Simple and secure Touch to pair
27 NFC OOB pairing why do we need it? IoT will generate a huge range of products that perform a particular function Lights Environmental sensors Industrial/Domestic appliances These products will not have keypads and most will not have displays Black boxes IoT products will be networked, locally and to the cloud Reliable security will be a pre-requisite
28 Why NFC? NFC Tags are low power! There are even tags which do not need any power supply (power-byfield) It is interoperable! NFC is supported natively by devices and operating systems NFC Readers need to support all Tag types NFC enables true Touch to... experience You have a picture open on your phone: Touch to share to open a BT link and show it on the other phone. Touch to pair no more cryptic codes to enter
29 What is NFC? NFC is based on a variety of RFID standards It operates @ 13,56 MHz Typically a passive card harvests energy from the magnetic field that the Reader generates. The maximum operating distance is below 10 cm. The magnetic field is modulated to transfer data at the same time. Nordic Semiconductor is an NFC Forum member
30 NFC: terminology Term Poll mode Listen mode Load modulation NFC Forum Device NDEF NFC Tag Meaning A mode when a device generates an RF carrier and probes for other devices A mode when a device does not generate a carrier but listens for the RF field of another device Passive RF carrier modulation performed by switching on and off a passive load inthe RF circuit A device that supports alloperating modes defined by NFC Forum (needs to support all tag types) NFC Data Exchange Format A contactless tag or card supporting passive NFC communication (not generating RF field) and NDEF. It cannot initiate communication.
31 NFC operating modes Mode Polling Device Listening Device Read/Write Mode NFC Forum Device Tag e.g. nrf52 NFCT Peer Mode NFC Forum Device NFC Forum Device Card Emulation Mode NFC Forum Device NFC Forum Device emulating a Tag
32 NFC antenna Loop antenna for inductive coupling Coupling factor low when antenna sizes are very different Main issue happens from small to big antenna. E.g. small antenna in a wearable to big antenna in payment terminal Small antenna on both sides is also an issue because it requires the user to align quite precisely NFC Forum testing is done against 3 different sizes of Poller antennas and 3 different sizes of Listener antennas. Must pass with all combinations! And this is difficult when the device uses a very small antenna Side note: when the Poller antenna and the Listener antenna have the same geometry and are both tuned to 13.56 MHz, are well aligned and very close to each other there is overcoupling and degrades performance.
33 NFC technologies NFC-A: 106-848kbps Poller: ASK 100% Modified Miller Listener: load modulation, Manchester coding w/ OOK 848kHz subcarrier NFC-B: 106kb/s 6.5Mb/s Poller: ASK 10% NRZ Listener: load modulation, NRZ w/ BPSK 848kHz subcarrier NFC-F: 212 and 424kb/s Poller : Manchester coding with ASK 10% both directions. Listener : load modulation, Manchester coding with ASK 10% both directions. NFC-V: 6.6-27kb/s Poller: ASK 100% 1-of-4 coding Listener : Manchester coding w/ OOK 424kbps subcarrier (NFC Forum only 106kb/s for NFC-A and NFC-B)
34 NFC-A Modulation Poller -> Listener Listener -> Poller
35 NFC Reader Writer mode Read a tag with information from a smart poster Simplest and most secure mode of BT pairing Phone generates carrier and 100% amplitude modulation Tag responds with load modulation
36 NFC on nrf52 NFCT (Near Field Communication Tag) is one of the nrf52 peripherals NFC-A Listen mode compliant Date rate 106 kbps Can only be a target (a tag), cannot be an initiator it means it is able to expose information but is NOT able to read information from or write information into another tag. System Wake-On-Field function NFCT can wake up nrf52 from deep sleep upon detection of NFC field Configurable Easy DMA channel to RAM Poller: ASK 100% 1-of-4 coding Listener : Manchester coding w/ OOK 424kbps subcarrier Hardware supported NFC features Automatic Collision resolution algorithm Configurable frame assembler/disassembler including CRC and parity calculation Inter Frame timer
37 NFC NDEF The NFC Data Exchange Format (NDEF) is a standardized data format that can be used to exchange information between any compatible NFC device and another NFC device or tag. A NDEF record payload can contain a nested NDEF message
38 Bluetooth LE pairing over NFC how it works? Handover Requestor Handover Selector Read NFC Forum Tag NDEF message with Handover Select record Communication over NFC BLE OOB pairing Data exchange on BLE Communication over BLE
39 BLE pairing over NFC support in mobile devices Android: Most current model Android phones & tablets have NFC HW Supports only Just Works over NFC. Windows: Windows Phone (smartphones) supports only Just Works over NFC. Windows 8.1/10 (laptops and tablets) and Windows RT (tablets) are the only OSes right now that support OOB pairing over NFC. ios: iphone 6, latest ipad Air, ipad Mini & Apple Watch have NFC HW Does not support Reader/Writer mode at all.
40 Other NFC use cases(1) Waking up a device Many IoT products do not have keypads or buttons nrf52 NFCT Wake-On-Field function adds only 100 na and allows to wake up a device from System Off.
41 Other NFC use cases(2) Launching an application Reading a tag launches already installed app or downloads new app from the store if the user doesn t already have the app installed This scenario isn t standardized by the NFC Forum, but is standaralized and natively supported by OSes providers (no additional application needed on the mobile side) Will be shown on a demo
42 Other NFC use cases(3) opening webpage, guide, manual etc. Reading a tag launches a default web browser with provided URI This scenario is standardized by the NFC Forum and natively supported by OSes providers (no additional application needed on mobile side)
43 DEMO application BLE Heart Rate Sensor application NFC used for pairing and launchng nrf Toolbox application on a phone
44 NFC (Type 2 Tag) API