{"record":{"id":"77d42d1f153b3a4d","repo":"mgth/LittleBigMouse","slug":"a-wi-fi-mac-address-is-required-for-vidaa-authentication","errorCode":null,"errorMessage":"A Wi-Fi MAC address is required for VIDAA authentication.","messagePattern":"A Wi-Fi MAC address is required for VIDAA authentication\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs","lineNumber":64,"sourceCode":"        null => VidaaAuthMethod.Modern,\n        _ => VidaaAuthMethod.Legacy,\n    };\n\n    public static bool UsesStaticLegacyProtocol(int? protocolVersion)\n        => protocolVersion is > 0 and < 3000;\n\n    public static string LegacyDeviceTopic(string controllerMac)\n        => $\"{NormalizeMac(controllerMac).ToUpperInvariant()}$normal\";\n\n    public static VidaaMqttCredentials GenerateCredentials(\n        string macAddress,\n        VidaaAuthMethod authMethod,\n        long? unixTimeSeconds = null,\n        string brand = \"his\")\n    {\n        var uuid = NormalizeMac(macAddress, preserveCase: true);\n        if (string.IsNullOrWhiteSpace(uuid))\n            throw new ArgumentException(\"A Wi-Fi MAC address is required for VIDAA authentication.\", nameof(macAddress));\n\n        var timestamp = unixTimeSeconds ?? DateTimeOffset.UtcNow.ToUnixTimeSeconds();\n        var raceHash = Md5($\"{DynamicPattern}${uuid}\")[..6];\n        var clientId = $\"{uuid}${brand}${raceHash}_vidaacommon_001\";\n        var usernameTime = authMethod == VidaaAuthMethod.Legacy\n            ? unchecked((ulong)timestamp)\n            : unchecked((ulong)timestamp) ^ TimeXorConstant;\n        var username = $\"{brand}${usernameTime}\";\n        var remainder = timestamp.ToString(CultureInfo.InvariantCulture)\n            .Where(char.IsAsciiDigit)\n            .Sum(c => c - '0') % 10;\n        var suffix = authMethod == VidaaAuthMethod.Modern ? ModernSuffix : LegacySuffix;\n        var valueHash = Md5($\"{brand}{remainder}{suffix}\")[..6];\n        var password = Md5($\"{timestamp}${valueHash}\");\n        return new VidaaMqttCredentials(clientId, username, password);\n    }\n\n    public static HisenseVidaaDevice ParseDescriptor(string ipAddress, string xml)","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/mgth/LittleBigMouse/blob/7a42f01d47d99d223b8ee33ba4019af82adf1c48/LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs#L46-L82","documentation":"VIDAA credential generation (GenerateCredentials) builds the client identity from the device's Wi-Fi MAC address. If the macAddress argument normalizes to null/whitespace, ArgumentException is thrown, because auth (dynamic pattern hash, clientId, username) cannot be derived without it.","triggerScenarios":"Calling GenerateCredentials with an empty/whitespace MAC, or passing a descriptor-derived MAC that was absent (descriptor didn't expose mac/macWifi/macEthernet and the caller passed an empty string).","commonSituations":"Projector descriptor XML omits MAC fields so the caller stored an empty MAC; reading the Ethernet MAC when the auth expects the Wi-Fi MAC; manual config entry left blank.","solutions":["Supply the device's Wi-Fi MAC address (colon/space separated forms accepted after NormalizeMac)","Re-fetch the descriptor and confirm mac/macWifi/macEthernet fields are populated; use macWifi preference","Store the MAC at discovery time so it is available for authentication later","Fetch the MAC from the TV's network settings or router DHCP table if the descriptor lacks it"],"exampleFix":"// before\nvar creds = HisenseVidaaProtocol.GenerateCredentials(device.Mac ?? \"\", method);\n// after\nif (string.IsNullOrWhiteSpace(device.Mac))\n    throw new InvalidOperationException(\"Descriptor had no MAC; re-discover the device.\");\nvar creds = HisenseVidaaProtocol.GenerateCredentials(device.Mac, method);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(device.Mac))\n    throw new InvalidOperationException(\"Descriptor has no MAC; re-discover device.\");","typeGuard":"bool HasMac(HisenseVidaaDevice d) => !string.IsNullOrWhiteSpace(d.Mac);","tryCatchPattern":"try { creds = GenerateCredentials(mac, method); }\ncatch (ArgumentException ex) { /* prompt re-discovery to fetch MAC */ }","preventionTips":["Persist the MAC at discovery time","Prefer macWifi from the descriptor for Wi-Fi auth","Re-discover if descriptor lacked MAC fields","Fall back to router/DHCP lookup for the MAC"],"tags":["authentication","argument","mac-address","hisense-vidaa"],"backgroundTag":"missing-credentials","analyzedSha":"7a42f01d47d99d223b8ee33ba4019af82adf1c48","analyzedAt":"2026-09-16T00:35:00.514Z","contentChangedAt":"2026-09-16T00:35:00.514Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}