Date post: | 14-Aug-2015 |
Category: |
Technology |
Upload: | andreas-jakl |
View: | 234 times |
Download: | 1 times |
Which new scenarios are enabled by
Windows 10 for NFC, Bluetooth LE & iBeacons?Andreas Jakl
@andijakl
30.6.2015, v1.0.0
© Andreas Jakl, Tieto Corporation
Andreas Jakl
• Mobility Evangelist, Tieto• @andijakl
• 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
© 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
Near Field CommunicationOpen NFC with NDEF
© Andreas Jakl, Tieto Corporation
NFC?
5
< 1 cm
(tap)
© Andreas Jakl, Tieto Corporation
NFC?
6
< 424 kbit / s
© Andreas Jakl, Tieto Corporation
NFC?
7
© Andreas Jakl, Tieto Corporation
NFC Tags
8
Tag memory size:
48 byte – few kB
© Andreas Jakl, Tieto Corporation
NFC & NDEF Overview
9
NDEF Message
NDEF Record
(e.g., URL)…
NDEF = NFC Data Exchange Format
© 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
© 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:
© 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
© 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
© Andreas Jakl, Tieto Corporation
Emulator: NFC
14
https://msdn.microsoft.com/library/windows/apps/mt162269.aspx
New in Windows 10 Mobile
© 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
Smart CardsLow Level NFC Interaction
© Andreas Jakl, Tieto Corporation
Smart Cards
• Interface• Contact
(chip)
• Contactless (eg NFC compatible)
17 Image credits: Maestro paypass
© 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
© 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
© 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
© 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
© 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
© 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/
© Andreas Jakl, Tieto Corporation
New: Transparent Exchange
• Send custom commands• Manufacturer specific
• Commands outside of standards
• Custom cards
• => Raw tag access
24
© 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:
© 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:
Host Card EmulationVirtual Smart Cards with Apps
© 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
© 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/
© 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
© 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
© 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
© Andreas Jakl, Tieto Corporation
Emulator: HCE
33
Supports scripting APDU
communication with app
© Andreas Jakl, Tieto Corporation
Details & Sample
34
Microsoft NFC Team Blog
http://bit.ly/nfc-hce
Bluetooth & Beacons
© 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
© 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
© Andreas Jakl, Tieto Corporation
Publisher & Watcher
38
Publisher
Payload
Watcher
Filter
Event Callback
© 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
© 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!
© 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
Inte
rnal
Summary
42
© Andreas Jakl, Tieto Corporation
New Windows 10 Scenarios
NFC Simulation
Smart Card
Transparent
Exchange
Host Card
Emulation
Bluetooth
Beacons
Inte
rnal
Thank You!
Andreas Jakl
@andijakl
44