capacitor-community / bluetooth-le

Capacitor plugin for Bluetooth Low Energy
MIT License
274 stars 79 forks source link

Android only shows "Unknown" device name when scanning with requestDevice() #633

Closed mley closed 5 months ago

mley commented 6 months ago

Describe the bug When using the requestDevice() method to scan for BLE heart-rate monitors, Android shows the devices only as "Unknown" with their MAC address. I test this with a Polar H9 and a Garmin watch in broadcast mode. On iOS the names of the devices are shown correctly.

await BleClient.requestDevice({
        services: ['0000180d-0000-1000-8000-00805f9b34fb'],
        scanMode: ScanMode.SCAN_MODE_LOW_LATENCY,
      });

To Reproduce Steps to reproduce the behavior:

  1. Turn on BLE HR monitor
  2. Call requestDevice()
  3. See result

Expected behavior I expect the pick device dialog to also show the name of the device

Screenshots Screenshot_20240308_094002_FIT-UP

Bildschirmfoto 2024-03-08 um 09 45 17

Plugin version:

Smartphone (please complete the following information):

pwespi commented 5 months ago

I'm unable to reproduce this on my test devices. Are you seeing this on multiple Android devices?

peitschie commented 5 months ago

Worth noting, iOS has 2 mechanisms for reporting BLE name, while Android only uses the advertised name. I wonder if the above is only showing the GAP name in iOS, which is cached after connection?

See https://forums.developer.apple.com/forums/thread/19381

@mley capturing the specific advertising packet using nrf Connect would perhaps make it clearer what's being broadcast.

mley commented 5 months ago

Thanks for the reply.

I tried again today with the same Android device and the same Polar H9 and this time the name of the device came back correctly. It might have just been a hiccup, fixed by a reboot of the Android phone...

Sorry for the inconvenience. I will close the issue then.