which new scenarios are enabled by windows 10 for nfc, bluetooth le & ibeacons?

44
Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons? Andreas Jakl @ andijakl [email protected] 30.6.2015, v1.0.0

Upload: andreas-jakl

Post on 14-Aug-2015

233 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

Which new scenarios are enabled by

Windows 10 for NFC, Bluetooth LE & iBeacons?Andreas Jakl

@andijakl

[email protected]

30.6.2015, v1.0.0

Page 2: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Andreas Jakl

• Mobility Evangelist, Tieto• @andijakl

[email protected]

• mobility.builders Community• Mobile Developer After-Work Events in Vienna

• History• Mopius: Startup-Founder (NFC & Mobile Apps)

• Nokia, Finland: Technology Wizard

• FH Hagenberg: Assistant Professor Mobile Computing

• Siemens / BenQ Mobile, Germany: Augmented Reality-Apps

2

Page 3: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Overview

• NFC• New: NFC simulation

• Smart Cards• New: raw tag access

• New: host card emulation

• Bluetooth LE• New: beacon support

3

Page 4: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

Near Field CommunicationOpen NFC with NDEF

Page 5: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

NFC?

5

< 1 cm

(tap)

Page 6: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

NFC?

6

< 424 kbit / s

Page 7: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

NFC?

7

Page 8: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

NFC Tags

8

Tag memory size:

48 byte – few kB

Page 9: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

NFC & NDEF Overview

9

NDEF Message

NDEF Record

(e.g., URL)…

NDEF = NFC Data Exchange Format

Page 10: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

NDEF

• NDEF• Data container for structured data

• Does not define “how”

10

Smart Poster MIMEHand-

overCustom Empty

UriText Image vCard

Web Sms TelRecord types

Possible payloads

Page 11: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Open Source NDEF Library

11

Reusable

NDEF

classes

Create NDEF

messages & records(standard compliant)

Parse informationfrom raw byte arrays

Fully documentedOpen Source LGPL license

andijakl.github.io/ndef-nfc

library development

supported by:

Page 12: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

NDEF Subscriptions

12

_device = ProximityDevice.GetDefault();

1 Activate proximity device

API documentation: bit.ly/ProximityAPI

_subscribedMessageId = _device.SubscribeForMessage("NDEF",MessageReceivedHandler);

2 Subscribe to all NDEF formatted tags

Page 13: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Parse Contents

13

private void MessageReceivedHandler(ProximityDevice sender, ProximityMessage message){

var msgArray = message.Data.ToArray();NdefMessage ndefMessage = NdefMessage.FromByteArray(msgArray);foreach (NdefRecord record in ndefMessage) {

// Check the type of each record if (record.CheckSpecializedType(false) == typeof(NdefUriRecord)) {

// Convert and extract URI infovar uriRecord = new NdefUriRecord(record);Debug.WriteLine("URI: " + uriRecord.Uri);

}}}

3 Parse NDEF message

Page 14: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Emulator: NFC

14

https://msdn.microsoft.com/library/windows/apps/mt162269.aspx

New in Windows 10 Mobile

Page 15: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Limitations with Proximity API

• Open tags only• Write protection possible

• Readable by everyone

• No encryption or access via keys

• Use cases• Tags with URLs on products (like QR codes)

• Bluetooth pairing

• Accessories: speakers, headsets

• Connection handover: share images or business cards between phones

15

Page 16: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

Smart CardsLow Level NFC Interaction

Page 17: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Smart Cards

• Interface• Contact

(chip)

• Contactless (eg NFC compatible)

17 Image credits: Maestro paypass

Page 18: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Smart Card Content

• Can be very powerful• Microprocessor

• Non-volatile memory and cryptography

• Programmable apps (e.g. Java Card)

• Use cases• Credit card

• Public transport cards

• Key card for doors

• …

18

Page 19: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Windows Phone Support

19

Lumia 830 Lumia 730 Lumia 640 Lumia 640 XL

… + upcoming

Lumias with

NFC

&

NXP PN547

NFC chip

Page 20: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Initialize NFC Smart Card Reading

20

if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Devices.SmartCards.SmartCardConnection")) {// This SKU of Windows does not support NFC card readingreturn;

}

1 Check for API support

var devSelector = SmartCardReader.GetDeviceSelector(SmartCardReaderKind.Nfc);var devices = await DeviceInformation.FindAllAsync(devSelector);_smartCardReader =

await SmartCardReader.FromIdAsync(devices.FirstOrDefault().Id);_smartCardReader.CardAdded += SmartCardReaderOnCardAdded;

2 Find device & subscribe

Page 21: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Smart Card Communication

21

private async void SmartCardReaderOnCardAdded(SmartCardReader sender, CardAddedEventArgs args) {

// Get Answer to Reset (ATR) according to ISO 7816// ATR = info about smart card's characteristics, behaviors, and statevar info = await args.SmartCard.GetAnswerToResetAsync();var infoArray = info.ToArray();Debug.WriteLine("Answer to Reset: " + BitConverter.ToString(infoArray));

// Connect to the card// var connection = await args.SmartCard.ConnectAsync();// ...

}

3 Check Type & Connect

Page 22: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Smart Card Communication: APDU

• Application Protocol Data Unit

• Communication protocol

22

Response APDU

Status code Response data

Command APDU

Header

(Instruction code)Parameter data

Page 23: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Smart Card Commands

• Microsoft PC/SC Library *• Now included in Windows 10 NFC Sample

https://github.com/Microsoft/Windows-universal-samples/tree/master/nfcsample

• Detects Smart Card type

• Contains some common commands• E.g., Mifare Authentication

23 * Standalone library for Windows Phone 8.1: https://nfcsmartcardreader.codeplex.com/

Page 24: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

New: Transparent Exchange

