310 likes | 651 Views
Apps for Bluetooth, HID, and USB devices. Ellick Sung Program Manager 3 -026. It’s easy to build apps for a rich ecosystem of USB , HID, and Bluetooth devices. Agenda. Device protocol access in Windows Key concepts Bluetooth RFCOMM Resources. New Device Protocol APIs in Windows 8.1.
E N D
Apps for Bluetooth, HID, and USB devices Ellick Sung Program Manager 3-026
It’s easy to build apps for a rich ecosystem of USB, HID, and Bluetooth devices
Agenda • Device protocol access in Windows • Key concepts • Bluetooth RFCOMM • Resources
New Device Protocol APIs in Windows 8.1 New Windows Runtime APIs: Bluetooth (RFCOMM) Bluetooth Smart HID USB Wi-Fi Direct Device Protocol APIs Innovative Devices Ecosystem of Apps Independent Developers
User consent and confidence • Access restricted to capabilities declared in the app manifest • High-level capability exposed to the user, who must consent to allow the app to access the device • User may revoke access at any time • Ability to restrict down to the specific capability and device • Ensuring app permissions are controlled by the user
Discover and use the device • Builds upon existing patterns for Windows.Devices • Familiar ways to interact with each transport • Bluetooth – RFCOMM via Sockets (includes SPP devices) • Bluetooth Smart – GATT Client • HID – Example: vendor-specific usage • USB – WinUSB based • Use standard or proprietary protocols • Some inbox classes reserved
Windows.Devices.Bluetooth.Rfcomm • Device discovery and pairing using familiar Bluetooth user experience • Windows Runtime API to connect, host, and communicate with Bluetooth RFCOMM device services • Devices using Serial Port Profile (SPP) are supported • Service Discovery Protocol (SDP) client and server
Rfcomm API RfcommDeviceService Client - Represents a remote device service RfcommServiceProvider Server -Represents a local service
Declaring app capabilities • Declare the device capability • Device capability name: “bluetooth.rfcomm” • Declare the RFCOMM Service • “name:<ServiceName>” • “serviceId:<ServiceUuid>” • Optional: Restrict your app to a specific device • “any” • “vidpid: <vendor Id> <product Id> <ID source: bluetooth | usb>” • Declare the RFCOMM capabilities in the app manifest
Declaring app capabilities (basic) • <!–- We'll use the Serial Port Profile service on any device. --> • <m2:DeviceCapability Name="bluetooth.rfcomm"> • <m2:Device Id="any"> • <m2:Function Type="name:serialPort" /> • </m2:Device> • </m2:DeviceCapability>
Declaring app capabilities (advanced) • <!–- We'll use different services on two specific devices. --> • <m2:DeviceCapability Name="bluetooth.rfcomm"> • <m2:Device Id="any"> • <m2:Function • Type="serviceId:AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE" /> • </m2:Device> • <m2:Device Id="vidpid:2000 B000 bluetooth"> • <m2:Function Type="name:serialPort" /> • </m2:Device> • </m2:DeviceCapability>
Client: Service discovery and instantiation • Use RfcommDeviceService’s helpers to retrieve an RFCOMM-specific selector. • RfcommDeviceService.GetDeviceSelector • Use an enumerated DeviceInformation object to instantiate an RfcommDeviceService. • RfcommDeviceService.FromIdAsync • Discover RfcommDeviceServices with the Windows.Devices. • Enumeration API
Client: Communicating with the Device • Use StreamSocket.ConnectAsync to connect to the remote device. • Use the ConnectionHostName and ConnectionServiceName properties on the RfcommDeviceService to connect. • I/O over the connected StreamSocket is available via its InputStream and OutputStream properties. • You can use the DataReader and DataWriter classes to read primitive types (such as UInt32s or strings). • Use a StreamSocket to communicate with the remote device
You must dispose of your Rfcomm objects when your application is suspended.
Takeaways • It’s easy to build Windows Store apps for USB, HID, Bluetooth, and Bluetooth Smart devices • Write apps for anything from your own device projects to retail peripherals • Make devices accessible to the entire Windows Store app ecosystem
Resources • Related Sessions • [2-023] Building apps that connect with devices • [3-924a] Apps for USB devices • [3-924b] Apps for HID devices • [3-9028] Apps for Bluetooth Smart devices • Samples and Documentation • Windows.Devices.Bluetooth.Rfcomm API reference • Bluetooth RFCOMM chat sample • Windows Store app samples (search for Sphero)
Bluetooth and Bluetooth Smart • Global standard • Low cost • Robust • Secure • Profile interoperability • Low power • Easy to use • Wireless connectivity for devices
Device protocol access made easy • Windows Runtime APIs for direct access to devices: • No drivers needed, just an app • Less complexity, increased reliability • Supported on all Windows platforms • Bluetooth (RFCOMM) • Bluetooth Smart • HID • USB • Wi-Fi Direct
Hardware developers • Create an app for your device • Enable an ecosystem of apps • Use a standard protocol if available • …or publish your proprietary protocol
Software developers • Create apps for retail devices • Use the standard protocol if implemented • …or download the proprietary protocol if available • Market your apps easily via the Windows Store • Write apps for your own device projects
Windows.Devices.Bluetooth.GenericAttributeProfile • Device discovery and pairing using familiar Bluetooth user experience • Windows Runtime API to collect and administer Bluetooth Smart device data • No driver needed • GATT Client support
Acer Iconia W3, Surface Pro, and Surface Type Cover Get your goodies Device distribution starts after sessions conclude today (approximately 6:00pm) in the Big Room, Hall D. If you choose not to pick up your devices tonight, distribution will continue for the duration of the conference at Registration in the North Lobby.
Required Slide *delete this box when your slide is finalized Your MS Tag will be inserted here during the final scrub. Evaluate this session • Scan this QR codeto evaluate this session and be automatically entered in a drawing to win a prize!