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

The platform IDevice.Name is not the same #761

Closed
yureng opened this issue Oct 24, 2023 · 4 comments
Closed

The platform IDevice.Name is not the same #761

yureng opened this issue Oct 24, 2023 · 4 comments
Labels

Comments

@yureng
Copy link

yureng commented Oct 24, 2023

My Bluetooth device, its
CompleteLocalName: WaveCup,
ShortenedLocalName: Cup.

Steps to reproduce

  1. Call the CrossBluetoothLE.Current.Adapter.StartScanningForDevicesAsync(..) to search for devices

  2. On Android, IDevice.Name is: WaveCup,

  3. On IOS, IDevice.Name is: Cup

Expected behavior

The IDevice.Name obtained by both platforms should be the same, both: WaveCup

Actual behavior

No!
Android is CompleteLocalName
iOS is ShortenedLocalName

Crashlog

none

Configuration

Version of the Plugin: v3.0.0

Platform: Android 8 / Android 13 / iOS 14.7.1 / iOS 15.4

Device: Samsung S8 / Samsung S22 / iPhone 8 / iPhone 8 Plus

on iOS, how can I get CompleteLocalName ?
Thank you!

@smsissuechecker
Copy link

Hi @yureng,

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.

@yureng
Copy link
Author

yureng commented Oct 25, 2023

Debug trace, I found:

CoreBluetooth.CBPeripheral.Name is "CompleteLocalName"
CoreBluetooth.CBDiscoveredPeripheralEventArgs.AdvertisementData[CBAdvertisement.DataLocalNameKey] is "ShortenedLocalName"

Hence the line of code, Apple.Adapter.cs 35

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();
}

"CompleteLocalName" is replaced with "ShortenedLocalName"

maybe, Apple.Adapter.cs 345 :

records.Add(new AdvertisementRecord(AdvertisementRecordType.CompleteLocalName,
NSData.FromString(advertisementData.ObjectForKey(key) as NSString).ToArray()));

Should be "ShortenedLocalName"

@janusw janusw added the os:iOS label Oct 25, 2023
@janusw
Copy link
Member

janusw commented Nov 18, 2023

This might possibly be related to #703. There it was claimed that Device.NativeDevice has the full name. Could you check that?

@yureng yureng closed this as completed Jan 18, 2024
@janusw
Copy link
Member

janusw commented Jan 18, 2024

@yureng Why did you close the issue? What's the conclusion? Is it solved? Did you find a workaround?

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

3 participants