Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get full device name? #703

Open
piotrusspan opened this issue Jun 28, 2023 · 3 comments · May be fixed by #711
Open

How to get full device name? #703

piotrusspan opened this issue Jun 28, 2023 · 3 comments · May be fixed by #711
Labels

Comments

@piotrusspan
Copy link

I got device with long name: SN_1234567890123456789012345 and when I scanning in IDevice variable my device.name is shorter: SN_12345678, but in device.NativeDevice there is full device name. How to get it?

Expected behavior

device.name = SN_1234567890123456789012345

Actual behavior

device.name = SN_12345678

Configuration

**Version of the Plugin:2.1.3

**Platform: iOS 16.5.1

**Device: iPhone 13

@smsissuechecker
Copy link

Hi @piotrusspan,

I'm the friendly issue checker.
It seems like (62.50 %) 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!

@janusw janusw added the os:iOS label Jul 3, 2023
@janusw
Copy link
Member

janusw commented Jul 3, 2023

Looking at the code in Plugin.BLE.iOS.Device, it seems like the name of the device is simply copied from the nativeDevice, so I don't understand why they would be different, see:

public Device(Adapter adapter, CBPeripheral nativeDevice, IBleCentralManagerDelegate bleCentralManagerDelegate)
: this(adapter, nativeDevice, bleCentralManagerDelegate, nativeDevice.Name, nativeDevice.RSSI?.Int32Value ?? 0,
new List<AdvertisementRecord>(), true)
{
}
public Device(Adapter adapter, CBPeripheral nativeDevice, IBleCentralManagerDelegate bleCentralManagerDelegate, string name, int rssi, List<AdvertisementRecord> advertisementRecords, bool isConnectable = true)
: base(adapter, nativeDevice)
{
_bleCentralManagerDelegate = bleCentralManagerDelegate;
Id = Guid.ParseExact(NativeDevice.Identifier.AsString(), "d");
Name = name;

However, there are two things that one could try ...

  1. Check this TODO comment:
    // TODO figure out if this is in any way required,
    // https://github.com/xabre/xamarin-bluetooth-le/issues/81
    //_nativeDevice.UpdatedName += OnNameUpdated;
  2. Try if uncommenting this line makes a difference:
    public void Update(CBPeripheral nativeDevice)
    {
    Rssi = nativeDevice.RSSI?.Int32Value ?? 0;
    //It's maybe not the best idea to updated the name based on CBPeripherial name because this might be stale.
    //Name = nativeDevice.Name;
    }

@janusw janusw linked a pull request Jul 4, 2023 that will close this issue
@janusw
Copy link
Member

janusw commented Aug 5, 2023

This might possibly be related to #541.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants