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

[BUG] NET MAUI on iOS, I read a wrong name connectiong to a Linux device #829

Closed
acaliaro opened this issue Mar 21, 2024 · 8 comments
Closed
Labels

Comments

@acaliaro
Copy link

acaliaro commented Mar 21, 2024

To help us fix your issue, please provide the information in the below template. If something causes a crash, provide as much information as you can gather.
Just imagine: we do not know what you are doing!

Note: There is often little we can do without a minimal reproducible sample of the issue, so please provide that in a standalone git repository and link it here.

Steps to reproduce

On a Linux machine, they change the name of the bluetooth device, the "Name" property is not changed but an "Alias" is created. Using the library on an iOS device (iPhone), the library continues to read "Name" and it is not possible to recover the value of "Alias", which is instead recovered if an Android device is used.

Expected behavior

The library should read the Alias instead of the Name, or return the Alias at least in the native part. By downloading some third-party iOS apps, the Linux device is found and the Alias content is displayed

Actual behavior

Only the Name is returned, which however cannot be unique between different Linux

Crashlog

Configuration

Version of the Plugin: 3.1.0-beta.2-10-gf6b048a

Platform: iOS 17.3

Device: iPhone 12

@smsissuechecker
Copy link

Hi @acaliaro,

I'm the friendly issue checker.
Thanks for using the issue template 🌟
I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.

@fteotini-remira
Copy link

👍

@janusw janusw added the os:iOS label Mar 23, 2024
@janusw
Copy link
Member

janusw commented Mar 23, 2024

Note: We have a couple of open issues concerning device names on iOS, e.g. #541, #698, #703, #749. Could you check if any of them is similar to your situation?

There are even two experimental PRs in that direction, but they did not seem to fix anything: #711, #792

@janusw
Copy link
Member

janusw commented Mar 23, 2024

On a Linux machine, they change the name of the bluetooth device, the "Name" property is not changed but an "Alias" is created. Using the library on an iOS device (iPhone), the library continues to read "Name" and it is not possible to recover the value of "Alias", which is instead recovered if an Android device is used.

Are you only looking at the advertisements, or are you connected to the device while the name changes?

I'm not sure which effect such an alias has on the advertisements. Could you check what kind of data the device is advertising before and after the change?

@acaliaro
Copy link
Author

Hi,

on first discovery we tried to cast IDevice to CBPeripheral, which has the name property containing the name, with the unexpected value. Inspecting the istance of IDevice we can see that there's a property called AdvertisementRecors, but unfortunately is empty.

We are not connected to the device, until it is found by his name during the scan.

CC @Gaburiere-Remira

@acaliaro
Copy link
Author

acaliaro commented Apr 4, 2024

Hi @janusw I have tried 3.1.0-beta.3 the problem seems to be present, although it seems to me that sometimes the name has been returned correctly..

@acaliaro
Copy link
Author

acaliaro commented Apr 4, 2024

@janusw I think the problem is here

   var name = e.Peripheral.Name;
    if (e.AdvertisementData.ContainsKey(CBAdvertisement.DataLocalNameKey))
    {
        // iOS caches the peripheral name, so it can become stale (if changing)
        // keep track of the local name key manually
        name = ((NSString)e.AdvertisementData.ValueForKey(CBAdvertisement.DataLocalNameKey)).ToString();
    }

I think you should have a separate property (LocalName ???) to store the advertisementdata local name so that the developer can decide which one to use

@acaliaro
Copy link
Author

I think it is been solved using _adapter.DeviceAdvertised

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

No branches or pull requests

4 participants