weliem / blessed-android

BLESSED, a Bluetooth Low Energy (BLE) library for Android
MIT License
557 stars 120 forks source link

scanForPeripherals choose from a list? #41

Closed KianYeo closed 4 years ago

KianYeo commented 4 years ago

I am modifying the default example in the library for my application, and I am trying to connect to a UART service example from Nordic. I have a few questions:

// Scan for peripherals with a certain service UUIDs central.startPairingPopupHack(); central.scanForPeripherals();

What does the startPairingPopupHack do? And when I call the scanForPeripherals, there is no pop up window that allows me to choose which BLE device to connect to.

In the app log, instead I see: Found peripheral 'null' scan stopped peripheral with address XXXXXXXXX is not in the Bluetooth cach, hence connection may fail connected to 'null' (XXXXXXXXXXX) using TRANSPORT_LE

I want to be able to choose which device to connect to. How can I do that?

weliem commented 4 years ago

Hi, startPairingPopupHack does a trick under the hood so that a 'pairing popup' would appear in the foreground rather than in the status bar only. So it is not related to what you are trying to do.

The library doesn't do any UI, so if you want to show the user a UI to select a peripheral, you will have to do it yourself.