react-native-ble-plx icon indicating copy to clipboard operation
react-native-ble-plx copied to clipboard

Unable to find services for my device

Open t3kkenz opened this issue 8 years ago • 9 comments

I keep getting null for my serviceUUIDs:

id: "..."
isConnectable: null
localName: null
manufacturerData: null
mtu: 23
name: "lifepi0000"
overflowServiceUUIDs: null
rssi: null
serviceData: null
serviceUUIDs: null
solicitedServiceUUIDs: null
txPowerLevel: null

Also no services found:

BleError: Services not discovered for device ..

When I run the same check using another package react-native-ble-manager, everything seems to work fine and it finds my services. Does anyone know what wrong? Is there a specific version of react-native etc that I need to run. Thanks!

t3kkenz avatar Nov 21 '18 23:11 t3kkenz

serviceUUIDs property is related to advertisement data only. To discover devices you have to call discoverAllServicesAndCharacteristicsForDevice and then you can get discovered devices by calling servicesForDevice. Hope it helps.

Cierpliwy avatar Nov 23 '18 09:11 Cierpliwy

Thanks for the quick response, I really appreciate it, my team is working on a time sensitive project so this is great. The first output above is from running discoverAllServicesAndCharacteristicsForDevice. I'm getting that data from the promise. The second output is from discover services which I tried to run after I ran discoverAllCharacteristicsAndServicesForDevice

t3kkenz avatar Nov 23 '18 17:11 t3kkenz

Can you give me a code snippet and native logs?

Cierpliwy avatar Nov 23 '18 18:11 Cierpliwy

this.manager.connectToDevice(deviceID) 
  .then((device) => {
  
  device.discoverAllServicesAndCharacteristics()
      .then((results) => { 
        console.log(results);
        this.manager.servicesForDevice(deviceID)
          .then((services) => {
            console.log(services);
          });
      });
});

t3kkenz avatar Nov 23 '18 18:11 t3kkenz

Helo @ssajnani, it might be interesting to look at this repository => https://github.com/zhanguangao/react-native-ble-plx-demo . I was inspired by watching this repository, especially the method fetchServicesAndCharacteristicsForDevice

leo-tavares avatar Nov 25 '18 21:11 leo-tavares

Closing due to lack of information and inactivity of the original poster.

When more data will be available—feel free to add that information and reopen this issue.

Best Regards

dariuszseweryn avatar Jan 04 '19 15:01 dariuszseweryn

i am change

device.discoverAllServicesAndCharacteristicsForDevice()

to

this.manager.discoverAllServicesAndCharacteristicsForDevice(peripheralId)


and change

device.servicesForDevice()

to

this.manager.servicesForDevice(peripheralId)


and the problem is resolved

hidayat-nur avatar Feb 20 '20 02:02 hidayat-nur

i am change

device.discoverAllServicesAndCharacteristicsForDevice()

to

this.manager.discoverAllServicesAndCharacteristicsForDevice(peripheralId)

and change

device.servicesForDevice()

to

this.manager.servicesForDevice(peripheralId)

and the problem is resolved

Hi @hidayatNgganteng !

I have the same problem.. I can scan and connect the device, but when I try to list the services I receve the same message error.

Can you show in your code how you solved this issue?

Thansks

renatoramossilva avatar Apr 05 '20 21:04 renatoramossilva

device.discoverAllServicesAndCharacteristicsForDevice() for this thing i am getting error of Function not found

this.manager.discoverAllServicesAndCharacteristicsForDevice(peripheralId) and in this i am getting the same response as connectToDevice ( null values )

hitanshuGajjar20 avatar Apr 20 '21 09:04 hitanshuGajjar20