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. |
service | The Bluetooth Serial service. |
Returns
Type | Description |
---|---|
Nmea |
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 Nmea
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
Target | Versions |
---|---|
.NET Windows | 100.13 - 200.6 |
UWP | 100.10 - 200.6 |