Hi guys
I'm playing around with an Arduino to which I have purchased the HM-10 BLE module. Currently, I just try to see if I can actually discover bluetooth devices through a simple application.
For this purpose, I use Xabre.
The sample application is as follows:
namespace BluetoothExample
{
public partial class MainPage : ContentPage
{
public MainPage()
{
Padding = new Thickness(0, 20, 0, 0);
var listView = new ListView();
listView.ItemsSource = refreshcmd();
Content = listView;
}
public static List<IDevice> refreshcmd()
{
List<IDevice> deviceList = new List<IDevice>();
var adapter = CrossBluetoothLE.Current.Adapter;
adapter.DeviceDiscovered += (s, a) => deviceList.Add(a.Device);
adapter.StartScanningForDevicesAsync();
return deviceList;
}
}
}
Now, my experience with Xamarin is little. However what i try to achieve here, is to create a listview and populate it with the bluetooth devices that my phone discovers.
Obviously, it doesn't show anything in the table, when i use it on my physical phone.
My logic tells me that i should allow the phone time to actually scan the environment before populating the list. Furthermore it could probably be convenient to add an automatic update feature to the list. - so that once a BT device is discovered, it is added to deviceList
and then appended to the listview.
Can any of you help me with this relatively simple issue? Thanks in advance