Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Unable to connect to multiple devices (Ollie and/or BB-8) #81

@WasylF

Description

@WasylF

Hi!

I'm running Ubuntu 16.04 lts and my bluetooth adapter is BCM20702A0 Bluetooth 4.0.

It 100% physically could work with few devices because I could control 2 Ollies at the same time (first from official SDK and the second one by unofficial python SDK). But I couldn't control both of them at the same time from the official SDK.

My code:

#Test.js
var sphero = require("sphero");

ollie1 = sphero('XX:XX:XX:XX:XX:XX', {timeout: 1000});
ollie2 = sphero('YY:YY:YY:YY:YY:YY', {timeout: 1000});

ollie1.connect(function() {
    console.log("Ollie1 connected");
    setInterval(function() {
            ollie1.randomColor(function(err, data) {
                console.log("Ollie1 set random color");
            });

    }, 1000);
});

ollie2.connect(function() {
    console.log("Ollie2 connected");
    setInterval(function() {
            ollie2.randomColor(function(err, data) {
                console.log("Ollie2 set random color");
            });

    }, 1000);
});

When I execute it only first Ollie changing color.

I divided code into two different files and locate them in the different directories:

#Test1.js
var sphero = require("sphero");

ollie1 = sphero('XX:XX:XX:XX:XX:XX', {timeout: 1000});

ollie1.connect(function() {
    console.log("Ollie1 connected");
    setInterval(function() {
            ollie1.randomColor(function(err, data) {
                console.log("Ollie1 set random color");
            });

    }, 1000);
});

#Test2.js
var sphero = require("sphero");

ollie2 = sphero('YY:YY:YY:YY:YY:YY', {timeout: 1000});

ollie2.connect(function() {
    console.log("Ollie2 connected");
    setInterval(function() {
            ollie2.randomColor(function(err, data) {
                console.log("Ollie2 set random color");
            });

    }, 1000);
});

When I execute second one It trough exceptions:

/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:405
  return this._connectedService(serviceId).characteristics;
                                          ^

TypeError: Cannot read property 'characteristics' of null
    at Adaptor._connectedCharacteristics (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:405:43)
    at Adaptor._connectCharacteristic (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:358:12)
    at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:303:12
    at Adaptor._connectService (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:339:5)
    at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:301:10
    at Adaptor._connectBLE (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:325:5)
    at Adaptor.getCharacteristic (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:300:8)
    at Adaptor.writeServiceCharacteristic (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:275:8)
    at Adaptor.setTXPower (/home/myPath2/node_modules/sphero/lib/adaptors/ble.js:204:8)
    at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:157:10
    at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:276:25
    at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:302:20
    at /home/myPath2/node_modules/sphero/lib/adaptors/ble.js:348:9
    at Peripheral.<anonymous> (/home/myPath2/node_modules/noble/lib/peripheral.js:73:7)
    at Peripheral.g (events.js:260:16)
    at emitOne (events.js:77:13)

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions