BLE.Plugin doesn't find any device

DidacCasanovasDidacCasanovas USMember

I can't get my app to detect any device except a smartwatch (MI Band 2). With the bluetooth adapter on my computer I detect all other devices (mobile, etc) except the smartwatch.
Anyone have any idea why?

EDIT: The device I tried to connect is not compatible with BLE. Are there any BTH nugets? I've been searching for Google and I've not found anything.

My code is this:

MainPage.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:App_v1._1"
             x:Class="App_v1._1.MainPage">
<StackLayout>
    <StackLayout Padding="10,10,10,10" BackgroundColor="White">
      <Image Source="image.png"/>
      <Button x:Name="btn_scan_device" BorderColor="Black" Text="Scan" FontSize="17" TextColor="Green" WidthRequest="60" HeightRequest="50" FontAttributes="Bold" Clicked="ButtonScan"/>
    <StackLayout BackgroundColor="#8FCA00" Padding="0,10,0,0">
      <Label Text="Device List" TextColor="Black" FontSize="15" TranslationX="10" FontAttributes="Bold"></Label>
      <Label BackgroundColor="Black" HeightRequest="5"/>
    </StackLayout>
    <StackLayout BackgroundColor="Gray" Padding="0,10,0,0">
      <ListView x:Name="lv_deviceList" HasUnevenRows="True" ItemSelected="OnSelection">>
        <ListView.ItemTemplate>
          <DataTemplate>
            <ViewCell>
              <StackLayout>
                <Label Text="{Binding name}"></Label>
              </StackLayout>
            </ViewCell>
          </DataTemplate>
        </ListView.ItemTemplate>
      </ListView>
    </StackLayout>
    </StackLayout>
</StackLayout>
  </ContentPage>

MainPage.xaml.cs:

public partial class MainPage : ContentPage
    {
        public ObservableCollection<Dispositivos> devicelist = new ObservableCollection<Dispositivos>();

    public MainPage()
    {
        InitializeComponent();
        lv_deviceList.ItemsSource = devicelist;
    }

    public void ButtonScan(object sender, EventArgs e)
    {

        var ble = CrossBluetoothLE.Current;
        var adapter = CrossBluetoothLE.Current.Adapter;

        adapter.DeviceDiscovered += (s, a) =>
        {
            //Debug.WriteLine($"NEW DEVICE FONDUURUUUUUUUU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! {a.Device.Name}");
            if (a.Device.Name != null)
            {
                devicelist.Add(new Dispositivos() { name = "Device " + a.Device.Name + " found!" });
            }

        };

        adapter.StartScanningForDevicesAsync();

    }

    async public void OnSelection(object sender, SelectedItemChangedEventArgs e)
    {
        Dispositivos DeviceSelect = e.SelectedItem as Dispositivos;
        var answer = await DisplayAlert("Device Connection", "Would you like to connect with this device?", "Yes", "No");
     }
}

Answers

  • carlos.jnrcarlos.jnr USMember ✭✭

    Exactly same problem in here! :-(

    Did you find any solution?

  • plopplopplopplop USMember ✭✭

    Hi !

    I detect some devices but they don't have any names !!
    So I'm not event sure that I really detect some actual devices.
    Even when I have no devices turned on I always have at least one that shows up. (With no name either)

    Does someone knows why ?

Sign In or Register to comment.