Giter Site home page Giter Site logo

Comments (3)

JuLights avatar JuLights commented on June 12, 2024 1

image

same problem, GetSystemConnectedOrPairedDevices() doesn't return anything, but I can see it(ESP32test) in android.bluetooth.BluetoothAdapter.BondedDevices.

from dotnet-bluetooth-le.

smsissuechecker avatar smsissuechecker commented on June 12, 2024

Hi @TiisangMguni,

I'm the friendly issue checker.
It seems like (75.00 %) you haven't used our issue template 😢 I think it is very frustrating for the repository owners, if you ignore them.

If you think it's fine to make an exception, just ignore this message.
But if you think it was a mistake to delete the template, please close the issue and create a new one.

Thanks!

from dotnet-bluetooth-le.

Auto72 avatar Auto72 commented on June 12, 2024

I want to summarize the behavior of the Adapter.GetSystemConnectedOrPairedDevices() method with the BLE.Plugin ver. 3.1.0-beta.

var pdList = Adapter.GetSystemConnectedOrPairedDevices();
foreach(var pd in pdList) 
{
    Debug.WriteLine($"Name: {pd.Name} | Id: {pd.Id} | IsConnectable: {pd.IsConnectable} |");
}

On Android it works form me, I get the list of paired BLE devices.

On Windows doesn't work form me, what it works form me is the following:

    public override IReadOnlyList<IDevice> GetSystemConnectedOrPairedDevices(Guid[] services = null)
    {
        string pairedSelector = BluetoothLEDevice.GetDeviceSelectorFromPairingState(true);
        DeviceInformationCollection pairedDevices = DeviceInformation.FindAllAsync(pairedSelector).GetAwaiter().GetResult();
        List<IDevice> devlist = ConnectedDevices.ToList();
        List<Guid> ids = ConnectedDevices.Select(d => d.Id).ToList();
        foreach (var dev in pairedDevices)
        {
            Guid id = dev.Id.ToBleDeviceGuidFromId();
            ulong bleaddress = id.ToBleAddress();
            if (!ids.Contains(id))
            {
                var bluetoothLeDevice = BluetoothLEDevice.FromBluetoothAddressAsync(bleaddress).AsTask().Result;
                if (bluetoothLeDevice != null)
                {
                    var device = new Device(this, bluetoothLeDevice, 0, id);
                    devlist.Add(device);
                    ids.Add(id);
                    Trace.Message("GetSystemConnectedOrPairedDevices: {0}: {1}", dev.Id, dev.Name);
                }
                else
                {
                    Trace.Message("GetSystemConnectedOrPairedDevices: {0}: {1}, BluetoothLEDevice == null", dev.Id, dev.Name);
                }
            }
        }
        return devlist;
    }

NOTE: we need to use BluetoothLEDevice, instead of the current BluetoothDevice.

On iOS I get the following error when I try to call the method .GetSystemConnectedOrPairedDevices()

Value cannot be null. (Parameter 'serviceUUIDs')

    public override IReadOnlyList<IDevice> GetSystemConnectedOrPairedDevices(Guid[] services = null)
    {
        // NOTE: to avoid the null error, instead of using 'null' here, we need to use 'new CBUUID[1]'
        CBUUID[] serviceUuids = null;
        if (services != null)
        {
            serviceUuids = services.Select(guid => CBUUID.FromString(guid.ToString())).ToArray();
        }

        var nativeDevices = _centralManager.RetrieveConnectedPeripherals(serviceUuids);

        return nativeDevices.Select(d => new Device(this, d, _bleCentralManagerDelegate)).Cast<IDevice>().ToList();
    }

Anyway, even if I fix the problem in iOS that way, it doesn't return my paired BLE device, that I can see listed in 'My Devices' under the Bluetooth Settings.

I need help in iOS, in order to get my paired BLE device listed by the method .GetSystemConnectedOrPairedDevices()

from dotnet-bluetooth-le.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.