mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2026-01-20 15:40:16 +01:00
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:
parent
22db351eff
commit
47d419864f
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue