react-native-ble-manager
react-native-ble-manager copied to clipboard
retrieveServices doesn't respond for a long time
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
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)
Something unknown reason,
retrieveServices
never resolved or rejected.I fixed that by remove await from
retrieveServices
andsetTimeout
after startingretrieveServices
. 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.
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.