internal int StartScan() { _adapterLeScanResultChangedCallback = (int result, ref BluetoothLeScanDataStruct scanData, IntPtr userData) => { Log.Info(Globals.LogTag, "Inside Le scan callback "); BluetoothLeScanData scanDataInfo = BluetoothUtils.ConvertStructToLeScanData(scanData); BluetoothLeDevice device = new BluetoothLeDevice(scanDataInfo); BluetoothError res = (BluetoothError)result; AdapterLeScanResultChangedEventArgs e = new AdapterLeScanResultChangedEventArgs(res, device); _adapterLeScanResultChanged?.Invoke(null, e); }; IntPtr data = IntPtr.Zero; int ret = Interop.Bluetooth.StartScan(_adapterLeScanResultChangedCallback, data); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to start BLE scan - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } _scanStarted = true; return(ret); }
public BluetoothDevice(BluetoothLeDevice leDevice) { RemoteDeviceAddress = leDevice?.RemoteAddress; }
internal AdapterLeScanResultChangedEventArgs(BluetoothError result, BluetoothLeDevice deviceData) { _deviceData = deviceData; _result = result; }