Comments (3)
same problem, GetSystemConnectedOrPairedDevices() doesn't return anything, but I can see it(ESP32test) in android.bluetooth.BluetoothAdapter.BondedDevices.
from dotnet-bluetooth-le.
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.
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)
- `ScanFilterOptions` filter returned devices on WinUI HOT 3
- WinUI AdvertisementRecords missing advertised device records HOT 7
- GetCharacteristicAsync returning null for iOS, not Android. Characteristic missing from iOS only HOT 3
- Grammatical and formatting opportunities HOT 3
- Enable/disable Bluetooth on Android HOT 9
- [Android] IDevice.IsConnected doesnt update when Bluetooth radio is turned off. HOT 4
- WriteAsync does not use the CancellationToken that is given to it HOT 3
- App .NET MAUI Crash on iOS HOT 7
- Windows: More than one lost connection does not work correctly HOT 17
- [WinUI] [3.1.0-beta.1] introduces null IDevice(s) to device lists HOT 9
- [BUG] NET MAUI on iOS, I read a wrong name connectiong to a Linux device HOT 8
- Can't detect device HOT 10
- when "OnConnectionStateChange: GattStatus: InsufficientAuthorization" is shown, the ble will hang forever HOT 5
- Manufacturer data packet is missing from device on iOS HOT 4
- Cannot use the package with Avalonia Cross Platform Project HOT 7
- ConnectToKnownDeviceAsync is giving null as device name HOT 2
- Regarding Plugin.BLE Connection Event HOT 1
- Plugin.BLE - Issue Regarding ambiguous connection HOT 2
- limit of bluetooth device can be connected simultaneous HOT 8
- Ble connected Device Get Service always return null HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotnet-bluetooth-le.