public DeviceViewModel() { var a = new Robotics.Mobile.Core.Bluetooth.LE.Adapter(); //SetAdapter(a); this.devices = new ObservableCollection <IDevice>(); adapter.DeviceDiscovered += (object sender, DeviceDiscoveredEventArgs e) => { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { devices.Add(e.Device); }); }; adapter.ScanTimeoutElapsed += (sender, e) => { adapter.StopScanningForDevices(); // not sure why it doesn't stop already, if the timeout elapses... or is this a fake timeout we made? Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { // DisplayAlert("Timeout", "Bluetooth scan timeout elapsed", "OK", ""); }); }; /* ScanAllButton.Activated += (sender, e) => { * StartScanning(); * }; * * ScanHrmButton.Activated += (sender, e) => { * StartScanning(0x180D.UuidFromPartial()); * };*/ }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); _buttonScanBle = FindViewById <Button>(Resource.Id.ButtonSearchBle); _textboxResults = FindViewById <EditText>(Resource.Id.TextBoxResults); _buttonScanBle.Click += ButtonScanBleClick; var appContext = Application.Context; _manager = (BluetoothManager)appContext.GetSystemService(BluetoothService); // ("bluetooth"); _adapter = _manager.Adapter; _bleAdapter = new Adapter(); _bleAdapter.DeviceDiscovered += _bleAdapter_DeviceDiscovered; _bleAdapter.ScanTimeoutElapsed += _bleAdapter_ScanTimeoutElapsed; }
public void Initialize_BT() { foundDev = new List<IDevice>(); var a = new Robotics.Mobile.Core.Bluetooth.LE.Adapter(); App.SetAdapter(a); Main_Adapter = App.Adapter; Main_Adapter.DeviceDiscovered += (object sender, DeviceDiscoveredEventArgs e) => { Console.WriteLine(String.Format("Device found {0}", e.Device.Name)); Console.WriteLine(String.Format("Name: {0} {1} {2} {3}", e.Device.Name, e.Device.State.ToString(), e.Device.ID.ToString(), e.Device.NativeDevice.ToString())); }; /* Main_Adapter.DeviceDiscovered += (object sender, DeviceDiscoveredEventArgs e) => { Console.WriteLine(String.Format("Device found {0}", e.Device.Name)); };*/ }
public void SetAdaptor() { var rob = new Robotics.Mobile.Core.Bluetooth.LE.Adapter(); App.SetAdaptor(rob); }
static Adapter () { _current = new Adapter (); }
public GattCallback (Adapter adapter) { this._adapter = adapter; }
public GattCallback (Adapter adapter) { _adapter = adapter; }