• Send custom commands• Manufacturer specific

• Commands outside of standards

• Custom cards

• => Raw tag access

24

Page 25: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Mifare Ultralight C Write Command

25

var writeContents = new byte[] { 0xA2, 0x08, 0x0A, 0x0B, 0x0C, 0x0D };await mifareULAccess.TransparentExchangeAsync(writeContents);

Write command according

to Mifare specification

Page address

4 bytes of memory to write

… added to Microsoft NFC sample:

Page 26: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Mifare Ultralight C Write Command

26

var writeContents = new byte[] { 0xA2, 0x08, 0x0A, 0x0B, 0x0C, 0x0D };await mifareULAccess.TransparentExchangeAsync(writeContents);

Write command according

to Mifare specification

Page address

4 bytes of memory to write

… added to Microsoft NFC sample:

Page 27: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

Host Card EmulationVirtual Smart Cards with Apps

Page 28: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Host Card Emulation

• Simulate Smart Card with app• Previously (< Win 10): SIM-card as smart card• Win 10: adds app support: directly communicate with NFC reader

• Register for specific applet ID• Auto-launches app through background task

28

Thank you!

$15.61 left

Page 29: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Payment vs Loyalty

• Single default payment app • Multiple loyalty / coupons / transit apps (“other”)

29

“Select AID”

APDU command

Yomova Countertop Terminal – Image by CardComplete

https://www.cardcomplete.com/akzeptanzpartner/terminals/standgeraete/complete-terminal-yomova-countertop/

Page 30: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

HCE Support

30

if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Devices.SmartCards.SmartCardEmulator")) // ... Supported!

1 Check for API support

var sce = await SmartCardEmulator.GetDefaultAsync();if (sce != null) // ... Supported!

2 Check for generic card emulation support

if (sce.IsHostCardEmulationSupported()) // ... Supported!

3 Check for HCE Support

Page 31: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

HCE Setup

31

var appletIds = new List<IBuffer> { Encoding.UTF8.GetBytes("MyAppletId").AsBuffer()};var aidGroup = new SmartCardAppletIdGroup("My Loyalty Card", appletIds,

SmartCardEmulationCategory.Other, SmartCardEmulationType.Host);

var reg = await SmartCardEmulator.RegisterAppletIdGroupAsync(aidGroup);var res = await reg.RequestActivationPolicyChangeAsync(policy);

Setup1

var taskBuilder = new BackgroundTaskBuilder{

Name = bgTaskName,TaskEntryPoint = taskEntryPoint

};taskBuilder.SetTrigger(

new SmartCardTrigger(SmartCardTriggerType.EmulatorHostApplicationActivated);bgTask = taskBuilder.Register();

Register Background Task2

Background taskSmartCardTrigger

Page 32: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Background taskSmartCardTrigger

HCE Implementation

32

Process request

Launch app for

confirmation or

user interaction

Optional

… Is your app already running in the foreground?

Can get events as well – also for payments if it’s not the default app.

TryRespondAsyncAPDU

TypedEventSmartCardEmulatorApduReceivedEventArgs

Page 33: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Emulator: HCE

33

Supports scripting APDU

communication with app

Page 34: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Details & Sample

34

Microsoft NFC Team Blog

http://bit.ly/nfc-hce

Page 35: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

Bluetooth & Beacons

Page 36: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Bluetooth Smart

• Bluetooth Low Energy =

• Bluetooth LE =

• Bluetooth Smart• Part of standard since 4.0

• Smart = not backwards compatible

• Support• Windows Phone 8.1+

36

Page 37: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Bluetooth Beacons

• Advertise in regular intervals (e.g., 100 ms)• No pairing required / possible

• Send IDs for identification

• No back communication channel

• Support• Windows 10

• Discover + advertise

37

Page 38: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Publisher & Watcher

38

Publisher

Payload

Watcher

Filter

Event Callback

Page 39: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Publish

39

_publisher = new BluetoothLEAdvertisementPublisher();

Create1

var writer = new DataWriter();const ushort uuidData = 0x1234; // Custom payloadwriter.WriteUInt16(uuidData);var manufacturerData = new BluetoothLEManufacturerData{

CompanyId = 0xFFFE, // Custom company IDData = writer.DetachBuffer()

};_publisher.Advertisement.ManufacturerData.Add(manufacturerData);

Setup2

_publisher.Start();

Start3

Company identifiers

assigned by Bluetooth SIG

We will subscribe to this

specific payload

Page 40: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Watch

40

_watcher = new BluetoothLEAdvertisementWatcher();

Create1

var writer = new DataWriter();const ushort uuidData = 0x1234; // Custom payloadwriter.WriteUInt16(uuidData);var manufacturerData = new BluetoothLEManufacturerData{

CompanyId = 0xFFFE, // Custom company IDData = writer.DetachBuffer()

};_watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(manufacturerData);

Setup2

_watcher.Received += WatcherOnReceived;_watcher.Start();

Start3

Same

Code!

Page 41: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

Beacon Background Tasks

• Scan for beacons from background task• BluetoothLEAdvertisementWatcherTrigger

• Only one payload filter

• Minimal sampling interval = 1 event / sec / beacon

• Foreground = no restrictions, every event

• Requires hardware offloading feature

• Process info directly in hardware

• All new Windows 10 Mobile devices + previous flagships + Surface Pro 3

• Publish beacons in the background

41

Page 42: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

Inte

rnal

Summary

42

Page 43: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

© Andreas Jakl, Tieto Corporation

New Windows 10 Scenarios

NFC Simulation

Smart Card

Transparent

Exchange

Host Card

Emulation

Bluetooth

Beacons

Page 44: Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & iBeacons?

Inte

rnal

Thank You!

Andreas Jakl

@andijakl

[email protected]

44