From addb1050c836da75b247216f5a79be3a31d563d7 Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Mon, 10 Feb 2014 22:33:55 -0800 Subject: [PATCH 1/3] Update README.md --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/README.md b/README.md index b3553c9..dbaf9b8 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,64 @@ BTDevices ========= Library for handling Bluetooth devices in Windows Store and Windows Phone, in particular devices using NMEA messages. + +This library makes it easy to connect and listen for NMEA messages from Bluetooth Devices in Windows Store and Windows Phone apps. + + +Usage - Windows Store +===================== +Ensure the bluetooth capability is enabled by opening package.appxmanifest in a text editor, and add the following to the section: +``` + + + + + +``` +See more here on bluetooth device capabilities in WinStore: http://msdn.microsoft.com/en-us/library/windows/apps/dn263090.aspx + +``` +//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 BTDevices.NmeaDevice(rfcommService); + rangeFinder.MessageReceived += device_NmeaMessageReceived; + await rangeFinder.StartAsync(); +} +... +private void device_NmeaMessageReceived(BTDevices.NmeaDevice sender, BTDevices.Nmea.NmeaMessage args) +{ + // called when a message is received +} + +``` + + +Usage - Windows Phone +====================== +Ensure the "ID_CAP_PROXIMITY" capability is enabled in the WMAppManifest.xml file. +``` + +// Search for all paired devices +PeerFinder.AlternateIdentities["Bluetooth:Paired"] = ""; +//Get all devices +var devices = await PeerFinder.FindAllPeersAsync(); +//Select device by name (in this case TruePulse 360B Laser Range Finder) +var TruePulse360B = devices.Where(t => t.DisplayName.StartsWith("TP360B-")).FirstOrDefault(); +if (TruePulse360B != null) +{ + var device = new BTDevices.NmeaDevice((PeerInformation)TruePulse360B); + device.MessageReceived += device_NmeaMessageReceived; +} +... +private void device_NmeaMessageReceived(BTDevices.NmeaDevice sender, BTDevices.Nmea.NmeaMessage args) +{ + // called when a message is received +} +``` From 72ceed59bff8f89e94ccaaf23de67477f5bc595c Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Mon, 10 Feb 2014 22:38:13 -0800 Subject: [PATCH 2/3] Update README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index dbaf9b8..c6db195 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,25 @@ Library for handling Bluetooth devices in Windows Store and Windows Phone, in pa This library makes it easy to connect and listen for NMEA messages from Bluetooth Devices in Windows Store and Windows Phone apps. +Currently supported devices: +- Generic GPS NMEA +- Trimble Laser Range Finder +- TruePulse Laser Range Finder + +The API is easily extensible with more NMEA message. Simply create a new class inheriting from "NmeaMessage" and use the NmeaMessageAttribute to tag it with the NMEA Message Token. + +Example: +``` +[NmeaMessageType(Type = "GPRMC")] +public class Gprmc : NmeaMessage +{ + protected override void LoadMessage(string[] message) + { + //Process message parts + } +} +``` + Usage - Windows Store ===================== From d034d9d02f5953909d21060191579b4881d12f5f Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Mon, 10 Feb 2014 22:41:13 -0800 Subject: [PATCH 3/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c6db195..5b9e037 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ public class Gprmc : NmeaMessage } ``` +If you add new messages, please fork, provide a simple unit test for the message and submit a pull request. Usage - Windows Store =====================