Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?

5,683 views

Published on

Beacons are one of the hottest topics of mobile development right now. Bluetooth Smart / LE is indispensable for Wearables and the Internet of Things (IoT). NFC is now finally arriving in the mass market.

With Windows 10, Microsoft has significantly expanded the possibilities for proximity technologies. In this overview, you will learn about the new scenarios and see several concrete examples of what is possible and how you can leverage it for your own projects!

Agenda:

NFC
- NFC simulation
- Smart Cards
- Raw NFC tag access
- Host card emulation (HCE)

Bluetooth Smart
- Bluetooth Beacon support
- Beacon specifications (iBeacon, Eddystone & co)

Published in: Technology

Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?

  1. 1. Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons? Andreas Jakl @andijakl andreas.jakl@tieto.com 1.10.2015, v1.1.0
  2. 2. © Andreas Jakl, Tieto Corporation Andreas Jakl • Mobility Evangelist, Tieto • @andijakl • andreas.jakl@tieto.com • 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
  3. 3. © Andreas Jakl, Tieto Corporation Overview • NFC • New: NFC simulation • Smart Cards • New: raw tag access • New: host card emulation • Bluetooth Smart • New: Bluetooth Beacon support • Beacon specifications (iBeacon, Eddystone & co) 3
  4. 4. Near Field Communication Open NFC with NDEF 4
  5. 5. © Andreas Jakl, Tieto Corporation NFC? 5 < 1 cm (tap)
  6. 6. © Andreas Jakl, Tieto Corporation NFC? 6 < 424 kbit / s
  7. 7. © Andreas Jakl, Tieto Corporation NFC? 7
  8. 8. © Andreas Jakl, Tieto Corporation NFC Tags 8 Tag memory size: 48 byte – few kB
  9. 9. © Andreas Jakl, Tieto Corporation NFC & NDEF Overview 9 NDEF Message NDEF Record (e.g., URL) … NDEF = NFC Data Exchange Format
  10. 10. © Andreas Jakl, Tieto Corporation NDEF • NDEF • Data container for structured data • Does not define “how” 10 Smart Poster MIME Hand- over Custom Empty Uri Text Image vCard Web Sms Tel Record types Possible payloads
  11. 11. © Andreas Jakl, Tieto Corporation Open Source NDEF Library 11 Reusable NDEF classes Create NDEF messages & records (standard compliant) Parse information from raw byte arrays Fully documented Open Source LGPL license andijakl.github.io/ndef-nfc library development supported by:
  12. 12. © 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
  13. 13. © 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 info var uriRecord = new NdefUriRecord(record); Debug.WriteLine("URI: " + uriRecord.Uri); } }} 3 Parse NDEF message
  14. 14. © Andreas Jakl, Tieto Corporation Emulator: NFC 14 https://msdn.microsoft.com/library/windows/apps/mt162269.aspx New in Windows 10 Mobile
  15. 15. © 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
  16. 16. Smart Cards Low Level NFC Interaction 16
  17. 17. © Andreas Jakl, Tieto Corporation Smart Cards • Interface • Contact (chip) • Contactless (eg NFC compatible) 17 Image credits: Maestro paypass
  18. 18. © 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
  19. 19. © 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
  20. 20. © 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 reading return; } 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
  21. 21. © 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 state var 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
  22. 22. © 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
  23. 23. © 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/Samples/Nfc • Detects Smart Card type • Contains some common commands • E.g., Mifare Authentication 23 * Standalone library for Windows Phone 8.1: https://nfcsmartcardreader.codeplex.com/
  24. 24. © Andreas Jakl, Tieto Corporation New: Transparent Exchange • Send custom commands • Manufacturer specific • Commands outside of standards • Custom cards • => Raw tag access 24
  25. 25. © 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:
  26. 26. © 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:
  27. 27. Host Card Emulation Virtual Smart Cards with Apps 27
  28. 28. © 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
  29. 29. © 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/
  30. 30. © 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
  31. 31. © 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 task SmartCardTrigger
  32. 32. © Andreas Jakl, Tieto Corporation Background task SmartCardTrigger 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. TryRespondAsync APDU TypedEvent SmartCardEmulatorApduReceivedEventArgs
  33. 33. © Andreas Jakl, Tieto Corporation Emulator: HCE 33 Supports scripting APDU communication with app
  34. 34. © Andreas Jakl, Tieto Corporation Details & Sample 34 Microsoft NFC Team Blog http://bit.ly/nfc-hce
  35. 35. Bluetooth & Beacons 35
  36. 36. © 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
  37. 37. © 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
  38. 38. © Andreas Jakl, Tieto Corporation Publisher & Watcher 38 Publisher Payload Watcher Filter Event Callback
  39. 39. © Andreas Jakl, Tieto Corporation Publish 39 _publisher = new BluetoothLEAdvertisementPublisher(); Create1 var writer = new DataWriter(); const ushort uuidData = 0x1234; // Custom payload writer.WriteUInt16(uuidData); var manufacturerData = new BluetoothLEManufacturerData { CompanyId = 0xFFFE, // Custom company ID Data = writer.DetachBuffer() }; _publisher.Advertisement.ManufacturerData.Add(manufacturerData); Setup2 _publisher.Start(); Start3 Company identifiers assigned by Bluetooth SIG We will subscribe to this specific payload
  40. 40. © Andreas Jakl, Tieto Corporation Watch 40 _watcher = new BluetoothLEAdvertisementWatcher(); Create1 var writer = new DataWriter(); const ushort uuidData = 0x1234; // Custom payload writer.WriteUInt16(uuidData); var manufacturerData = new BluetoothLEManufacturerData { CompanyId = 0xFFFE, // Custom company ID Data = writer.DetachBuffer() }; _watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(manufacturerData); Setup2 _watcher.Received += WatcherOnReceived; _watcher.Start(); Start3 Same Code!
  41. 41. © 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
  42. 42. Beacon Specifications iBeacon, Eddystone & Co 42
  43. 43. © Andreas Jakl, Tieto Corporation Beacon Formats 43 Bluetooth advertisement standardized by Bluetooth Core specification. → “How” iBeacon Eddystone AltBeacon … Data not standardized – various different specifications. → “What” iBeacon™ is a Trademark by Apple Inc. Eddystone™ is an open Bluetooth® Smart beacon format from Google.
  44. 44. © Andreas Jakl, Tieto Corporation iBeacon™ & Eddystone™ 44 Eddystone Beacon Eddystone-UID Beacon ID, Tx power level Eddystone-TLM Battery, temperature, sent frames, time running Eddystone-URL URL, Tx power level Open source specification https://github.com/google/eddystone iBeacon UUID, major & minor ID Proprietary specification https://developer.apple.com/ibeacon/
  45. 45. © Andreas Jakl, Tieto Corporation Universal Beacon Library 45 https://github.com/andijakl/universal-beacon Parse & create Beacon frames Assigns received frames to individual beacons Fully documented. Includes Windows 10 example app. Open Source license
  46. 46. © Andreas Jakl, Tieto Corporation Example 46 _beaconManager = new BeaconManager(); _watcher = new BluetoothLEAdvertisementWatcher(); _watcher.Received += WatcherOnReceived; _watcher.Start(); 1 Initialize Beacon scanning API documentation: bit.ly/ProximityAPI private async void WatcherOnReceived( BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs eventArgs) { await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => _beaconManager.ReceivedAdvertisement(eventArgs)); } 2 Beacon advertisement frame received callback
  47. 47. © Andreas Jakl, Tieto Corporation Example 47 foreach (var bluetoothBeacon in _beaconManager.BluetoothBeacons.ToList()) { Debug.WriteLine("nBeacon: " + bluetoothBeacon.BluetoothAddressAsString); Debug.WriteLine("Type: " + bluetoothBeacon.BeaconType); foreach (var beaconFrame in bluetoothBeacon.BeaconFrames.ToList()) { // Print a small sample of the available data parsed by the library if (beaconFrame is UidEddystoneFrame) { Debug.WriteLine("Eddystone UID Frame"); Debug.WriteLine("ID: " + ((UidEddystoneFrame) beaconFrame). NamespaceIdAsNumber.ToString("X") + " / " + ((UidEddystoneFrame) beaconFrame). InstanceIdAsNumber.ToString("X")); } // ... }} 3 Access Beacon Info
  48. 48. © Andreas Jakl, Tieto Corporation Bluetooth Beacon Interactor 48 Library Example App = Free Windows 10 Bluetooth Beacon Interactor https://www.microsoft.com/store/apps/9NBLGGH1Z24K
  49. 49. Internal Summary 49
  50. 50. © Andreas Jakl, Tieto Corporation New Windows 10 Scenarios NFC Simulation Smart Card Transparent Exchange Host Card Emulation Bluetooth Beacons
  51. 51. Internal Thank You! Andreas Jakl @andijakl andreas.jakl@tieto.com 51

×