using System;
using System.Collections.Generic;
using System.Text;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetExtendedAdvertisingParameters : PacketBase
{
	public class UserFieldsWrapper
	{
		public class AdvertisingEventPropertiesEnumCollection
		{
			private EnableBitEnum _ConnectableAdvertising;

			private EnableBitEnum _ScannableAdvertising;

			private EnableBitEnum _DirectedAdvertising;

			private EnableBitEnum _HighDutyCycleDirectedConnectableAdvertising;

			private EnableBitEnum _UseLegacyAdvertisingPdus;

			private EnableBitEnum _OmitAdvertiserAddressFromAllPdusAnonymousAdvertising;

			private EnableBitEnum _IncludeTxpowerInTheExtendedHeaderOfTheAdvertisingPdu;

			public EnableBitEnum ConnectableAdvertising
			{
				get
				{
					return _ConnectableAdvertising;
				}
				set
				{
					_ConnectableAdvertising = value;
				}
			}

			public EnableBitEnum ScannableAdvertising
			{
				get
				{
					return _ScannableAdvertising;
				}
				set
				{
					_ScannableAdvertising = value;
				}
			}

			public EnableBitEnum DirectedAdvertising
			{
				get
				{
					return _DirectedAdvertising;
				}
				set
				{
					_DirectedAdvertising = value;
				}
			}

			public EnableBitEnum HighDutyCycleDirectedConnectableAdvertising
			{
				get
				{
					return _HighDutyCycleDirectedConnectableAdvertising;
				}
				set
				{
					_HighDutyCycleDirectedConnectableAdvertising = value;
				}
			}

			public EnableBitEnum UseLegacyAdvertisingPdus
			{
				get
				{
					return _UseLegacyAdvertisingPdus;
				}
				set
				{
					_UseLegacyAdvertisingPdus = value;
				}
			}

			public EnableBitEnum OmitAdvertiserAddressFromAllPdusAnonymousAdvertising
			{
				get
				{
					return _OmitAdvertiserAddressFromAllPdusAnonymousAdvertising;
				}
				set
				{
					_OmitAdvertiserAddressFromAllPdusAnonymousAdvertising = value;
				}
			}

			public EnableBitEnum IncludeTxpowerInTheExtendedHeaderOfTheAdvertisingPdu
			{
				get
				{
					return _IncludeTxpowerInTheExtendedHeaderOfTheAdvertisingPdu;
				}
				set
				{
					_IncludeTxpowerInTheExtendedHeaderOfTheAdvertisingPdu = value;
				}
			}
		}

		public static class AdvertisingEventPropertiesInfo
		{
			public static AdvertisingEventPropertiesEnumCollection ValueToAdvertisingEventProperties(uint value)
			{
				AdvertisingEventPropertiesEnumCollection advertisingEventPropertiesEnumCollection = new AdvertisingEventPropertiesEnumCollection();
				advertisingEventPropertiesEnumCollection.ConnectableAdvertising = EnableBitInfo.ValueToEnableBit(value & 1u);
				advertisingEventPropertiesEnumCollection.ScannableAdvertising = EnableBitInfo.ValueToEnableBit((value & 2) >> 1);
				advertisingEventPropertiesEnumCollection.DirectedAdvertising = EnableBitInfo.ValueToEnableBit((value & 4) >> 2);
				advertisingEventPropertiesEnumCollection.HighDutyCycleDirectedConnectableAdvertising = EnableBitInfo.ValueToEnableBit((value & 8) >> 3);
				advertisingEventPropertiesEnumCollection.UseLegacyAdvertisingPdus = EnableBitInfo.ValueToEnableBit((value & 0x10) >> 4);
				advertisingEventPropertiesEnumCollection.OmitAdvertiserAddressFromAllPdusAnonymousAdvertising = EnableBitInfo.ValueToEnableBit((value & 0x20) >> 5);
				advertisingEventPropertiesEnumCollection.IncludeTxpowerInTheExtendedHeaderOfTheAdvertisingPdu = EnableBitInfo.ValueToEnableBit((value & 0x40) >> 6);
				return advertisingEventPropertiesEnumCollection;
			}

			public static uint AdvertisingEventPropertiesToValue(AdvertisingEventPropertiesEnumCollection enumCollection)
			{
				uint num = 0u;
				num |= EnableBitInfo.EnableBitToValue(enumCollection.ConnectableAdvertising);
				num |= EnableBitInfo.EnableBitToValue(enumCollection.ScannableAdvertising) << 1;
				num |= EnableBitInfo.EnableBitToValue(enumCollection.DirectedAdvertising) << 2;
				num |= EnableBitInfo.EnableBitToValue(enumCollection.HighDutyCycleDirectedConnectableAdvertising) << 3;
				num |= EnableBitInfo.EnableBitToValue(enumCollection.UseLegacyAdvertisingPdus) << 4;
				num |= EnableBitInfo.EnableBitToValue(enumCollection.OmitAdvertiserAddressFromAllPdusAnonymousAdvertising) << 5;
				return num | (EnableBitInfo.EnableBitToValue(enumCollection.IncludeTxpowerInTheExtendedHeaderOfTheAdvertisingPdu) << 6);
			}

			public static string AdvertisingEventPropertiesToString(AdvertisingEventPropertiesEnumCollection enumCollection)
			{
				string text = "";
				text = text + "Connectable advertising: " + EnableBitInfo.EnableBitToString(enumCollection.ConnectableAdvertising) + "\r\n";
				text = text + "Scannable advertising: " + EnableBitInfo.EnableBitToString(enumCollection.ScannableAdvertising) + "\r\n";
				text = text + "Directed advertising: " + EnableBitInfo.EnableBitToString(enumCollection.DirectedAdvertising) + "\r\n";
				text = text + "High Duty Cycle Directed Connectable advertising: " + EnableBitInfo.EnableBitToString(enumCollection.HighDutyCycleDirectedConnectableAdvertising) + "\r\n";
				text = text + "Use legacy advertising PDUs: " + EnableBitInfo.EnableBitToString(enumCollection.UseLegacyAdvertisingPdus) + "\r\n";
				text = text + "Omit advertiser address from all PDUs anonymous advertising: " + EnableBitInfo.EnableBitToString(enumCollection.OmitAdvertiserAddressFromAllPdusAnonymousAdvertising) + "\r\n";
				text = text + "Include TxPower in the extended header of the advertising PDU: " + EnableBitInfo.EnableBitToString(enumCollection.IncludeTxpowerInTheExtendedHeaderOfTheAdvertisingPdu) + "\r\n";
				return text.TrimEnd('\r', '\n');
			}

			public static string AdvertisingEventPropertiesToDescription()
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("Bit 0: Connectable advertising");
				stringBuilder.AppendLine("Bit 1: Scannable advertising");
				stringBuilder.AppendLine("Bit 2: Directed advertising");
				stringBuilder.AppendLine("Bit 3: High Duty Cycle Directed Connectable advertising");
				stringBuilder.AppendLine("Bit 4: Use legacy advertising PDUs");
				stringBuilder.AppendLine("Bit 5: Omit advertiser address from all PDUs anonymous advertising");
				stringBuilder.AppendLine("Bit 6: Include TxPower in the extended header of the advertising PDU");
				stringBuilder.AppendLine("Bits 15-8: Reserved for future use");
				return stringBuilder.ToString();
			}
		}

		public enum PrimaryAdvertisingPhyEnum
		{
			Reserved_for_future_use,
			Primary_advertisement_PHY_is_LE_1M,
			Primary_advertisement_PHY_is_LE_Coded,
			InvalidPrimaryAdvertisingPhyValue
		}

		public static class PrimaryAdvertisingPhyInfo
		{
			public static PrimaryAdvertisingPhyEnum ValueToPrimaryAdvertisingPhy(uint value)
			{
				switch (value)
				{
				case 0u:
					return PrimaryAdvertisingPhyEnum.Reserved_for_future_use;
				case 1u:
					return PrimaryAdvertisingPhyEnum.Primary_advertisement_PHY_is_LE_1M;
				case 2u:
					return PrimaryAdvertisingPhyEnum.Reserved_for_future_use;
				case 3u:
					return PrimaryAdvertisingPhyEnum.Primary_advertisement_PHY_is_LE_Coded;
				default:
					if (value >= 4 && value <= 255)
					{
						return PrimaryAdvertisingPhyEnum.Reserved_for_future_use;
					}
					return PrimaryAdvertisingPhyEnum.InvalidPrimaryAdvertisingPhyValue;
				}
			}

			public static uint PrimaryAdvertisingPhyToValue(PrimaryAdvertisingPhyEnum enumItem)
			{
				switch (enumItem)
				{
				case PrimaryAdvertisingPhyEnum.Reserved_for_future_use:
					return 0u;
				case PrimaryAdvertisingPhyEnum.Primary_advertisement_PHY_is_LE_1M:
					return 1u;
				default:
					switch (enumItem)
					{
					case PrimaryAdvertisingPhyEnum.Reserved_for_future_use:
						return 2u;
					case PrimaryAdvertisingPhyEnum.Primary_advertisement_PHY_is_LE_Coded:
						return 3u;
					default:
						if (enumItem == PrimaryAdvertisingPhyEnum.Reserved_for_future_use)
						{
							return 4u;
						}
						return uint.MaxValue;
					}
				}
			}

			public static string PrimaryAdvertisingPhyToString(PrimaryAdvertisingPhyEnum enumItem)
			{
				switch (enumItem)
				{
				case PrimaryAdvertisingPhyEnum.Reserved_for_future_use:
					return "Reserved for future use";
				case PrimaryAdvertisingPhyEnum.Primary_advertisement_PHY_is_LE_1M:
					return "Primary advertisement PHY is LE 1M";
				default:
					switch (enumItem)
					{
					case PrimaryAdvertisingPhyEnum.Reserved_for_future_use:
						return "Reserved for future use";
					case PrimaryAdvertisingPhyEnum.Primary_advertisement_PHY_is_LE_Coded:
						return "Primary advertisement PHY is LE Coded";
					default:
						if (enumItem == PrimaryAdvertisingPhyEnum.Reserved_for_future_use)
						{
							return "Reserved for future use";
						}
						return "Invalid PrimaryAdvertisingPhy Value";
					}
				}
			}

			public static string PrimaryAdvertisingPhyToDescription()
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("0x0 = Reserved for future use");
				stringBuilder.AppendLine("0x1 = Primary advertisement PHY is LE 1M");
				stringBuilder.AppendLine("0x2 = Reserved for future use");
				stringBuilder.AppendLine("0x3 = Primary advertisement PHY is LE Coded");
				stringBuilder.AppendLine("0x4-0xFF = Reserved for future use");
				return stringBuilder.ToString();
			}
		}

		public enum SecondaryAdvertisingMaxSkipEnum
		{
			AUX_ADV_IND_shall_be_sent_prior_to_the_next_advertising_event,
			Maximum_advertising_events_the_Controller_can_skip_before_sending_the_AUX_ADV_IND_packets_on_the_secondary_advertising_channel,
			InvalidSecondaryAdvertisingMaxSkipValue
		}

		public static class SecondaryAdvertisingMaxSkipInfo
		{
			public static SecondaryAdvertisingMaxSkipEnum ValueToSecondaryAdvertisingMaxSkip(uint value)
			{
				if (value == 0)
				{
					return SecondaryAdvertisingMaxSkipEnum.AUX_ADV_IND_shall_be_sent_prior_to_the_next_advertising_event;
				}
				if (value >= 1 && value <= 255)
				{
					return SecondaryAdvertisingMaxSkipEnum.Maximum_advertising_events_the_Controller_can_skip_before_sending_the_AUX_ADV_IND_packets_on_the_secondary_advertising_channel;
				}
				return SecondaryAdvertisingMaxSkipEnum.InvalidSecondaryAdvertisingMaxSkipValue;
			}

			public static uint SecondaryAdvertisingMaxSkipToValue(SecondaryAdvertisingMaxSkipEnum enumItem)
			{
				return enumItem switch
				{
					SecondaryAdvertisingMaxSkipEnum.AUX_ADV_IND_shall_be_sent_prior_to_the_next_advertising_event => 0u, 
					SecondaryAdvertisingMaxSkipEnum.Maximum_advertising_events_the_Controller_can_skip_before_sending_the_AUX_ADV_IND_packets_on_the_secondary_advertising_channel => 1u, 
					_ => uint.MaxValue, 
				};
			}

			public static string SecondaryAdvertisingMaxSkipToString(SecondaryAdvertisingMaxSkipEnum enumItem)
			{
				return enumItem switch
				{
					SecondaryAdvertisingMaxSkipEnum.AUX_ADV_IND_shall_be_sent_prior_to_the_next_advertising_event => "AUX_ADV_IND shall be sent prior to the next advertising event.", 
					SecondaryAdvertisingMaxSkipEnum.Maximum_advertising_events_the_Controller_can_skip_before_sending_the_AUX_ADV_IND_packets_on_the_secondary_advertising_channel => "Maximum advertising events the Controller can skip before sending the AUX_ADV_IND packets on the secondary advertising channel.", 
					_ => "Invalid SecondaryAdvertisingMaxSkip Value", 
				};
			}

			public static string SecondaryAdvertisingMaxSkipToDescription()
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("0x0 = AUX_ADV_IND shall be sent prior to the next advertising event.");
				stringBuilder.AppendLine("0x1-0xFF = Maximum advertising events the Controller can skip before sending the AUX_ADV_IND packets on the secondary advertising channel.");
				return stringBuilder.ToString();
			}
		}

		public enum SecondaryAdvertisingPhyEnum
		{
			Reserved_for_future_use,
			Secondary_advertisement_PHY_is_LE_1M,
			Secondary_advertisement_PHY_is_LE_2M,
			Secondary_advertisement_PHY_is_LE_Coded,
			InvalidSecondaryAdvertisingPhyValue
		}

		public static class SecondaryAdvertisingPhyInfo
		{
			public static SecondaryAdvertisingPhyEnum ValueToSecondaryAdvertisingPhy(uint value)
			{
				switch (value)
				{
				case 0u:
					return SecondaryAdvertisingPhyEnum.Reserved_for_future_use;
				case 1u:
					return SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_1M;
				case 2u:
					return SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_2M;
				case 3u:
					return SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_Coded;
				default:
					if (value >= 4 && value <= 255)
					{
						return SecondaryAdvertisingPhyEnum.Reserved_for_future_use;
					}
					return SecondaryAdvertisingPhyEnum.InvalidSecondaryAdvertisingPhyValue;
				}
			}

			public static uint SecondaryAdvertisingPhyToValue(SecondaryAdvertisingPhyEnum enumItem)
			{
				switch (enumItem)
				{
				case SecondaryAdvertisingPhyEnum.Reserved_for_future_use:
					return 0u;
				case SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_1M:
					return 1u;
				case SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_2M:
					return 2u;
				case SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_Coded:
					return 3u;
				default:
					if (enumItem == SecondaryAdvertisingPhyEnum.Reserved_for_future_use)
					{
						return 4u;
					}
					return uint.MaxValue;
				}
			}

			public static string SecondaryAdvertisingPhyToString(SecondaryAdvertisingPhyEnum enumItem)
			{
				switch (enumItem)
				{
				case SecondaryAdvertisingPhyEnum.Reserved_for_future_use:
					return "Reserved for future use";
				case SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_1M:
					return "Secondary advertisement PHY is LE 1M";
				case SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_2M:
					return "Secondary advertisement PHY is LE 2M";
				case SecondaryAdvertisingPhyEnum.Secondary_advertisement_PHY_is_LE_Coded:
					return "Secondary advertisement PHY is LE Coded";
				default:
					if (enumItem == SecondaryAdvertisingPhyEnum.Reserved_for_future_use)
					{
						return "Reserved for future use";
					}
					return "Invalid SecondaryAdvertisingPhy Value";
				}
			}

			public static string SecondaryAdvertisingPhyToDescription()
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("0x0 = Reserved for future use");
				stringBuilder.AppendLine("0x1 = Secondary advertisement PHY is LE 1M");
				stringBuilder.AppendLine("0x2 = Secondary advertisement PHY is LE 2M");
				stringBuilder.AppendLine("0x3 = Secondary advertisement PHY is LE Coded");
				stringBuilder.AppendLine("0x4-0xFF = Reserved for future use");
				return stringBuilder.ToString();
			}
		}

		public enum ScanRequestNotificationEnableEnum
		{
			Scan_request_notifications_disabled,
			Scan_request_notifications_enabled,
			Reserved_for_future_use,
			InvalidScanRequestNotificationEnableValue
		}

		public static class ScanRequestNotificationEnableInfo
		{
			public static ScanRequestNotificationEnableEnum ValueToScanRequestNotificationEnable(uint value)
			{
				switch (value)
				{
				case 0u:
					return ScanRequestNotificationEnableEnum.Scan_request_notifications_disabled;
				case 1u:
					return ScanRequestNotificationEnableEnum.Scan_request_notifications_enabled;
				default:
					if (value >= 2 && value <= 255)
					{
						return ScanRequestNotificationEnableEnum.Reserved_for_future_use;
					}
					return ScanRequestNotificationEnableEnum.InvalidScanRequestNotificationEnableValue;
				}
			}

			public static uint ScanRequestNotificationEnableToValue(ScanRequestNotificationEnableEnum enumItem)
			{
				return enumItem switch
				{
					ScanRequestNotificationEnableEnum.Scan_request_notifications_disabled => 0u, 
					ScanRequestNotificationEnableEnum.Scan_request_notifications_enabled => 1u, 
					ScanRequestNotificationEnableEnum.Reserved_for_future_use => 2u, 
					_ => uint.MaxValue, 
				};
			}

			public static string ScanRequestNotificationEnableToString(ScanRequestNotificationEnableEnum enumItem)
			{
				return enumItem switch
				{
					ScanRequestNotificationEnableEnum.Scan_request_notifications_disabled => "Scan request notifications disabled (default)", 
					ScanRequestNotificationEnableEnum.Scan_request_notifications_enabled => "Scan request notifications enabled", 
					ScanRequestNotificationEnableEnum.Reserved_for_future_use => "Reserved for future use", 
					_ => "Invalid ScanRequestNotificationEnable Value", 
				};
			}

			public static string ScanRequestNotificationEnableToDescription()
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("0x0 = Scan request notifications disabled (default)");
				stringBuilder.AppendLine("0x1 = Scan request notifications enabled");
				stringBuilder.AppendLine("0x2-0xFF = Reserved for future use");
				return stringBuilder.ToString();
			}
		}

		private uint _AdvertisingHandle;

		private uint _AdvertisingEventProperties;

		private uint _PrimaryAdvertisingIntervalMin = 32u;

		private uint _PrimaryAdvertisingIntervalMax = 32u;

		private uint _PrimaryAdvertisingChannelMap;

		private uint _OwnAddressType;

		private uint _PeerAddressType;

		private ulong _PeerAddress;

		private uint _AdvertisingFilterPolicy;

		private uint _AdvertisingTxPower;

		private uint _PrimaryAdvertisingPhy;

		private uint _SecondaryAdvertisingMaxSkip;

		private uint _SecondaryAdvertisingPhy;

		private uint _AdvertisingSid;

		private uint _ScanRequestNotificationEnable;

		public uint AdvertisingHandle
		{
			get
			{
				return _AdvertisingHandle;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for AdvertisingHandle is 0xFF");
				}
				_AdvertisingHandle = value;
			}
		}

		public uint AdvertisingEventProperties
		{
			get
			{
				return _AdvertisingEventProperties;
			}
			set
			{
				if (value > 65535)
				{
					throw new Exception("Maximum possible value for AdvertisingEventProperties is 0xFFFF");
				}
				_AdvertisingEventProperties = value;
			}
		}

		public uint PrimaryAdvertisingIntervalMin
		{
			get
			{
				return _PrimaryAdvertisingIntervalMin;
			}
			set
			{
				if (value > 16777215)
				{
					throw new Exception("Maximum possible value for PrimaryAdvertisingIntervalMin is 0xFFFFFF");
				}
				_PrimaryAdvertisingIntervalMin = value;
			}
		}

		public uint PrimaryAdvertisingIntervalMax
		{
			get
			{
				return _PrimaryAdvertisingIntervalMax;
			}
			set
			{
				if (value > 16777215)
				{
					throw new Exception("Maximum possible value for PrimaryAdvertisingIntervalMax is 0xFFFFFF");
				}
				_PrimaryAdvertisingIntervalMax = value;
			}
		}

		public uint PrimaryAdvertisingChannelMap
		{
			get
			{
				return _PrimaryAdvertisingChannelMap;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for PrimaryAdvertisingChannelMap is 0xFF");
				}
				_PrimaryAdvertisingChannelMap = value;
			}
		}

		public uint OwnAddressType
		{
			get
			{
				return _OwnAddressType;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for OwnAddressType is 0xFF");
				}
				_OwnAddressType = value;
			}
		}

		public uint PeerAddressType
		{
			get
			{
				return _PeerAddressType;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for PeerAddressType is 0xFF");
				}
				_PeerAddressType = value;
			}
		}

		public ulong PeerAddress
		{
			get
			{
				return _PeerAddress;
			}
			set
			{
				_PeerAddress = value;
			}
		}

		public uint AdvertisingFilterPolicy
		{
			get
			{
				return _AdvertisingFilterPolicy;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for AdvertisingFilterPolicy is 0xFF");
				}
				_AdvertisingFilterPolicy = value;
			}
		}

		public uint AdvertisingTxPower
		{
			get
			{
				return _AdvertisingTxPower;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for AdvertisingTxPower is 0xFF");
				}
				_AdvertisingTxPower = value;
			}
		}

		public uint PrimaryAdvertisingPhy
		{
			get
			{
				return _PrimaryAdvertisingPhy;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for PrimaryAdvertisingPhy is 0xFF");
				}
				_PrimaryAdvertisingPhy = value;
			}
		}

		public uint SecondaryAdvertisingMaxSkip
		{
			get
			{
				return _SecondaryAdvertisingMaxSkip;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for SecondaryAdvertisingMaxSkip is 0xFF");
				}
				_SecondaryAdvertisingMaxSkip = value;
			}
		}

		public uint SecondaryAdvertisingPhy
		{
			get
			{
				return _SecondaryAdvertisingPhy;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for SecondaryAdvertisingPhy is 0xFF");
				}
				_SecondaryAdvertisingPhy = value;
			}
		}

		public uint AdvertisingSid
		{
			get
			{
				return _AdvertisingSid;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for AdvertisingSid is 0xFF");
				}
				_AdvertisingSid = value;
			}
		}

		public uint ScanRequestNotificationEnable
		{
			get
			{
				return _ScanRequestNotificationEnable;
			}
			set
			{
				if (value > 255)
				{
					throw new Exception("Maximum possible value for ScanRequestNotificationEnable is 0xFF");
				}
				_ScanRequestNotificationEnable = value;
			}
		}

		public AdvertisingEventPropertiesEnumCollection GetAdvertisingEventPropertiesAsAdvertisingEventPropertiesEnumCollection()
		{
			return AdvertisingEventPropertiesInfo.ValueToAdvertisingEventProperties(_AdvertisingEventProperties);
		}

		public void SetAdvertisingEventPropertiesAsAdvertisingEventPropertiesEnumCollection(AdvertisingEventPropertiesEnumCollection enumCollection)
		{
			AdvertisingEventProperties = AdvertisingEventPropertiesInfo.AdvertisingEventPropertiesToValue(enumCollection);
		}

		public ExtAdvIntervalEnum GetPrimaryAdvertisingIntervalMinAsExtAdvIntervalEnum()
		{
			return ExtAdvIntervalInfo.ValueToExtAdvInterval(_PrimaryAdvertisingIntervalMin);
		}

		public void SetPrimaryAdvertisingIntervalMinAsExtAdvIntervalEnum(ExtAdvIntervalEnum enumItem)
		{
			PrimaryAdvertisingIntervalMin = ExtAdvIntervalInfo.ExtAdvIntervalToValue(enumItem);
		}

		public ExtAdvIntervalEnum GetPrimaryAdvertisingIntervalMaxAsExtAdvIntervalEnum()
		{
			return ExtAdvIntervalInfo.ValueToExtAdvInterval(_PrimaryAdvertisingIntervalMax);
		}

		public void SetPrimaryAdvertisingIntervalMaxAsExtAdvIntervalEnum(ExtAdvIntervalEnum enumItem)
		{
			PrimaryAdvertisingIntervalMax = ExtAdvIntervalInfo.ExtAdvIntervalToValue(enumItem);
		}

		public AdvertisingChannelMapEnumCollection GetPrimaryAdvertisingChannelMapAsAdvertisingChannelMapEnumCollection()
		{
			return AdvertisingChannelMapInfo.ValueToAdvertisingChannelMap(_PrimaryAdvertisingChannelMap);
		}

		public void SetPrimaryAdvertisingChannelMapAsAdvertisingChannelMapEnumCollection(AdvertisingChannelMapEnumCollection enumCollection)
		{
			PrimaryAdvertisingChannelMap = AdvertisingChannelMapInfo.AdvertisingChannelMapToValue(enumCollection);
		}

		public ExtendedAdvertisingOwnAddressTypeEnum GetOwnAddressTypeAsExtendedAdvertisingOwnAddressTypeEnum()
		{
			return ExtendedAdvertisingOwnAddressTypeInfo.ValueToExtendedAdvertisingOwnAddressType(_OwnAddressType);
		}

		public void SetOwnAddressTypeAsExtendedAdvertisingOwnAddressTypeEnum(ExtendedAdvertisingOwnAddressTypeEnum enumItem)
		{
			OwnAddressType = ExtendedAdvertisingOwnAddressTypeInfo.ExtendedAdvertisingOwnAddressTypeToValue(enumItem);
		}

		public PeerAddressTypeEnum GetPeerAddressTypeAsPeerAddressTypeEnum()
		{
			return PeerAddressTypeInfo.ValueToPeerAddressType(_PeerAddressType);
		}

		public void SetPeerAddressTypeAsPeerAddressTypeEnum(PeerAddressTypeEnum enumItem)
		{
			PeerAddressType = PeerAddressTypeInfo.PeerAddressTypeToValue(enumItem);
		}

		public AdvertisingFilterPolicyEnum GetAdvertisingFilterPolicyAsAdvertisingFilterPolicyEnum()
		{
			return AdvertisingFilterPolicyInfo.ValueToAdvertisingFilterPolicy(_AdvertisingFilterPolicy);
		}

		public void SetAdvertisingFilterPolicyAsAdvertisingFilterPolicyEnum(AdvertisingFilterPolicyEnum enumItem)
		{
			AdvertisingFilterPolicy = AdvertisingFilterPolicyInfo.AdvertisingFilterPolicyToValue(enumItem);
		}

		public ExtendedAdvertisingTxPowerEnum GetAdvertisingTxPowerAsExtendedAdvertisingTxPowerEnum()
		{
			return ExtendedAdvertisingTxPowerInfo.ValueToExtendedAdvertisingTxPower(_AdvertisingTxPower);
		}

		public void SetAdvertisingTxPowerAsExtendedAdvertisingTxPowerEnum(ExtendedAdvertisingTxPowerEnum enumItem)
		{
			AdvertisingTxPower = ExtendedAdvertisingTxPowerInfo.ExtendedAdvertisingTxPowerToValue(enumItem);
		}

		public PrimaryAdvertisingPhyEnum GetPrimaryAdvertisingPhyAsPrimaryAdvertisingPhyEnum()
		{
			return PrimaryAdvertisingPhyInfo.ValueToPrimaryAdvertisingPhy(_PrimaryAdvertisingPhy);
		}

		public void SetPrimaryAdvertisingPhyAsPrimaryAdvertisingPhyEnum(PrimaryAdvertisingPhyEnum enumItem)
		{
			PrimaryAdvertisingPhy = PrimaryAdvertisingPhyInfo.PrimaryAdvertisingPhyToValue(enumItem);
		}

		public SecondaryAdvertisingMaxSkipEnum GetSecondaryAdvertisingMaxSkipAsSecondaryAdvertisingMaxSkipEnum()
		{
			return SecondaryAdvertisingMaxSkipInfo.ValueToSecondaryAdvertisingMaxSkip(_SecondaryAdvertisingMaxSkip);
		}

		public void SetSecondaryAdvertisingMaxSkipAsSecondaryAdvertisingMaxSkipEnum(SecondaryAdvertisingMaxSkipEnum enumItem)
		{
			SecondaryAdvertisingMaxSkip = SecondaryAdvertisingMaxSkipInfo.SecondaryAdvertisingMaxSkipToValue(enumItem);
		}

		public SecondaryAdvertisingPhyEnum GetSecondaryAdvertisingPhyAsSecondaryAdvertisingPhyEnum()
		{
			return SecondaryAdvertisingPhyInfo.ValueToSecondaryAdvertisingPhy(_SecondaryAdvertisingPhy);
		}

		public void SetSecondaryAdvertisingPhyAsSecondaryAdvertisingPhyEnum(SecondaryAdvertisingPhyEnum enumItem)
		{
			SecondaryAdvertisingPhy = SecondaryAdvertisingPhyInfo.SecondaryAdvertisingPhyToValue(enumItem);
		}

		public AdvertisingSidEnum GetAdvertisingSidAsAdvertisingSidEnum()
		{
			return AdvertisingSidInfo.ValueToAdvertisingSid(_AdvertisingSid);
		}

		public void SetAdvertisingSidAsAdvertisingSidEnum(AdvertisingSidEnum enumItem)
		{
			AdvertisingSid = AdvertisingSidInfo.AdvertisingSidToValue(enumItem);
		}

		public ScanRequestNotificationEnableEnum GetScanRequestNotificationEnableAsScanRequestNotificationEnableEnum()
		{
			return ScanRequestNotificationEnableInfo.ValueToScanRequestNotificationEnable(_ScanRequestNotificationEnable);
		}

		public void SetScanRequestNotificationEnableAsScanRequestNotificationEnableEnum(ScanRequestNotificationEnableEnum enumItem)
		{
			ScanRequestNotificationEnable = ScanRequestNotificationEnableInfo.ScanRequestNotificationEnableToValue(enumItem);
		}
	}

	private const uint _Opcode = 8246u;

	private Type[] expectedResponseTypes = new Type[1] { typeof(CommandCompleteForLeSetExtendedAdvertisingParameters) };

	private PacketInfoBase info;

	private uint _PayloadLength;

	public UserFieldsWrapper _UserFields = new UserFieldsWrapper();

	public override PacketType Type => PacketType.Command;

	public override Type[] ExpectedResponseTypes => expectedResponseTypes;

	public override PacketInfoBase Info
	{
		get
		{
			if (info == null)
			{
				info = new LeSetExtendedAdvertisingParametersInfo(this);
			}
			return info;
		}
	}

	public uint Opcode => 8246u;

	public uint PayloadLength
	{
		get
		{
			ToBitString();
			return _PayloadLength;
		}
	}

	public UserFieldsWrapper UserFields => _UserFields;

	public override void SetDefaultValues()
	{
		UserFields.AdvertisingHandle = 0u;
		UserFields.PrimaryAdvertisingIntervalMin = 32u;
		UserFields.PrimaryAdvertisingIntervalMax = 32u;
		UserFields.PrimaryAdvertisingChannelMap = 7u;
		UserFields.PrimaryAdvertisingPhy = 1u;
		UserFields.SecondaryAdvertisingPhy = 1u;
	}

	protected override bool FromBitBuilder(ref BitBuilder bitBuilder)
	{
		if (bitBuilder.RemoveBitsAsUintLittleEndian(16) != Opcode)
		{
			return false;
		}
		_PayloadLength = bitBuilder.RemoveBitsAsUint(8);
		int numberOfBits = bitBuilder.GetNumberOfBits();
		if (numberOfBits > _PayloadLength * 8 + 7)
		{
			return false;
		}
		if (numberOfBits < _PayloadLength * 8)
		{
			return false;
		}
		UserFields.AdvertisingHandle = bitBuilder.RemoveBitsAsUint(8);
		UserFields.AdvertisingEventProperties = bitBuilder.RemoveBitsAsUintLittleEndian(16);
		UserFields.PrimaryAdvertisingIntervalMin = bitBuilder.RemoveBitsAsUintLittleEndian(24);
		UserFields.PrimaryAdvertisingIntervalMax = bitBuilder.RemoveBitsAsUintLittleEndian(24);
		UserFields.PrimaryAdvertisingChannelMap = bitBuilder.RemoveBitsAsUint(8);
		UserFields.OwnAddressType = bitBuilder.RemoveBitsAsUint(8);
		UserFields.PeerAddressType = bitBuilder.RemoveBitsAsUint(8);
		UserFields.PeerAddress = bitBuilder.RemoveBitsAsUlongLittleEndian(48);
		UserFields.AdvertisingFilterPolicy = bitBuilder.RemoveBitsAsUint(8);
		UserFields.AdvertisingTxPower = bitBuilder.RemoveBitsAsUint(8);
		UserFields.PrimaryAdvertisingPhy = bitBuilder.RemoveBitsAsUint(8);
		UserFields.SecondaryAdvertisingMaxSkip = bitBuilder.RemoveBitsAsUint(8);
		UserFields.SecondaryAdvertisingPhy = bitBuilder.RemoveBitsAsUint(8);
		UserFields.AdvertisingSid = bitBuilder.RemoveBitsAsUint(8);
		UserFields.ScanRequestNotificationEnable = bitBuilder.RemoveBitsAsUint(8);
		if (bitBuilder.GetNumberOfBits() > 7)
		{
			return false;
		}
		return true;
	}

	public override string ToBitString()
	{
		BitBuilder bitBuilder = new BitBuilder();
		bitBuilder.AddBitsAsUintLittleEndian(Opcode, 16);
		int numberOfBits = bitBuilder.GetNumberOfBits();
		bitBuilder.AddBitsAsUint(0u, 8);
		bitBuilder.AddBitsAsUint(UserFields.AdvertisingHandle, 8);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.AdvertisingEventProperties, 16);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.PrimaryAdvertisingIntervalMin, 24);
		bitBuilder.AddBitsAsUintLittleEndian(UserFields.PrimaryAdvertisingIntervalMax, 24);
		bitBuilder.AddBitsAsUint(UserFields.PrimaryAdvertisingChannelMap, 8);
		bitBuilder.AddBitsAsUint(UserFields.OwnAddressType, 8);
		bitBuilder.AddBitsAsUint(UserFields.PeerAddressType, 8);
		bitBuilder.AddBitsAsUlongLittleEndian(UserFields.PeerAddress, 48);
		bitBuilder.AddBitsAsUint(UserFields.AdvertisingFilterPolicy, 8);
		bitBuilder.AddBitsAsUint(UserFields.AdvertisingTxPower, 8);
		bitBuilder.AddBitsAsUint(UserFields.PrimaryAdvertisingPhy, 8);
		bitBuilder.AddBitsAsUint(UserFields.SecondaryAdvertisingMaxSkip, 8);
		bitBuilder.AddBitsAsUint(UserFields.SecondaryAdvertisingPhy, 8);
		bitBuilder.AddBitsAsUint(UserFields.AdvertisingSid, 8);
		bitBuilder.AddBitsAsUint(UserFields.ScanRequestNotificationEnable, 8);
		_PayloadLength = (uint)((bitBuilder.GetNumberOfBits() - numberOfBits - 8) / 8);
		if ((bitBuilder.GetNumberOfBits() - numberOfBits - 8) % 8 != 0)
		{
			_PayloadLength++;
		}
		bitBuilder.ChangeBitsAsUint(numberOfBits, _PayloadLength, 8);
		return bitBuilder.ToString();
	}

	public override List<string> GetWarnings()
	{
		List<string> list = new List<string>();
		if (UserFields.AdvertisingHandle < 0)
		{
			list.Add("Minimum allowed value for Advertising_Handle is 0x0");
		}
		if (UserFields.AdvertisingHandle > 239)
		{
			list.Add("Maximum allowed value for Advertising_Handle is 0xEF");
		}
		if (UserFields.PrimaryAdvertisingIntervalMin < 32)
		{
			list.Add("Minimum allowed value for Primary_Advertising_Interval_Min is 0x20");
		}
		if (UserFields.PrimaryAdvertisingIntervalMin > 16777215)
		{
			list.Add("Maximum allowed value for Primary_Advertising_Interval_Min is 0xFFFFFF");
		}
		if (UserFields.PrimaryAdvertisingIntervalMax < 32)
		{
			list.Add("Minimum allowed value for Primary_Advertising_Interval_Max is 0x20");
		}
		if (UserFields.PrimaryAdvertisingIntervalMax > 16777215)
		{
			list.Add("Maximum allowed value for Primary_Advertising_Interval_Max is 0xFFFFFF");
		}
		return list;
	}
}
