コード例 #1
0
        //public void SearchDeviceByName_Thread()
        //{
        //    while (true)
        //    {
        //        foundDevice = context.GetAvailableBLEDeviceByName(name);
        //        if (foundDevice != null)
        //        {
        //            SelectedDevice = foundDevice;
        //            break;
        //        }
        //        Thread.Sleep(5000);        //Wait for 5 secs before checking if the required device is available or not
        //    }

        //    ConnectToSelectedDevice(foundDevice);
        //}

        public async void ConnectToSelectedDevice(ObservableBLEDevice bleDevice)
        {
            StopEnumeration();

            Console.WriteLine("Connecting to: " + SelectedDevice.name);
            if (await SelectedDevice.Connect() == false)
            {
                Console.WriteLine("ConnectToSelectedDevice: Something went wrong getting the BLEDevice");
                SelectedDevice = null;
                return;
            }

            Console.WriteLine("ConnectToSelectedDevice: Connected");
        }
コード例 #2
0
 public void SearchDeviceByName(string name)
 {
     SelectedDevice = context.GetAvailableBLEDeviceByName(name);
 }