using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class PinConnectivityInterfaceIdInfo
{
	public static PinConnectivityInterfaceIdEnum ValueToPinConnectivityInterfaceId(uint value)
	{
		switch (value)
		{
		case 0u:
			return PinConnectivityInterfaceIdEnum.HCI_UART_PINS;
		case 1u:
			return PinConnectivityInterfaceIdEnum.SLIMBUS_PINS;
		case 2u:
			return PinConnectivityInterfaceIdEnum.WCI2_PINS;
		case 3u:
			return PinConnectivityInterfaceIdEnum.WSI_PINS;
		case 4u:
			return PinConnectivityInterfaceIdEnum.SENSOR_UART_PINS;
		default:
			if (value >= 5 && value <= 255)
			{
				return PinConnectivityInterfaceIdEnum.RESERVED_FOR_FUTURE_USE;
			}
			return PinConnectivityInterfaceIdEnum.InvalidPinConnectivityInterfaceIdValue;
		}
	}

	public static uint PinConnectivityInterfaceIdToValue(PinConnectivityInterfaceIdEnum enumItem)
	{
		return enumItem switch
		{
			PinConnectivityInterfaceIdEnum.HCI_UART_PINS => 0u, 
			PinConnectivityInterfaceIdEnum.SLIMBUS_PINS => 1u, 
			PinConnectivityInterfaceIdEnum.WCI2_PINS => 2u, 
			PinConnectivityInterfaceIdEnum.WSI_PINS => 3u, 
			PinConnectivityInterfaceIdEnum.SENSOR_UART_PINS => 4u, 
			PinConnectivityInterfaceIdEnum.RESERVED_FOR_FUTURE_USE => 5u, 
			_ => uint.MaxValue, 
		};
	}

	public static string PinConnectivityInterfaceIdToString(PinConnectivityInterfaceIdEnum enumItem)
	{
		return enumItem switch
		{
			PinConnectivityInterfaceIdEnum.HCI_UART_PINS => "HCI_UART_PINS", 
			PinConnectivityInterfaceIdEnum.SLIMBUS_PINS => "SLIMBUS_PINS", 
			PinConnectivityInterfaceIdEnum.WCI2_PINS => "WCI2_PINS", 
			PinConnectivityInterfaceIdEnum.WSI_PINS => "WSI_PINS", 
			PinConnectivityInterfaceIdEnum.SENSOR_UART_PINS => "SENSOR_UART_PINS", 
			PinConnectivityInterfaceIdEnum.RESERVED_FOR_FUTURE_USE => "Reserved for future use", 
			_ => "Invalid PinConnectivityInterfaceId Value", 
		};
	}

	public static string PinConnectivityInterfaceIdToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = HCI_UART_PINS");
		stringBuilder.AppendLine("0x1 = SLIMBUS_PINS");
		stringBuilder.AppendLine("0x2 = WCI2_PINS");
		stringBuilder.AppendLine("0x3 = WSI_PINS");
		stringBuilder.AppendLine("0x4 = SENSOR_UART_PINS");
		stringBuilder.AppendLine("0x5-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
