Пример #1
0
        private BtDevice DiscoverPeerAddress(BtDeviceAddress address, int duration)
        {
            IEnumerable <BtDevice> devices;

            try
            {
                BtScanParameters scanParams = new BtScanParameters();
                scanParams.ScanIntervalMs = 100;
                scanParams.ScanWindowMs   = 12;
                devices = masterEmulator.DiscoverDevices(1, scanParams);
                foreach (BtDevice dev in devices)
                {
                    if (address.Value == dev.DeviceAddress.Value)
                    {
                        return(dev);
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex);
                return(null);
            }
        }
        /// <summary>
        /// Device discovery is started with the given scan parameters.
        /// By stating active scan, we will be receiving data from both advertising
        /// and scan repsonse packets.
        /// </summary>
        /// <returns></returns>
        bool StartDeviceDiscovery()
        {
            if (!masterEmulator.IsRunning)
            {
                AddToLog("Not ready.");
                return(false);
            }

            BtScanParameters scanParameters = new BtScanParameters();

            scanParameters.ScanType = BtScanType.ActiveScanning;
            bool startSuccess = masterEmulator.StartDeviceDiscovery(scanParameters);

            if (startSuccess)
            {
                Scanning(this, EventArgs.Empty);
            }

            return(startSuccess);
        }
Пример #3
0
        //=====================================================================
        //=====================================================================
        //=====================================================================
        //=====================================================================
        /// <summary>
        /// Device discovery is started with the given scan parameters.
        /// By stating active scan, we will be receiving data from both advertising
        /// and scan repsonse packets.
        /// </summary>
        /// <returns></returns>
        public bool StartDeviceScanning()
        {
            FLAG_autoConnect = false;
            m_deviceList.Clear();

            if (!masterEmulator.IsRunning)
            {
                AddToLog("Not ready.");
                return false;
            }

            BtScanParameters scanParameters = new BtScanParameters();
            scanParameters.ScanType = BtScanType.ActiveScanning;
            bool startSuccess = masterEmulator.StartDeviceDiscovery(scanParameters);

            if (startSuccess)
            {
                appEv_ScanningStarted(this, EventArgs.Empty);
            }

            return startSuccess;
        }
Пример #4
0
        /// <summary>
        /// Device discovery is started with the given scan parameters.
        /// By stating active scan, we will be receiving data from both advertising
        /// and scan repsonse packets.
        /// </summary>
        /// <returns></returns>
        bool StartDeviceDiscovery()
        {
            if (!masterEmulator.IsRunning)
            {
                AddToLog("Not ready.");
                return false;
            }

            BtScanParameters scanParameters = new BtScanParameters();
            scanParameters.ScanType = BtScanType.ActiveScanning;
            bool startSuccess = masterEmulator.StartDeviceDiscovery(scanParameters);

            if (startSuccess)
            {
                Scanning(this, EventArgs.Empty);
            }

            return startSuccess;
        }
 public void StartScan()
 {
     BtScanParameters scan = new BtScanParameters();
     scan.ScanType = BtScanType.ActiveScanning;
     masterEmulator.StartDeviceDiscovery(scan);
 }