/// <summary> /// Gets the <see cref="SrpError"/> associated with the specified ID <paramref name="value"/>. /// </summary> /// <param name="source"></param> /// <param name="value">ID value to retrieve <see cref="SrpError"/>.</param> /// <returns>The <see cref="SrpError"/> for the specified ID <paramref name="value"/>, /// <see cref="SrpError.UNKNOWN"/> if it does not exist.</returns> public static SrpError Get(this SrpError source, byte value) { var values = Enum.GetValues(typeof(SrpError)).OfType <SrpError>(); if (values.Cast <byte>().Contains(value)) { return((SrpError)value); } return(SrpError.UNKNOWN); }
/// <summary> /// Returns the <see cref="SrpError"/> in string format. /// </summary> /// <param name="source"></param> /// <returns>The <see cref="SrpError"/> in string format.</returns> public static string ToDisplayString(this SrpError source) { return(string.Format("({0}) {1}", HexUtils.ByteArrayToHexString(ByteUtils.IntToByteArray((byte)source)), GetName(source))); }
/// <summary> /// Gets the SRP error name. /// </summary> /// <param name="source"></param> /// <returns>The SRP error name.</returns> public static string GetName(this SrpError source) { return(lookupTable.ContainsKey(source) ? lookupTable[source] : source.ToString()); }
/// <summary> /// Gets the SRP error value. /// </summary> /// <param name="source"></param> /// <returns>The SRP error value.</returns> public static byte GetValue(this SrpError source) { return((byte)source); }
/// <summary> /// Class constructor. Instantiates a <see cref="BluetoothUnlockResponsePacket"/> packet /// with the given parameters. /// </summary> /// <param name="error">SRP error</param> /// <seealso cref="Models.SrpError"/> public BluetoothUnlockResponsePacket(SrpError error) : base(APIFrameType.BLE_UNLOCK_RESPONSE) { SrpError = error; logger = LogManager.GetLogger <BluetoothUnlockResponsePacket>(); }