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.

Cannot connect to device using Service UUIDs

See original GitHub issue

Prerequisites

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Expected Behavior

BleManager.startDeviceScan should emit callback when serviceUUIDs are present on peripheral.

Current Behavior

BleManager.startDeviceScan does not emit callback when serviceUUIDs are present.

Steps to Reproduce

  1. Use array of one or more strings to filter peripherals scanned by service UUID.
  2. Callback is not fired
  3. Set service UUIDs to null
  4. Callback is fired for all peripherals

Context

Current environment:

{
  "react": "16.8.3",
  "react-native": "0.59.3",
  "react-native-ble-plx": "1.0.3"
}

The code below demonstrates the problem:

const bleManager = new BleManager();
bleManager.onStateChange(state => {
    if (state !== "PoweredOn") return
    bleManager.startDeviceScan(
        ["053d03fd-00b0-4331-a337-f49f59777484"], // change this value to null to and all peripherals are called
        null,
        (error, scannedDevice) => {
            if (error) console.error(error);
            bleManager.connectToDevice(scannedDevice.id).then(connectedDevice => {
                return connectedDevice.discoverAllServicesAndCharacteristics()
            }).then(connectedDevice2 => {
                return connectedDevice2.services()
            }).then(services => {
                console.log(services.map(x=>x.uuid));
            })
        }
    )
})

After changing services to null, the service UUIDs are printed in console. I have tried to copy/paste the array for the services and running again, but the peripheral is still not found.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
Cierpliwycommented, Apr 5, 2019

Is 053d03fd-00b0-4331-a337-f49f59777484 present in advertisement data? You can check scannedDevice.serviceUUIDs field to check if this UUID is visible. If not, then that’s expected behavior.

1reaction
xkovacikmcommented, Apr 7, 2019

I am unfortunately having a same problem. Some fields are actually missing in connectToDevice promise

this.manager.startDeviceScan( null, null, (error, device) =>{
    if( error ){ console.log( error ); }

    if( device.id = "24:0A:C4:32:31:32" ){
            console.log( device ); //  serviceUUIDs, localName, rssi, txPowerLevel, are present
            this.manager.stopDeviceScan();
            
            this.manager.connectToDevice( device.id, { autoconnect: true } ).then( deviceConnected => {
                 return deviceConnected.discoverAllServicesAndCharacteristics();
            }).then( deviceConnected2 => {
                console.log( deviceConnected2 ); // none of fields above are present now
            });
        }
        
    });`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot connect to device using Service UUIDs #443 - GitHub
After changing services to null, the service UUIDs are printed in console. I have tried to copy/paste the array for the services and...
Read more >
BLE: Can not connect to device wit… | Apple Developer Forums
My all devices have different name and identifier, first device is working fine. For creating UUID values, I used UUID generator. var secondFirstCharacteristic ......
Read more >
Connecting to a specific BLE devicetype using UUID and Name
I am getting an error when I try to connect to a specific device image. The docs have the 'type' missing - it's...
Read more >
Why cant I connect to the hands free service on my device?
I tried to connect Gear S3 to hands free service of my Galaxy S6 Edge. At first i tried to get the list...
Read more >
GattServiceUuids Class (Windows.Devices.Bluetooth ...
To view a list of all Bluetooth SIG-defined service UUIDs, see Bluetooth SIG-defined Service ... doesn't have a named property, you can use...
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