using System;
using QCRPG.Framework;

namespace QCRPG.TSL.ZigBee.Packets;

public class MlmeBeaconNotifyIndicationInfo : PacketInfoBase
{
	public override string Name => "Mlme Beacon Notify Indication";

	public override string DisplayGroup => "MLME Indication Packets";

	public MlmeBeaconNotifyIndicationInfo(MlmeBeaconNotifyIndication packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		MlmeBeaconNotifyIndication mlmeBeaconNotifyIndication = (MlmeBeaconNotifyIndication)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("PacketLength", "", 32, FormatValue(mlmeBeaconNotifyIndication.UserFields.Packetlength, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ProtocolID", "ProtocolID\r\n\r\n" + ProtocolIdInfo.ProtocolIdToDescription(), 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Protocolid, 8), ProtocolIdInfo.ProtocolIdToString(ProtocolIdInfo.ValueToProtocolId(mlmeBeaconNotifyIndication.UserFields.Protocolid)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Event Code", CommandOpcodeInfo.CommandOpcodeToDescription(), 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.EventCode, 8), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(mlmeBeaconNotifyIndication.UserFields.EventCode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Length", "Payload Length", 16, FormatValue(mlmeBeaconNotifyIndication.UserFields.Length, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("BNS", "", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Bns, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CoordAddrMode", "The coordinator addressing mode for this primitive and subsequent MPDU\r\n\r\n" + DutaddressmodeInfo.DutaddressmodeToDescription(), 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Coordaddrmode, 8), DutaddressmodeInfo.DutaddressmodeToString(DutaddressmodeInfo.ValueToDutaddressmode(mlmeBeaconNotifyIndication.UserFields.Coordaddrmode)), "2", "3", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CoordPANId", "The identifier of the PAN with which to associate", 16, FormatValue(mlmeBeaconNotifyIndication.UserFields.Coordpanid, 16), "", "0000", "0xFFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CoordAddress", "The address of the coordinator with which to associate", 64, FormatValue(mlmeBeaconNotifyIndication.UserFields.Coordaddress, 64), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LogicalChannel", "The logical channel on which to attempt association", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Logicalchannel, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ChannelPage", "The channel page on which to attempt association", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Channelpage, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SuperframeSpec", "", 16, FormatValue(mlmeBeaconNotifyIndication.UserFields.Superframespec, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("GTSPermit", "", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Gtspermit, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LinkQuality", "", 16, FormatValue(mlmeBeaconNotifyIndication.UserFields.Linkquality, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Timestamp", "", 32, FormatValue(mlmeBeaconNotifyIndication.UserFields.Timestamp, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SecurityFailure", "", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Securityfailure, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SecurityLevel", "The security level to be used\r\n\r\n" + SecurityLevelOptionsInfo.SecurityLevelOptionsToDescription(), 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Securitylevel, 8), SecurityLevelOptionsInfo.SecurityLevelOptionsToString(SecurityLevelOptionsInfo.ValueToSecurityLevelOptions(mlmeBeaconNotifyIndication.UserFields.Securitylevel)), "0", "7", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("KeyIdMode", "The mode used to identify the key to be used. This parameter is ignored if the SecurityLevel parameter is set to 0x00", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Keyidmode, 8), "", "0", "3", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("KeySource", "The originator of the key to be used. This parameter is ignored if the KeyIdMode parameter is ignored or set to 0x00", 64, FormatValue(mlmeBeaconNotifyIndication.UserFields.Keysource, 64), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("KeyIndex", "The index of the key to be used. This parameter is ignored if the KeyIdMode parameter is ignored or set to 0x00", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Keyindex, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PendAddrSpec", "", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Pendaddrspec, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("AddrList", "", mlmeBeaconNotifyIndication.UserFields.AddrlistList.Count * 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.AddrlistList, mlmeBeaconNotifyIndication.UserFields.AddrlistList.Count * 8, includeSpaces: false), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SDULength", "", 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.Sdulength, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SDU", "", mlmeBeaconNotifyIndication.UserFields.SduList.Count * 8, FormatValue(mlmeBeaconNotifyIndication.UserFields.SduList, mlmeBeaconNotifyIndication.UserFields.SduList.Count * 8, includeSpaces: false), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		MlmeBeaconNotifyIndication mlmeBeaconNotifyIndication = (MlmeBeaconNotifyIndication)packet;
		int num = -1;
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Packetlength = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Protocolid = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field EventCode");
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Length = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Bns = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Coordaddrmode = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Coordpanid = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Coordaddress = Convert.ToUInt64(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Logicalchannel = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Channelpage = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Superframespec = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Gtspermit = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Linkquality = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Timestamp = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Securityfailure = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Securitylevel = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Keyidmode = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Keysource = Convert.ToUInt64(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Keyindex = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Pendaddrspec = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, mlmeBeaconNotifyIndication.UserFields.AddrlistList.Count);
			int num2 = 0;
			while (value.Length > 0)
			{
				string value2 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				mlmeBeaconNotifyIndication.UserFields.AddrlistList[num2] = Convert.ToUInt32(value2, 16);
				num2++;
			}
		}
		if (index == ++num)
		{
			mlmeBeaconNotifyIndication.UserFields.Sdulength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, mlmeBeaconNotifyIndication.UserFields.SduList.Count);
			int num3 = 0;
			while (value.Length > 0)
			{
				string value3 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				mlmeBeaconNotifyIndication.UserFields.SduList[num3] = Convert.ToUInt32(value3, 16);
				num3++;
			}
		}
	}
}
