コード例 #1
0
        /// <summary>
        /// Analyze the received Bluetooth LE advertisement, and either add a new unique
        /// beacon to the list of known beacons, or update a previously known beacon
        /// with the new information.
        /// </summary>
        /// <param name="btAdv">Bluetooth advertisement to parse, as received from
        /// the Windows Bluetooth LE API.</param>
        private void ReceivedAdvertisement(BLEAdvertisementPacket btAdv)
        {
            if (btAdv == null)
            {
                return;
            }

            // Check if we already know this bluetooth address
            foreach (var bluetoothBeacon in BluetoothBeacons)
            {
                if (bluetoothBeacon.BluetoothAddress == btAdv.BluetoothAddress)
                {
                    // We already know this beacon
                    // Update / Add info to existing beacon
                    bluetoothBeacon.UpdateBeacon(btAdv);
                    return;
                }
            }

            // Beacon was not yet known - add it to the list.
            var newBeacon = new Beacon(btAdv);

            BluetoothBeacons.Add(newBeacon);
            BeaconAdded?.Invoke(this, newBeacon);
        }
コード例 #2
0
ファイル: BLE.cs プロジェクト: puf17640/IPSConfigure
 public BLE(IBluetoothPacketProvider provider)
 {
     if (provider != null)
     {
         manager              = new BeaconManager(provider);
         manager.BeaconAdded += (s, b) => BeaconAdded.Invoke(s, b);
         provider.AdvertisementPacketReceived += (s, e) => AdvertisementPacketReceived.Invoke(s, e);
     }
 }