Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1.  void Start()
  2.     {
  3.         Application.runInBackground = true;
  4.         _scannedItems = new Dictionary<string, BleDeviceInfo>();
  5.  
  6.         BluetoothLEHardwareInterface.Initialize(true, false, () =>
  7.         {
  8.         },
  9.         (error) =>
  10.         {
  11.             BluetoothLEHardwareInterface.Log("Error: " + error);
  12.             if (error.Contains("Bluetooth LE Not Enabled"))
  13.                 BluetoothLEHardwareInterface.BluetoothEnable(true);
  14.         });
  15.         Debug.Log("CheckForBluetooth()");
  16.         InvokeRepeating("CheckForBluetooth", 1f, 1f);
  17.     }
  18.  
  19.  void CheckForBluetooth()
  20.     {
  21.         Debug.Log("BluetoothLEHardwareInterface.StopScan()");
  22.         BluetoothLEHardwareInterface.StopScan();
  23.  
  24.         Debug.Log("ScanForPeripheralsWithServices.ScanForPeripheralsWithServices()");
  25.         BluetoothLEHardwareInterface.ScanForPeripheralsWithServices(null, null, (address, name, rssi, bytes) =>
  26.         {
  27.             BluetoothLEHardwareInterface.Log("item found !");
  28.             BluetoothLEHardwareInterface.Log("item scanned: " + address);
  29.             BluetoothLEHardwareInterface.Log("item rssi: " + rssi);
  30.         }, false);
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement