Detect GN support per-message instead (#79)

* Simplify Android device lookup

* Detect GN support per-message instead.

* add length check
This commit is contained in:
Morten Nielsen 2020-08-31 22:22:27 -07:00 committed by GitHub
parent 22db351eff
commit 47d419864f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -54,7 +54,7 @@ namespace NmeaParser
var adapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter;
if (adapter != null && adapter.IsEnabled)
{
foreach (var b in adapter.BondedDevices.Where(d => d.GetUuids().Where(t => t.Uuid != null && t.Uuid.ToString()!.Equals("00001101-0000-1000-8000-00805F9B34FB", StringComparison.InvariantCultureIgnoreCase)).Any()))
foreach (var b in adapter.BondedDevices.Where(d => d.GetUuids().Any(t => SERIAL_UUID.CompareTo(t.Uuid) == 0)))
yield return b;
}
}

View file

@ -26,7 +26,6 @@ namespace NmeaParser.Gnss
/// </summary>
public class GnssMonitor : INotifyPropertyChanged
{
private bool m_supportGNMessages; // If device detect GN* messages, ignore all other Talker ID
private bool m_supportGGaMessages; //If device support GGA, ignore RMC for location
private Dictionary<string, NmeaMessage> m_allMessages { get; } = new Dictionary<string, NmeaMessage>();
private object m_lock = new object();
@ -81,10 +80,12 @@ namespace NmeaParser.Gnss
m_allMessages[message.MessageType] = message;
}
properties.Add(nameof(AllMessages));
if (message.TalkerId == NmeaParser.Talker.GlobalNavigationSatelliteSystem)
m_supportGNMessages = true; // Support for GN* messages detected
else if (m_supportGNMessages && message.TalkerId != NmeaParser.Talker.GlobalNavigationSatelliteSystem && !(message is Gsv))
return; // If device supports combined GN* messages, ignore non-GN messages, except for Gsv
if(message.TalkerId != NmeaParser.Talker.GlobalNavigationSatelliteSystem && !(message is Gsv) && message.MessageType.Length > 2)
{
// If device supports combined GN*** messages, ignore non-GN messages, except for Gsv
if (m_allMessages.ContainsKey("GN" + message.MessageType.Substring(2)))
return;
}
if (message is NmeaParser.Messages.Garmin.Pgrme rme)
{