using System;
using QCRPG.Framework;

namespace QCRPG.TSL.ZigBee.Packets;

public class MlmeDisassociateInfo : PacketInfoBase
{
	public override string Name => "Mlme Disassociate";

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

	public MlmeDisassociateInfo(MlmeDisassociate packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		MlmeDisassociate mlmeDisassociate = (MlmeDisassociate)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("DeviceAddrMode", "The addressing mode of the device to which to send the disassociation notification command.\r\n\r\n" + MlmeDisassociate.UserFieldsWrapper.DeviceaddrmodeInfo.DeviceaddrmodeToDescription(), 8, FormatValue(mlmeDisassociate.UserFields.Deviceaddrmode, 8), MlmeDisassociate.UserFieldsWrapper.DeviceaddrmodeInfo.DeviceaddrmodeToString(MlmeDisassociate.UserFieldsWrapper.DeviceaddrmodeInfo.ValueToDeviceaddrmode(mlmeDisassociate.UserFields.Deviceaddrmode)), "2", "3", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("DevicePANId", "The PAN identifier of the device to which to send the disassociation notification command.", 16, FormatValue(mlmeDisassociate.UserFields.Devicepanid, 16), "", "0000", "0xFFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("DeviceAddress", "The address of the device to which to send the disassociation notification command.", 64, FormatValue(mlmeDisassociate.UserFields.Deviceaddress, 64), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("DisassociateReason", "The reason for the disassociation\r\n\r\n" + MlmeDisassociate.UserFieldsWrapper.DisassociatereasonInfo.DisassociatereasonToDescription(), 8, FormatValue(mlmeDisassociate.UserFields.Disassociatereason, 8), MlmeDisassociate.UserFieldsWrapper.DisassociatereasonInfo.DisassociatereasonToString(MlmeDisassociate.UserFieldsWrapper.DisassociatereasonInfo.ValueToDisassociatereason(mlmeDisassociate.UserFields.Disassociatereason)), "00", "FF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("TxIndirect", "TRUE if the disassociation notification command is to be sent indirectly.\r\n\r\n" + MlmeDisassociate.UserFieldsWrapper.TxindirectInfo.TxindirectToDescription(), 8, FormatValue(mlmeDisassociate.UserFields.Txindirect, 8), MlmeDisassociate.UserFieldsWrapper.TxindirectInfo.TxindirectToString(MlmeDisassociate.UserFieldsWrapper.TxindirectInfo.ValueToTxindirect(mlmeDisassociate.UserFields.Txindirect)), "00", "01", 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(mlmeDisassociate.UserFields.Securitylevel, 8), SecurityLevelOptionsInfo.SecurityLevelOptionsToString(SecurityLevelOptionsInfo.ValueToSecurityLevelOptions(mlmeDisassociate.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(mlmeDisassociate.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(mlmeDisassociate.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(mlmeDisassociate.UserFields.Keyindex, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		MlmeDisassociate mlmeDisassociate = (MlmeDisassociate)packet;
		int num = -1;
		if (index == ++num)
		{
			mlmeDisassociate.UserFields.Deviceaddrmode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeDisassociate.UserFields.Devicepanid = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeDisassociate.UserFields.Deviceaddress = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			mlmeDisassociate.UserFields.Disassociatereason = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeDisassociate.UserFields.Txindirect = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeDisassociate.UserFields.Securitylevel = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeDisassociate.UserFields.Keyidmode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			mlmeDisassociate.UserFields.Keysource = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			mlmeDisassociate.UserFields.Keyindex = Convert.ToUInt32(value, 16);
		}
	}
}
