Show / Hide Table of Contents

Class BluetoothDevice

A Bluetooth NMEA device

Inheritance
object
NmeaDevice
BluetoothDevice
Implements
IDisposable
Inherited Members
NmeaDevice.OpenAsync()
NmeaDevice.CloseAsync()
NmeaDevice.MessageReceived
NmeaDevice.DeviceDisconnected
NmeaDevice.Dispose()
NmeaDevice.IsOpen
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NmeaParser
Assembly: NmeaParser.dll
Syntax
public class BluetoothDevice : NmeaDevice, IDisposable
Remarks

To use the NMEA Parser against a bluetooth device in a 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>

See more here on bluetooth device capabilities in UWP Apps: https://docs.microsoft.com/en-schemas/appxpackage/how-to-specify-device-capabilities-for-bluetooth

Make sure your Bluetooth device is paired with your Windows Device.

//Get list of devices
                                                                              string serialDeviceType = RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort);
                                                                              var devices = await DeviceInformation.FindAllAsync(serialDeviceType);
                                                                              //Select device by name (in this case TruePulse 360B Laser Range Finder)
                                                                              var TruePulse360B = devices.Where(t => t.Name.StartsWith("TP360B-")).FirstOrDefault();
                                                                              //Get service
                                                                              RfcommDeviceService rfcommService = await RfcommDeviceService.FromIdAsync(TruePulse360B.Id);
                                                                              if (rfcommService != null)
                                                                              {
                                                                                  var rangeFinder = new NmeaParser.BluetoothDevice(rfcommService);
                                                                                  rangeFinder.MessageReceived += device_NmeaMessageReceived;
                                                                                  await rangeFinder.OpenAsync();
                                                                              }
                                                                              ...
                                                                              private void device_NmeaMessageReceived(object sender, NmeaParser.NmeaMessageReceivedEventArgs args)
                                                                              {
                                                                                  // called when a message is received
                                                                              }

Constructors

Name Description
BluetoothDevice(RfcommDeviceService, bool)

Initializes a new instance of the BluetoothDevice class.

BluetoothDevice(PeerInformation)

Initializes a new instance of the BluetoothDevice class.

Properties

Name Description
CanWrite

Gets a value indicating whether this device supports writing

Methods

Name Description
CloseStreamAsync(Stream)

Closes the stream the NmeaDevice is working on top off.

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

GetBluetoothSerialDevicesAsync()

Gets a list of bluetooth devices that supports serial communication

OpenStreamAsync()

Creates and opens the stream the NmeaDevice is working on top off.

ReadAsync(byte[], int, int, CancellationToken)

Performs a read operation of the stream

WriteAsync(byte[], int, int)

Writes to the device stream. Useful for transmitting RTCM corrections to the device Check the CanWrite property before calling this method.

Applies

TargetVersions
.NET Windowsmain
.NET Androidmain, v3.0
UWPmain, v3.0, v2.2, v2.1, v2.0
Xamarin.Androidv2.2, v2.1, v2.0
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX