/// <summary> /// Show button to show advertisements in store (true), after death (false) /// </summary> /// <param name="shop"></param> public void Display(AdvertisingType type) { switch (type) { case AdvertisingType.CoinReward: if (PlayerPrefs.GetInt(Keys.CountRewardAdvertising) < 4) { gameObject.SetActive(Advertisement.IsReady(Keys.ID.PlacementReward)); } else { gameObject.SetActive(false); } break; case AdvertisingType.ContinueReward: if (PlayerPrefs.HasKey(Keys.ContinuedAdvertising)) { gameObject.SetActive(false); } else { gameObject.SetActive(Advertisement.IsReady(Keys.ID.PlacementReward)); } break; } }
internal BlePeripheral(AdvertisingType type, Guid guid, Byte[] address, Boolean?addressIsRandom, IEnumerable <AdvertisingDataItem> advertising, Int32 rssi) : base(guid, address, addressIsRandom) { Type = type; //Advertisement = new BleAdvertisement(); Rssi = rssi; }
/// <summary> /// Set the advertising parameters /// The Advertising_Interval_Min and Advertising_Interval_Max shall not be set to less than 0x00A0 (100 ms) if the Advertising_Type is set to 0x02 (ADV_SCAN_IND) or 0x03 (ADV_NONCONN_IND). /// The Host shall not issue this command when advertising is enabled in the Controller; if it is the Command Disallowed error code shall be used. /// </summary> /// <param name="minimumAdvertisingIntervalInMs">Minimum advertising interval for undirected and low duty cycle directed advertising. Ranges from 20 ms to 10.24 sec. Defaults to 1.28 sec.</param> /// <param name="maximumAdvertisingIntervalInMs">Maximum advertising interval for undirected and low duty cycle directed advertising. Ranges from 20 ms to 10.24 sec. Defaults to 1.28 sec.</param> /// <param name="advertisingType">Used to determine the packet type that is used for advertising when advertising is enabled.</param> /// <param name="ownAdressType">This parameter indicates the type of address being used in the advertising packets.</param> /// <param name="peerAdressType">This parameter contains the Peer’s Identity Type.</param> /// <param name="peerAddress">This parameter contains the peer’s Identity Address.</param> /// <param name="advertisingChannelMap">This is a bit field that indicates the advertising channels that shall be used when transmitting advertising packets.At least one channel bit shall be set in the Advertising_Channel_Map parameter.</param> /// <param name="advertisingFilterPolicy">This parameter shall be ignored when directed advertising is enabled.</param> public LeSetAdvertisingParametersCommand( int minimumAdvertisingIntervalInMs, int maximumAdvertisingIntervalInMs, AdvertisingType advertisingType, OwnAddressType ownAdressType, PeerAddressType peerAdressType, byte[] peerAddress, AdvertisingChannelMap advertisingChannelMap, AdvertisingFilterPolicy advertisingFilterPolicy) : base(OpcodeGroup.LeController, (int)LeControllerOpcode.SetAdvertisingParameters) { if (peerAddress == null) { throw new ArgumentNullException("peerAddress"); } if (peerAddress.Length != 6) { throw new ArgumentOutOfRangeException("peerAddress", "The peer address should consist of exactly 6 bytes."); } ushort minimumAdvertisingIntervalCode = (ushort)Math.Ceiling(minimumAdvertisingIntervalInMs / 0.625); ushort maximumAdvertisingIntervalCode = (ushort)Math.Ceiling(maximumAdvertisingIntervalInMs / 0.625); if (advertisingType != AdvertisingType.ConnectableHighDutyCycleDirected) { if (minimumAdvertisingIntervalCode > 0x4000) { throw new ArgumentOutOfRangeException("minimumAdvertisingIntervalCode", "Interval too long, should be less than 10240 ms"); } if (maximumAdvertisingIntervalCode > 0x4000) { throw new ArgumentOutOfRangeException("maximumAdvertisingIntervalCode", "Interval too long, should be less than 10240 ms"); } if (advertisingType == AdvertisingType.ScannableUndirectedAdvertising || advertisingType == AdvertisingType.NonConnectableUndirected) { if (minimumAdvertisingIntervalCode < 0x00A0) { throw new ArgumentOutOfRangeException("minimumAdvertisingIntervalCode", "Interval too short, should not be less than 100 ms"); } if (maximumAdvertisingIntervalCode < 0x00A0) { throw new ArgumentOutOfRangeException("maximumAdvertisingIntervalCode", "Interval too short, should not be less than 100 ms"); } } else { if (minimumAdvertisingIntervalCode < 0x0020) { throw new ArgumentOutOfRangeException("minimumAdvertisingIntervalCode", "Interval too short, should be more than 20 ms"); } if (maximumAdvertisingIntervalCode < 0x0020) { throw new ArgumentOutOfRangeException("maximumAdvertisingIntervalCode", "Interval too short, should be more than 20 ms"); } } } Parameters.Add(new UshortCommandParameter(minimumAdvertisingIntervalCode)); Parameters.Add(new UshortCommandParameter(maximumAdvertisingIntervalCode)); Parameters.Add(new ByteCommandParameter((byte)advertisingType)); Parameters.Add(new ByteCommandParameter((byte)ownAdressType)); Parameters.Add(new ByteCommandParameter((byte)peerAdressType)); Parameters.Add(new ByteArrayCommandParameter(peerAddress)); Parameters.Add(new ByteCommandParameter((byte)advertisingChannelMap)); Parameters.Add(new ByteCommandParameter((byte)advertisingFilterPolicy)); }
/// <summary> /// True if this advertising type can contain data: ADV_IND, ADV_NONCONN_IND, and ADV_SCAN_IDN. /// </summary> public static Boolean CanCarryPayload(this AdvertisingType type) { return(type == AdvertisingType.ADV_IND || type == AdvertisingType.ADV_NONCONN_IND || type == AdvertisingType.ADV_SCAN_IDN); }
/// <summary> /// Выгрузка рекламной информации /// </summary> /// <param name="advertisingText">Текст рекламной информации</param> /// <param name="advertisingType">Тип рекламной информации <see cref="AdvertisingType"/></param> protected virtual bool OnAdvertisingUpload(string advertisingText, AdvertisingType advertisingType) { return(true); }