You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
On Android, calls to BleManager.read() do not resolve when called for a peripheral which was discovered, but is not currently connected. The call never returns, nor throws an error.
On iOS, the same call to read() resolves with an error " Could not find service with UUID XXX on peripheral with UUID YYYY".
To Reproduce
Steps to reproduce the behavior:
On Android, run a scan and discover the device, but do not connect to it.
Call BleManager.read() with the given peripheralId and existing service and characteristic UUIDs.
The read() call never completes.
Expected behavior
The read() call should result in an error due to the peripheral not being currently connected, or at least some other type of error.
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
Device: Huawei P30 Pro, Samsung Galaxy A14
OS: Android 10, Android 13
react-native-ble-manager version: 11.5.5
react-native version: 0.73.6
Additional context
When the BleManager.read() is called before the device is discovered, the call completes correctly with an error "Peripheral not found".
The following code snippet can be used to reproduce the issue:
testForReadBug: async () => {
// replace with the peripheral ID of your device on iOS and Android
const peripheralId = Platform.OS === 'android' ? "00:80:81:82:83:84" : "bd377951-2070-d4ea-3a44-3d2d0f8401a3";
const serviceUUID = "180a";
const characteristicUUID = "2a26";
console.log("Will try to read before discovery");
try {
const characteristicValue = await BleManager.read(peripheralId, serviceUUID, characteristicUUID);
console.log("Characteristic value: " + characteristicValue);
} catch (error) {
console.log("Error reading characteristic before discovery: " + error);
}
const eventEmitter = new NativeEventEmitter(NativeModules.BleManager);
const logDiscoveredPeripheral = (peripheral: Peripheral) => {
if (peripheralId == peripheral.id) {
console.log("Discovered peripheral with id " + peripheral.id);
const readValueAfterDiscovery = async () => {
await BleManager.stopScan();
console.log("Will try to read after discovery");
try {
const characteristicValue = await BleManager.read(peripheralId, serviceUUID, characteristicUUID);
console.log("Characteristic value: " + characteristicValue);
} catch (error) {
console.log("Error reading characteristic after discovery: " + error);
}
}
readValueAfterDiscovery();
}
};
const discoverEventListener = eventEmitter.addListener('BleManagerDiscoverPeripheral', logDiscoveredPeripheral);
const stopScanEventListener = eventEmitter.addListener('BleManagerStopScan', () => {
console.log("Scan stopped");
discoverEventListener.remove();
stopScanEventListener.remove();
});
console.log("Will start scan");
await BleManager.scan([],30, false);
console.log("Scan started");
}
On Android, the console shows the following - note that no error message or a message with the characteristic value is shown after "Will try to read after discovery":
Will try to read before discovery
Error reading characteristic before discovery: Peripheral not found
Will start scan
Scan started
Discovered peripheral with id 00:80:81:82:83:84
Will try to read after discovery
Scan stopped
On iOS, the results are the following - notice that an error is thrown after the attempt to call read() after the device is discovered:
Will try to read before discovery
Error reading characteristic before discovery: Could not find peripheral with UUID bd377951-2070-d4ea-3a44-3d2d0f8401a3
Will start scan
Scan started
Discovered peripheral with id bd377951-2070-d4ea-3a44-3d2d0f8401a3
Scan stopped
Will try to read after discovery
Error reading characteristic after discovery: Could not find service with UUID 180a on peripheral with UUID bd377951-2070-d4ea-3a44-3d2d0f8401a3
```
The text was updated successfully, but these errors were encountered:
Describe the bug
On Android, calls to BleManager.read() do not resolve when called for a peripheral which was discovered, but is not currently connected. The call never returns, nor throws an error.
On iOS, the same call to read() resolves with an error " Could not find service with UUID XXX on peripheral with UUID YYYY".
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The read() call should result in an error due to the peripheral not being currently connected, or at least some other type of error.
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
Additional context
When the BleManager.read() is called before the device is discovered, the call completes correctly with an error "Peripheral not found".
The following code snippet can be used to reproduce the issue:
On Android, the console shows the following - note that no error message or a message with the characteristic value is shown after "Will try to read after discovery":
On iOS, the results are the following - notice that an error is thrown after the attempt to call read() after the device is discovered:
The text was updated successfully, but these errors were encountered: