question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

device.isConnected does not return the true connection state

See original GitHub issue

The following code prints incorrect information as far as I can tell:

console.log('await device.isConnected()', await device.isConnected()); // logs false
await device.connect();
console.log('await device.isConnected()', await device.isConnected()); // logs false

The first log statement should be false, but the second log statement should be true.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
lastmjscommented, May 25, 2018

Actually, this gives incorrect results as well, I would expect the bleManager to be maintaining the global state of the device at all times:

console.log('await bleManager.isDeviceConnected(device.id)', await bleManager.isDeviceConnected(device.id)); // logs false
await device.connect();
console.log('await bleManager.isDeviceConnected(device.id)', await bleManager.isDeviceConnected(device.id)); //logs false
2reactions
federicomirallescommented, Apr 23, 2020

This issue is still present on version 2.0.0. Everytime I try to check the status of a connected device by using isDeviceConnected it always returns false. Please check the following code, despite of sending a connected device Id, I always get Device AA:BB:CC:DD:EE:FF is NOT connected!:

const isBleDeviceConnected = async (deviceId = null) => {
    if (!deviceId) return false;
    const isConnected = await bleManager.isDeviceConnected(deviceId);
    if (isConnected) {
      console.log(`Device ${deviceId} is connected!`);
    } else {
      console.log(`Device ${deviceId} is NOT connected!`);
    }
    return isConnected;
  };

Context: I need to check by using the built-in RN AppState component whether a device the user was using before switching of apps (or after coming back from background) it’s still connected…

Is there any fix in progress or a workaround available?

Thanks in advance!

Federico

Read more comments on GitHub >

github_iconTop Results From Across the Web

device.isConnected does not return the true connection state
I think I see what's happening, the device.isConnected() call is returning an updated device, but the state of the original device does not...
Read more >
If isConnected returns true, why does Exeption say that it isn't ...
isConnected() tells you about the state of the Socket . If you have ever connected or accepted it, it returns true. Even after...
Read more >
IoT Hub Device twin returning connectionState ...
Re: IoT Hub Device twin returning connectionState = Disconnected, when it's actually connected.
Read more >
Fix your Google Nest Wifi or Google Wifi network
Follow these troubleshooting steps to fix: Google Nest Wifi router or point or Google Wifi point shows offline in mesh test; Can't connect...
Read more >
How to troubleshoot Android Wi-Fi connection problems
Return to your Android device's Settings > Wireless & Networks > Wi-Fi ... When status is Connected, tap Advanced to view the client's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found