question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose localName of advertising packets in ScanResult object

See original GitHub issue

Is your feature request related to a problem? Please describe. When a BLE peripheral is discovered the first time by an iOS device the localName from the advertising packet is shown to the user as device name. After connecting to this device the GAP name is discovered and cached. For subsequent connection attempts the cached GAP name is shown to the user instead of the localName in the advertising packet.

If you are using the requestDevice(...) function of this plugin a dialog is opened automatically which shows eventually cached names.

If you have a BLE device where the GAP name differs from the localName provided in the advertising packets you can not guarantee a proper user experience using the requestDevice(...) function.

By using the requestLEScan(...) function you could provide a proper user experience by fetching the localName from the advertising packet of each found device and render your own connection dialog. Unfortunately the localName attribute is currently not accessible in the ScanResult object.

Describe the solution you’d like Add the localName property from the advertising packet to the ScanResult object.

Additional context I tested it out by adding the following snippet to the getScanResult() function of the Plugin.swift file right before the return Statement:

let localName = advertisementData[CBAdvertisementDataLocalNameKey] as? String
if localName != nil {
    data["localName"] = localName
}

But I am not sure if localName is a good attribute name next to the device.name which is already present in the ScanResult. Personally, I would prefer a name that makes it clear that it is the name from the advertisement packet.

Do you think this is something you could add to this plugin? Thank you in advance for your time and efforts!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pwespicommented, Mar 9, 2021

I agree that the larger response doesn’t really matter and that it’s best if both localName and device.name are there on all platforms. I don’t see any other drawbacks and will go with that solution.

Thanks for the fruitful discussion.

0reactions
pwespicommented, Mar 14, 2021

This has been added to v0.4.0 (Capacitor 2) and v1.0.0-1 (Capacitor 3).

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScanResult - Android Developers
For chained advertisements, indicates that the controller was unable to receive all chained packets and the scan result contains incomplete truncated data.
Read more >
Bluetooth scanning and advertising with LTE Beacon
Here's a list of properties available on the scanResult objects. Always available: type - [integer number] packet type. 0 - Indirect advertising packet;...
Read more >
bluetooth/gap_linux.go at release · tinygo-org/bluetooth - GitHub
"github.com/muka/go-bluetooth/bluez/profile/advertising" ... LocalName: options.LocalName, ... makeScanResult creates a ScanResult from a Device1 object.
Read more >
Why doesn't the scan result contain the complete local name?
I'm using the BluetoothLeScanner to scan for a hardware device. I have complete control over the advertising data output ...
Read more >
RA4W1 Group Bluetooth Low Energy Application Developer's ...
4.2.2 Advertising Data / Scan Response Data . ... Changing maximum transmission packet length . ... Complete Local Name */.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found