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.

Unable to connect to multiple devices

See original GitHub issue

Hi,

I have 5 devices and most of the time it will only connect to 1 or 2 devices. Sometimes 3, but rarely more. I’m running ubuntu 14.04 TLS.

Here is my code if it can help:

var noble = require('noble');
var os = require('os');

noble.on('stateChange', function(state) {
    console.log(state);
    if (state === 'poweredOn') {
        noble.startScanning();
    } else {
    }
});

noble.on('scanStart', function() {
    console.log('scanStart');
});

noble.on('scanStop', function() {
    console.log('scanStop');
});

noble.on('discover', function(peripheral) {

    var localName = peripheral.advertisement.localName;
    console.log("discover ", localName);

    if(localName !== undefined && localName !== "" && localName.substring(0, "MY".length) === "MY") {
        console.log("Connecting ", localName);

        peripheral.on('connect', function() {
            console.log(localName, 'connected');
        });

        peripheral.on('disconnect', function() {
            console.log(localName, 'disconnected');
        });

        peripheral.connect(function(error) {
            if(error) {
                console.log(error);
                return;
            }
            console.log(localName, 'connected!'); 
        return;
        });
    }

});

When all 5 devices are power on, it will connect to maximum 3, I haven’t seen it connect to all 5. When all devices are off, the I switch one on, it will connect to it. But then when I turn on all the other 4 devices, it will never discover any of them. Thus not making an attempt to connect.

Also, would it work with bluez 5.xx?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
sandeepmistrycommented, Mar 20, 2016

@pdaddy26 try adding a noble.startScanning(); inside the `peripheral.connect(function(error) {`` callback.

This might be related to https://github.com/sandeepmistry/node-sensortag/issues/37.

0reactions
sandeepmistrycommented, May 8, 2016

@pdaddy26 thanks, unfortunately it looks the same to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Some (but not all) of my devices cannot connect to Wi-Fi ... - Fizz
Some (but not all) of my devices cannot connect to Wi-Fi. How do I fix this? · Make sure Wi-Fi is activated on...
Read more >
How to Fix Bluetooth Pairing Problems - Techlicious
Can't connect two devices? Try these 16 tips to solve your Bluetooth pairing problems.
Read more >
Why can't I connect more than one device to my WiFi? - Quora
If you are unable to connect more than 1 devices on your mobile, then it is possible that there is a device limit...
Read more >
Unable to connect multiple devices… | Apple Developer Forums
Hi, I am implementing an iPhone/iPad and mac app that allows users to send each other messages using the bonjour protocol. Basically, a...
Read more >
Unable to connect the headphones or speaker to a device ...
Hint: If a connection still can't be established, check the Bluetooth setting on other paired devices to find the device currently connected ......
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