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
I'm facing an issue with auto-connecting and re-connecting devices using BleManager in React Native. The connection process is working for the initial connection, but the subsequent reconnect attempts are failing. The goal is to connect to a peripheral, set the MTU size, retrieve services, and handle the connected device's characteristics. However, the reconnect logic does not seem to be functioning as expected.
I'm facing an issue with auto-connecting and re-connecting devices using BleManager in React Native. The connection process is working for the initial connection, but the subsequent reconnect attempts are failing. The goal is to connect to a peripheral, set the MTU size, retrieve services, and handle the connected device's characteristics. However, the reconnect logic does not seem to be functioning as expected.
Here is the code that I am currently using:
const onConnect = async (item) => {
try {
await new Promise(async () => {
await BleManager.connect(item);
// Await the MTU request
await BleManager.requestMTU(item, 517);
BleManager.retrieveServices(item).then((res) => {
// handle characteristics response
});
});
} catch (error) {
console.error("Connection error:", error);
}
};
const onConnectedDevices = async () => {
await BleManager.getConnectedPeripherals([]).then(async (peripherals) => {
if (peripherals.length > 0) {
onConnect(peripherals[0]?.id);
}
});
};
Expected Behavior:
Current Behavior:
The text was updated successfully, but these errors were encountered: