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

retrieveServices doesn't respond for a long time

Open Tanisi001 opened this issue 3 years ago • 2 comments

Hi, We tried adding a custom timeout of 15 seconds but still faced this issues. We can see that in the first attempt, BLEManager.retreiveServices took around 14 seconds to return and our timeout is 15 seconds which led to timeout. In the subsequent attempt, BLEManager.retreiveServices did not return any response till 15 seconds.

Used:

  • react-native-ble-manager v6.6.2
  • react-native v0.59.8
  • DeviceModel: iPhone12,1, version: 14.6

Is there any solution for this?

Originally posted by @Tanisi001 in https://github.com/innoveit/react-native-ble-manager/issues/185#issuecomment-846731038

Tanisi001 avatar May 24 '21 04:05 Tanisi001

Something unknown reason, retrieveServices never resolved or rejected.

I fixed that by remove await from retrieveServices and setTimeout after starting retrieveServices. Example of work code:

await BleManager.connect(peripheral)
BleManager.retrieveServices(peripheral) // no await specially

setTimeout(async () => {  
  await BleManager.startNotification(....);
  await BleManager.read(....);
  ...more...
}, 1000)

Spoki4 avatar Sep 02 '21 02:09 Spoki4

Something unknown reason, retrieveServices never resolved or rejected.

I fixed that by remove await from retrieveServices and setTimeout after starting retrieveServices. Example of work code:

await BleManager.connect(peripheral)
BleManager.retrieveServices(peripheral) // no await specially

setTimeout(async () => {  
  await BleManager.startNotification(....);
  await BleManager.read(....);
  ...more...
}, 1000)

@Spoki4 this solution is not working because if retriveServises is never resolved or rejected, startNotification will not work. I get "Possible Unhandled Promise Rejection (id: 0): Characteristic not found" warning and device is not connected.

ivokutlesa avatar Sep 08 '21 08:09 ivokutlesa

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

marcosinigaglia avatar Dec 12 '23 02:12 marcosinigaglia