static public void SearchDevice()
        {
            if (Manager == null)
            {
                Manager = new wclBluetoothManager();

                //Manager.OnNumericComparison += new wclBluetoothNumericComparisonEvent(Manager_OnNumericComparison);
                //Manager.OnPasskeyNotification += new wclBluetoothPasskeyNotificationEvent(Manager_OnPasskeyNotification);
                //Manager.OnPasskeyRequest += new wclBluetoothPasskeyRequestEvent(Manager_OnPasskeyRequest);
                //Manager.OnPinRequest += new wclBluetoothPinRequestEvent(Manager_OnPinRequest);
                Manager.OnDeviceFound          += new wclBluetoothDeviceEvent(Manager_OnDeviceFound);
                Manager.OnDiscoveringCompleted += new wclBluetoothResultEvent(Manager_OnDiscoveringCompleted);
                //Manager.OnDiscoveringStarted += new wclBluetoothEvent(Manager_OnDiscoveringStarted);

                Manager.Open();

                Radio = GetRadio();
            }

            if (Radio != null)
            {
                Int32 Res = Radio.Discover(3, wclBluetoothDiscoverKind.dkBle);
                if (Res != wclErrors.WCL_E_SUCCESS)
                {
                    CSLibrary.Debug.WriteLine("Error starting discovering: 0x" + Res.ToString("X8"));
                }
            }
        }
Exemple #2
0
 void Manager_OnDiscoveringCompleted(object Sender, wclBluetoothRadio Radio, int Error)
 {
     //Console.WriteLine("Discovering completed");
     if (scanning)
     {
         // Restart scan as RMIR allows scanning for 15 minutes
         int Res = Radio.Discover(120, wclBluetoothDiscoverKind.dkBle);
         scanning = Res == wclErrors.WCL_E_SUCCESS ? true : false;
     }
 }
Exemple #3
0
 public void DiscoverUEI(bool start)
 {
     if (start)
     {
         addressList.Clear();
         nameList.Clear();
         rssiList.Clear();
         int Res = Radio.Discover(120, wclBluetoothDiscoverKind.dkBle);
         scanning = Res == wclErrors.WCL_E_SUCCESS ? true : false;
         //Console.WriteLine("Scanning state = " + scanning);
     }
     else
     {
         //Console.WriteLine("Scanning terminated");
         scanning = false;
         Radio.Terminate();
     }
 }
        void FManager_AfterOpen(object sender, EventArgs e)
        {
            btStart.Enabled = false;

            Trace("Bluetooth Manager has been opened");
            Trace("Looking for working radio");

            if (FManager.Count == 0)
            {
                Trace("No Bluetooth hardware installed");
                CloseBluetoothManager();
            }
            else
            {
                wclBluetoothRadio Radio = null;
                for (Int32 i = 0; i < FManager.Count; i++)
                {
                    if (FManager[i].Available)
                    {
                        Radio = FManager[i];
                        break;
                    }
                }

                if (Radio == null)
                {
                    Trace("No available Bluetooth Radio was found");
                    CloseBluetoothManager();
                }
                else
                {
                    Trace("Start discovering for BLE devices on radio " + Radio.ApiName);
                    Int32 Res = Radio.Discover(10, wclBluetoothDiscoverKind.dkBle);
                    if (Res != wclErrors.WCL_E_SUCCESS)
                    {
                        Trace("Start discovering failed: 0x" + Res.ToString("X8"));
                        CloseBluetoothManager();
                    }
                }
            }
        }