Show / Hide Table of Contents

Method FromBluetooth

FromBluetooth(RfcommDeviceService)

Creates a NMEA LocationDataSource based on a serial port.

Declaration
public static NmeaLocationDataSource FromBluetooth(RfcommDeviceService service)
Parameters
Type Name Description
Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService service

The Bluetooth Serial service.

Returns
Type Description
NmeaLocationDataSource

A NMEA Location Datasource that reads from the specified bluetooth port

Remarks

The created datasource will automatically handle creating and opening the specified serial port when the datasource is started. Once the datasource has been started, the NmeaDataStream will be available.

To use a bluetooth device in a Windows 10 Universal app, ensure the bluetooth capability is enabled by opening package.appxmanifest in a text editor, and add the following to the <Capabilities> section:

<DeviceCapability Name="bluetooth.rfcomm">
  <Device Id="any">
    <Function Type="name:serialPort" />
  </Device>
</DeviceCapability>

To obtain a serial port device id, you can use the Device Selector API to search for it:

//Get list of devices
string serialDeviceType = RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort);
var devices = await DeviceInformation.FindAllAsync(serialDeviceType); // Select a bluetooth serial port from this list
var device = devices.Where(t => t.Name = "My device name").FirstOrDefault();
//Get service
RfcommDeviceService rfcommService = await RfcommDeviceService.FromIdAsync(device.Id);

Applies to

Platforms and versions
TargetVersions
.NET Windows100.13 - 200.7
UWP100.10 - 200.7
In This Article
Back to top Copyright © 2022 Esri.