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.

Everytime I try to connect to an android 7.0 device, I get an error for device is disconnected. Why is this happening?

See original GitHub issue
           scanAndConnect(){
                this.manager.startDeviceScan(null, null, (error, device) => {
                if(error){
                    console.log('Error occurred while scanning');
                    return;
             }

            if(device.id === MAC ){
                this.manager.stopDeviceScan();

                this.manager.connectToDevice(MAC, {autoConnect:false})
                .then((device) => {
                    this.info("Discovering services and characteristics")
                    console.log('device');
                    return device.services(device.id);
                })
                .then((service) => {
                    this.info("Listening... ")
                    console.log(services)
                })
                .catch((error) => {
                        console.log(error.message);
                        device.cancelConnection();
                        this.scanAndConnect();
                });
            }
        })

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
TailNestcommented, Jun 17, 2019
           scanAndConnect(){
                this.manager.startDeviceScan(null, null, (error, device) => {
                if(error){
                    console.log('Error occurred while scanning');
                    return;
             }

            if(device.id === MAC ){
                this.manager.stopDeviceScan();

                this.manager.connectToDevice(MAC, {autoConnect:false})
                .then((device) => {
                    this.info("Discovering services and characteristics")
                    console.log('device');
                    return device.services(device.id);
                })
                .then((service) => {
                    this.info("Listening... ")
                    console.log(services)
                })
                .catch((error) => {
                        console.log(error.message);
                        device.cancelConnection();
                        this.scanAndConnect();
                });
            }
        })

I might help elaborate because I’m having the same problem. I’m using the same code to connect to my bluetooth device, every time, after few seconds from the connectToDevice function I get the error “Device [MAC_ADDRESS] was disconnected”.

I can’t see any other log (not “Discovering services and characteristics”, not “Listening…”)…the code goes directly in the catch clause of the function and print the error. Here’s the stackoverflow question: https://stackoverflow.com/questions/56632350/react-native-bluetooth-device-keep-disconnecting

0reactions
gpawlikcommented, Apr 15, 2020

The problem still exists, any ideas?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Bluetooth Pairing Problems - Techlicious
1. Make sure Bluetooth is turned on ... You should see the little Bluetooth symbol at the top right of the screen if...
Read more >
5 Ways to Fix Wi-Fi Authentication Problems on Android
1. Open your Wi-Fi settings in the Settings app, like you did when forgetting the network, tap and hold the network or choose...
Read more >
Fix FITPRO Device disconnected Problem - YouTube
Fitpro auto disconnect problem happens when you don't turn ON the ... after watching this video on how to connect smartwatch to fitpro...
Read more >
How to Fix Android 7.0 Nougat Bluetooth issues - Nerds Chalk
First up, unpair your Nougat devices with all Bluetooth devices first. Now, turn off Wi-Fi and Bluetooth. Give device a reboot. Make sure...
Read more >
The Device Has Either Stopped Responding or Has Been ...
I get an error message “The Device has either stopped responding or has been disconnected” (see photo attached). This has happened recently –...
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