Added Maglink RTK GNSS receiver integration with correct BLE UUIDs and device name filtering (ML-* prefix). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
using FieldLogger.Models;
|
|
|
|
namespace FieldLogger.Services;
|
|
|
|
/// <summary>Persisted app settings: paired device identities, active job, map key.</summary>
|
|
public sealed class SettingsService
|
|
{
|
|
private const string LocatorIdKey = "device.locator.id";
|
|
private const string LocatorNameKey = "device.locator.name";
|
|
private const string RtkIdKey = "device.rtk.id";
|
|
private const string RtkNameKey = "device.rtk.name";
|
|
private const string ActiveJobKey = "job.active.id";
|
|
private const string MapsApiKeyKey = "maps.apikey";
|
|
|
|
public Guid? GetSavedDeviceId(DeviceKind kind)
|
|
{
|
|
var raw = Preferences.Default.Get(IdKey(kind), string.Empty);
|
|
return Guid.TryParse(raw, out var id) ? id : null;
|
|
}
|
|
|
|
public string? GetSavedDeviceName(DeviceKind kind)
|
|
{
|
|
var name = Preferences.Default.Get(NameKey(kind), string.Empty);
|
|
return string.IsNullOrEmpty(name) ? null : name;
|
|
}
|
|
|
|
public void SaveDevice(DeviceKind kind, Guid id, string name)
|
|
{
|
|
Preferences.Default.Set(IdKey(kind), id.ToString());
|
|
Preferences.Default.Set(NameKey(kind), name);
|
|
}
|
|
|
|
public void ClearDevice(DeviceKind kind)
|
|
{
|
|
Preferences.Default.Remove(IdKey(kind));
|
|
Preferences.Default.Remove(NameKey(kind));
|
|
}
|
|
|
|
public int? ActiveJobId
|
|
{
|
|
get
|
|
{
|
|
var id = Preferences.Default.Get(ActiveJobKey, 0);
|
|
return id > 0 ? id : null;
|
|
}
|
|
set => Preferences.Default.Set(ActiveJobKey, value ?? 0);
|
|
}
|
|
|
|
/// <summary>Google Maps JavaScript API key used by the Windows WebView map.</summary>
|
|
public string GoogleMapsApiKey
|
|
{
|
|
get => Preferences.Default.Get(MapsApiKeyKey, string.Empty);
|
|
set => Preferences.Default.Set(MapsApiKeyKey, value);
|
|
}
|
|
|
|
private static string IdKey(DeviceKind kind) => kind == DeviceKind.Locator ? LocatorIdKey : RtkIdKey;
|
|
private static string NameKey(DeviceKind kind) => kind == DeviceKind.Locator ? LocatorNameKey : RtkNameKey;
|
|
}
|