Hello,
I am trying to use Monkey Robotics to get all the BLE devices but I simply can't start a scan to receive a list of all the devices. Even the examples provided by Monkey Robotics fails. Maybe it has something to do with my VM android phone not enabling bluetooth? I haven't tested iphone. My VS debugger open up asking for the destination of a 'SyncContext.cs' file. Afterwards it ends with a null pointer. This is my code
CORE
private IAdapter adapter;
public TestPage(IAdapter adapter)
{
InitializeComponent();
this.adapter = adapter;
}
public void ScanDevices(object senderr, EventArgs es)
{
adapter.DeviceDiscovered += (sender, e) =>
{
if (e.Device.Name != null)
{
}
};
adapter.ScanTimeoutElapsed += (sender, e) =>
{
adapter.StopScanningForDevices();
};
if (adapter.IsScanning) // stop with previous scans
{
adapter.StopScanningForDevices();
}
adapter.StartScanningForDevices(Guid.Empty);
}
ANDROID
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
SetAdapter();
LoadApplication(new App());
}
void SetAdapter()
{
var adapter = new Robotics.Mobile.Core.Bluetooth.LE.Adapter();
App.SetAdapter(adapter);
}