0
votes

I have a client app on Android 10 built with react native

Android SDK:
  API Levels: 23, 28
  Build Tools: 28.0.3
react: ^16.9.0 => 16.9.0
react-native: ^0.62.2 => 0.62.2

What works: service discovery connecting reading/writing/notify of custom (128 bit) characteritics

What does not work: reading the characteristics of general access service 0x1800

Service discovery: BleManager.retrieveServices /snip/ "characteristics": [{"characteristic": "2a00", "properties": [Object], "service": "1800"}, This is the full device name characteristic.

I can read it using any BLE client app, e.g. LightBlue, so the server side works.

I have tried reading 16-bit short UUID:

    BleManager.read(peripheral.id, 
      '1800', 
      '2a00').then((readData) => {
      console.log(readData);          
    }).catch((error) => {
      console.log(error); 
    });

and also full 128b version:

BleManager.read(peripheral.id, 
  '00001800-0000-1000-8000-00805f9b34fb', 
  '00002a00-0000-1000-8000-00805f9b34fb').then((readData) => {
  console.log(readData);          
}).catch((error) => {
  console.log(error); 
});

In both cases catch error "00002a00-0000-1000-8000-00805f9b34fb not found".

Note that the same code works fine for my own custom UUIDs. peripheral.id is MAC address of my server peripheral.

Any ideas what can be wrong? Thanks!

1
Does your scan work? I mean Device Discovery?Abhinav Saxena

1 Answers

0
votes

I found the problem. It was a race condition where retrieve services was not complete before reading characteristics. Solution:

BleManager.retrieveServices(peripheral.id).then((peripheralInfo) => {
    BleManager.read(peripheral.id, 
      '1800', 
      '2a00').then((readData) => {
      console.log(readData);          
    }).catch((error) => {
      console.log(error); 
    });
})