diff --git a/src/NmeaParser/NmeaParser.csproj b/src/NmeaParser/NmeaParser.csproj
index 3d89797..ac4f364 100644
--- a/src/NmeaParser/NmeaParser.csproj
+++ b/src/NmeaParser/NmeaParser.csproj
@@ -11,7 +11,7 @@
An NMEA stream parser for serial port, bluetooth and file-based nmea simulation.
nmea winrt wpf uwp xamarin gps serialport bluetooth
SharpGIS.NmeaParser
- 1.10.0
+ 1.10.1
http://opensource.org/licenses/ms-pl.html
https://github.com/dotMorten/NmeaParser
https://github.com/dotMorten/NmeaParser
@@ -19,9 +19,10 @@
Copyright © Morten Nielsen 2015-2018
$(MSBuildThisFileDirectory)..\Bin\$(Configuration)
$(OutDir)
- 1.9.0.0
- 1.9.0.0
- Added SystemNmeaDevice to the Android library, which uses the NMEA stream from the system's location provider.
+ 1.10.1.0
+ 1.10.1.0
+ Fixed missing shutdown of Android location device.
+Exposed non-NMEA based Accuracy estimate on Android location device.
diff --git a/src/NmeaParser/SystemNmeaDevice.Android.cs b/src/NmeaParser/SystemNmeaDevice.Android.cs
index 6c7c9aa..5a5e3ca 100644
--- a/src/NmeaParser/SystemNmeaDevice.Android.cs
+++ b/src/NmeaParser/SystemNmeaDevice.Android.cs
@@ -23,13 +23,23 @@ namespace NmeaParser
private LocationManager manager;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public SystemNmeaDevice()
{
manager = Application.Context.GetSystemService(Context.LocationService) as LocationManager;
}
+ ///
+ /// Gets the estimated accuracy of this location, in meters as reported by the system location provider (not NMEA based).
+ /// Returns NaN if no estimate is available or the active location provider isn't GPS (ie IP/WiFi/Network Provider)
+ ///
+ ///
+ /// Normally the **GST messages will provide the estimated accuracy, but this is not always exposed as NMEA
+ /// on Android devices, so this serves as a useful fallback.
+ ///
+ public float Accuracy => listener == null ? float.NaN : listener.Accuracy;
+
///
[Android.Runtime.RequiresPermission("android.permission.ACCESS_FINE_LOCATION")]
protected override Task OpenStreamAsync()
@@ -43,8 +53,7 @@ namespace NmeaParser
listener = new Listener();
listener.NmeaMessage += (s, e) => stream?.Append(e);
bool success = manager.AddNmeaListener(listener);
- manager.RequestLocationUpdates(LocationManager.GpsProvider, 100, .1f, listener );
-
+ manager.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0f, listener );
return Task.FromResult(stream);
}
@@ -81,10 +90,17 @@ namespace NmeaParser
public event EventHandler NmeaMessage;
+ public float Accuracy = float.NaN;
+
void ILocationListener.OnLocationChanged(Location location)
{
+ if (location.Provider != LocationManager.GpsProvider)
+ {
+ Accuracy = float.NaN;
+ return;
+ }
+ Accuracy = location.HasAccuracy ? location.Accuracy : float.NaN;
if (_isNmeaSupported) return;
- if (location.Provider != LocationManager.GpsProvider) return;
// Not all Android devices support reporting NMEA, so we'll fallback to just generating
// simple RMC and GGA message so the provider continues to work across multiple devices
// $GPRMC:
diff --git a/src/SampleApp.Droid/MainActivity.cs b/src/SampleApp.Droid/MainActivity.cs
index 7f77db2..99a4d90 100644
--- a/src/SampleApp.Droid/MainActivity.cs
+++ b/src/SampleApp.Droid/MainActivity.cs
@@ -13,47 +13,148 @@ using NmeaParser.Nmea;
namespace SampleApp.Droid
{
- [Activity(Label = "SampleApp.Droid", MainLauncher = true)]
+ [Activity(Label = "NMEA Parser SampleApp", MainLauncher = true)]
public class MainActivity : Activity
{
+ private Button startButton;
+ private Button stopButton;
+
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
+ startButton = FindViewById
True
@@ -48,9 +48,9 @@
prompt
4
true
- False
+ true
SdkOnly
- True
+ false
diff --git a/src/SampleApp.WinDesktop/MainWindow.xaml b/src/SampleApp.WinDesktop/MainWindow.xaml
index 25e05c2..6b98303 100644
--- a/src/SampleApp.WinDesktop/MainWindow.xaml
+++ b/src/SampleApp.WinDesktop/MainWindow.xaml
@@ -39,7 +39,7 @@
+ GsvMessages="{Binding GsvMessages, ElementName=satView}" />
diff --git a/src/SampleApp.WinDesktop/MainWindow.xaml.cs b/src/SampleApp.WinDesktop/MainWindow.xaml.cs
index 3011c23..2245b97 100644
--- a/src/SampleApp.WinDesktop/MainWindow.xaml.cs
+++ b/src/SampleApp.WinDesktop/MainWindow.xaml.cs
@@ -12,7 +12,8 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
-
+using NmeaParser;
+
namespace SampleApp.WinDesktop
{
///
@@ -66,7 +67,7 @@ namespace SampleApp.WinDesktop
gpgsaView.Message = null;
gpgllView.Message = null;
pgrmeView.Message = null;
- satView.GpgsvMessages = null;
+ satView.GsvMessages = null;
//Start new device
currentDevice = device;
currentDevice.MessageReceived += device_MessageReceived;
@@ -78,9 +79,10 @@ namespace SampleApp.WinDesktop
currentDeviceInfo.Text = string.Format("SerialPortDevice( port={0}, baud={1} )",
((NmeaParser.SerialPortDevice)device).Port.PortName,
((NmeaParser.SerialPortDevice)device).Port.BaudRate);
- }
- }
-
+ }
+ }
+ Dictionary> gsvMessages = new Dictionary>();
+
private void device_MessageReceived(object sender, NmeaParser.NmeaMessageReceivedEventArgs args)
{
Dispatcher.BeginInvoke((Action) delegate()
@@ -90,11 +92,13 @@ namespace SampleApp.WinDesktop
output.Text = string.Join("\n", messages.ToArray());
output.Select(output.Text.Length - 1, 0); //scroll to bottom
- if(args.Message is NmeaParser.Nmea.Gps.Gpgsv)
- {
- var gpgsv = (NmeaParser.Nmea.Gps.Gpgsv)args.Message;
- if(args.IsMultipart && args.MessageParts != null)
- satView.GpgsvMessages = args.MessageParts.OfType();
+ if(args.Message is NmeaParser.Nmea.Gsv gpgsv)
+ {
+ if (args.IsMultipart && args.MessageParts != null)
+ {
+ gsvMessages[args.Message.MessageType] = args.MessageParts.OfType().ToList();
+ satView.GsvMessages = gsvMessages.SelectMany(m=>m.Value);
+ }
}
if (args.Message is NmeaParser.Nmea.Gps.Gprmc)
gprmcView.Message = args.Message as NmeaParser.Nmea.Gps.Gprmc;
diff --git a/src/SampleApp.WinDesktop/SatelliteSnr.xaml.cs b/src/SampleApp.WinDesktop/SatelliteSnr.xaml.cs
index 540a978..4e1b9bd 100644
--- a/src/SampleApp.WinDesktop/SatelliteSnr.xaml.cs
+++ b/src/SampleApp.WinDesktop/SatelliteSnr.xaml.cs
@@ -25,19 +25,19 @@ namespace SampleApp.WinDesktop
InitializeComponent();
}
- public IEnumerable GpgsvMessages
+ public IEnumerable GsvMessages
{
- get { return (IEnumerable)GetValue(GpgsvMessagesProperty); }
- set { SetValue(GpgsvMessagesProperty, value); }
+ get { return (IEnumerable)GetValue(GsvMessagesProperty); }
+ set { SetValue(GsvMessagesProperty, value); }
}
// Using a DependencyProperty as the backing store for GpgsvMessages. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty GpgsvMessagesProperty =
- DependencyProperty.Register("GpgsvMessages", typeof(IEnumerable), typeof(SatelliteSnr), new PropertyMetadata(null, OnGpgsvMessagesChanged));
+ public static readonly DependencyProperty GsvMessagesProperty =
+ DependencyProperty.Register("GsvMessages", typeof(IEnumerable), typeof(SatelliteSnr), new PropertyMetadata(null, OnGpgsvMessagesChanged));
private static void OnGpgsvMessagesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
- var sats = e.NewValue as IEnumerable;
+ var sats = e.NewValue as IEnumerable;
if (sats == null)
(d as SatelliteSnr).satellites.ItemsSource = null;
else
diff --git a/src/SampleApp.WinDesktop/SatelliteView.xaml.cs b/src/SampleApp.WinDesktop/SatelliteView.xaml.cs
index afe5c41..2848b2c 100644
--- a/src/SampleApp.WinDesktop/SatelliteView.xaml.cs
+++ b/src/SampleApp.WinDesktop/SatelliteView.xaml.cs
@@ -27,19 +27,18 @@ namespace SampleApp.WinDesktop
- public IEnumerable GpgsvMessages
+ public IEnumerable GsvMessages
{
- get { return (IEnumerable)GetValue(GpgsvMessagesProperty); }
- set { SetValue(GpgsvMessagesProperty, value); }
+ get { return (IEnumerable)GetValue(GsvMessagesProperty); }
+ set { SetValue(GsvMessagesProperty, value); }
}
- // Using a DependencyProperty as the backing store for GpgsvMessages. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty GpgsvMessagesProperty =
- DependencyProperty.Register("GpgsvMessages", typeof(IEnumerable), typeof(SatelliteView), new PropertyMetadata(null, OnGpgsvMessagesChanged));
+ public static readonly DependencyProperty GsvMessagesProperty =
+ DependencyProperty.Register("GsvMessages", typeof(IEnumerable), typeof(SatelliteView), new PropertyMetadata(null, OnGsvMessagesChanged));
- private static void OnGpgsvMessagesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ private static void OnGsvMessagesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
- var sats = e.NewValue as IEnumerable;
+ var sats = e.NewValue as IEnumerable;
if (sats == null)
(d as SatelliteView).satellites.ItemsSource = null;
else