示例#1
0
        public DnaBluetoothLEAdvertisementWatcher(GattServiceIds gattIds)
        {
            mGattServiceIds = gattIds ?? throw new ArgumentNullException(nameof(gattIds));
            mWatcher        = new BluetoothLEAdvertisementWatcher
            {
                ScanningMode = BluetoothLEScanningMode.Active
            };

            mWatcher.Received += WatcherAdvertisementReceivedAsync;

            //Listen out for when the watcher stops listening
            mWatcher.Stopped += (watcher, e) =>
            {
                StoppedListening();
            };
        }
        /// <summary>
        /// The default constructor
        /// </summary>
        public DnaBluetoothLEAdvertisementWatcher(GattServiceIds gattIds)
        {
            // Null guard
            mGattServiceIds = gattIds ?? throw new ArgumentNullException();

            // Create bluetooth listener
            mWatcher = new BluetoothLEAdvertisementWatcher
            {
                ScanningMode = BluetoothLEScanningMode.Active
            };

            // Listen out for new advertisement
            mWatcher.Received += WatcherAdvertismentRecievedAsync;

            // LIsten out for when the watcher stops listening
            mWatcher.Stopped += (watcher, e) =>
            {
                // Inform listeners
                StoppedListening();
            };
        }
示例#3
0
        /// <summary>
        /// the default constructor
        /// </summary>
        public DnaBluetoothLEAdvertisementWatcher(GattServiceIds gattIds)
        {
            // null check
            mGattServiceIds = gattIds ?? throw new ArgumentNullException(nameof(gattIds));

            // create bluetooth listener
            mWatcher = new BluetoothLEAdvertisementWatcher
            {
                ScanningMode = BluetoothLEScanningMode.Active,
            };

            // listen out for new advertisements
            mWatcher.Received += WatcherAdvertisementReceivedAsync;

            // listen out for when the watcher stops listening
            mWatcher.Stopped += (watcher, e) =>
            {
                // inform listeners
                StoppedListening();
            };
        }