From 46fafcbdbac30154c6f4688fe46c7905a35077d3 Mon Sep 17 00:00:00 2001 From: Tim Schneeberger Date: Wed, 7 Aug 2024 18:25:58 +0200 Subject: [PATCH] fix: Buds3/3Pro use GET_ALL_DEBUG for version data --- .../Pages/SystemInfoPageViewModel.cs | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/GalaxyBudsClient/Interface/ViewModels/Pages/SystemInfoPageViewModel.cs b/GalaxyBudsClient/Interface/ViewModels/Pages/SystemInfoPageViewModel.cs index fced85e3..6a3d4fd9 100644 --- a/GalaxyBudsClient/Interface/ViewModels/Pages/SystemInfoPageViewModel.cs +++ b/GalaxyBudsClient/Interface/ViewModels/Pages/SystemInfoPageViewModel.cs @@ -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; @@ -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) @@ -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() @@ -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); } @@ -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;