0
votes

I need to solve this issue with my app. I try to scan the peripherals (Bluetooth devices) using the CBCentralManager from the CoreBluetooth in Xamarin.iOS, but when a peripheral is discovered it has an empty name sometimes, when I do the same from the iOS settings then it has a name. I'm not searching for a specific UUID.

CBCentralManager  manager = new CBCentralManager(CoreFoundation.DispatchQueue.MainQueue);

manager.DiscoveredPeripheral += (sender, e) =>
{
    if (e.Peripheral != null)
    {
        Debug.WriteLine($"DiscoveredPeripheral: {e.Peripheral.Name} - {e.Peripheral.Identifier} - {e.AdvertisementData}");

        PeripheralsList.Add(e.Peripheral);
        CustomDeviceDiscoveredAction(this, new CustomBTEDevice
        {
            DeviceName = e.Peripheral.Name,
            DeviceAddress = e.Peripheral.Identifier.AsString(),
            DeviceGuid = Guid.Parse(e.Peripheral.Identifier.AsString())
        });
    }
};
manager.ScanForPeripherals(null, new PeripheralScanningOptions
{
    AllowDuplicatesKey = false,
});
1
Because it's updating piece by piece (chunks of data), so it can be seen multiples times, each times with more info (including the name)?Larme

1 Answers

0
votes

Check property LocalName in the advertisement data package Also, my suggestions, do not rely on the device name, better rely on data in advertisement data