Skip to content

Commit

Permalink
fix: Buds3/3Pro use GET_ALL_DEBUG for version data
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Aug 7, 2024
1 parent 624fc04 commit 46fafcb
Showing 1 changed file with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GalaxyBudsClient.Interface.Pages;
using GalaxyBudsClient.Message;
using GalaxyBudsClient.Message.Decoder;
using GalaxyBudsClient.Model.Constants;
using GalaxyBudsClient.Model.Specifications;
using GalaxyBudsClient.Platform;
using GalaxyBudsClient.Utils.Interface;
Expand All @@ -29,17 +30,25 @@ public SystemInfoPageViewModel()
Loc.LanguageUpdated += RequestData;
}

private void OnVersionInfoResponse(object? sender, DebugModeVersionDecoder e)
private void OnVersionInfoResponse(object? sender, DebugModeVersionDecoder? e)
{
HwVersion = $"{Strings.Left}: {e.LeftHardwareVersion ?? Unknown}, {Strings.Right}: {e.RightHardwareVersion ?? Unknown}";
SwVersion = $"{Strings.Left}: {e.LeftSoftwareVersion ?? Unknown}, {Strings.Right}: {e.RightSoftwareVersion ?? Unknown}";
TouchSwVersion = $"{Strings.Left}: {e.LeftTouchSoftwareVersion ?? Unknown}, {Strings.Right}: {e.RightTouchSoftwareVersion ?? Unknown}";

if (e is not null)
{
HwVersion =
$"{Strings.Left}: {e.LeftHardwareVersion ?? Unknown}, {Strings.Right}: {e.RightHardwareVersion ?? Unknown}";
SwVersion =
$"{Strings.Left}: {e.LeftSoftwareVersion ?? Unknown}, {Strings.Right}: {e.RightSoftwareVersion ?? Unknown}";
TouchSwVersion =
$"{Strings.Left}: {e.LeftTouchSoftwareVersion ?? Unknown}, {Strings.Right}: {e.RightTouchSoftwareVersion ?? Unknown}";
}

// Fallback to GET_ALL_DATA if the version info is incomplete
if(e is { LeftTouchSoftwareVersion: "0", RightTouchSoftwareVersion: "0" })
if(e is null or { LeftTouchSoftwareVersion: "0", RightTouchSoftwareVersion: "0" })
TouchSwVersion = DeviceMessageCache.Instance.DebugGetAllData?.TouchSoftwareVersion ?? Unknown;
if(e is { LeftHardwareVersion: "rev0.0", RightHardwareVersion: "rev0.0" })
if(e is null or { LeftHardwareVersion: "rev0.0", RightHardwareVersion: "rev0.0" })
HwVersion = DeviceMessageCache.Instance.DebugGetAllData?.HardwareVersion ?? Unknown;
if(e is null || (e.LeftSoftwareVersion?.StartsWith('R') != true && e.RightSoftwareVersion?.StartsWith('R') != true))
SwVersion = DeviceMessageCache.Instance.DebugGetAllData?.SoftwareVersion ?? Unknown;
}

private void OnDebugSerialNumberReceived(object? sender, CradleSerialNumberDecoder e)
Expand Down Expand Up @@ -84,6 +93,12 @@ private void OnGetAllDataResponse(object? sender, DebugGetAllDataDecoder e)
BluetoothAddress = e.LocalBluetoothAddress != null || e.PeerBluetoothAddress != null
? string.Format(Strings.SystemBtaddrTemplate, e.LocalBluetoothAddress ?? Unknown, e.PeerBluetoothAddress ?? Unknown)
: Unknown;

// Buds3 and up don't respond to VERSION_INFO. Force load the info from GET_ALL_DEBUG by passing a null object
if (BluetoothImpl.Instance.CurrentModel >= Models.Buds3)
{
OnVersionInfoResponse(this, null);
}
}

private static async void RequestData()
Expand All @@ -99,7 +114,6 @@ private static async void RequestData()

await BluetoothImpl.Instance.SendRequestAsync(MsgIds.DEBUG_SERIAL_NUMBER);
await BluetoothImpl.Instance.SendRequestAsync(MsgIds.DEBUG_GET_ALL_DATA);
// Buds3 & Buds3 Pro don't support GET_ALL_DATA anymore, so we need to request the version info separately as a backup
await BluetoothImpl.Instance.SendRequestAsync(MsgIds.VERSION_INFO);
}

Expand All @@ -109,7 +123,7 @@ private static async void RequestData()
[Reactive] public string SwVersion { set; get; } = Placeholder;
[Reactive] public string TouchSwVersion { set; get; } = Placeholder;
[Reactive] public string ProtocolVersion { set; get; } = Placeholder;
[Reactive] public string BluetoothAddress { set; get; } = Unknown;
[Reactive] public string BluetoothAddress { set; get; } = Placeholder;
[Reactive] public string SerialNumber { set; get; } = Placeholder;
[Reactive] public string CradleSerialNumber { set; get; } = Placeholder;
[Reactive] public string CradleSwVersion { set; get; } = Placeholder;
Expand Down

0 comments on commit 46fafcb

Please sign in to comment.