Skip to content

Latter instances of beanio.Board appear to get ignored. #3

@BorisKourt

Description

@BorisKourt

My previous question still stands, just wanted to put a new issue up as this is going in a slightly different direction. Started hardcoding it just for testing, and got into a bind.

Here is the test for the issue:

var five = require("johnny-five");
var beanio = require("bean-io");

var board1 = new beanio.Board({uuid: '78a50449b628'})
var board2 = new beanio.Board({uuid: 'd03972e51a74'})
var board3 = new beanio.Board({uuid: 'd03972d34ce3'})

var handle_bean = function(board) {

        console.log("Ready to handle:");
        console.log(board);

        var interval;
        var bean = board.connectedBean;
        var bean_data = board.beanPeripheral;

        bean.on("accell", function(x,y,z,valid) {
                var id = bean.chara.uuid;
                console.log("| " + bean_data.uuid + " accell:| x: " + x);
        });

        interval = setInterval(function() {
                bean.requestAccell();
        },500);

}

board1.on("ready", function() {
        handle_bean(this);
});

board2.on("ready", function() {
        handle_bean(this);
});

board3.on("ready", function() {
        handle_bean(this);
});

Here is the log:

$ node index.js
Scanning for BLE devices...
Scanning for BLE devices...
Scanning for BLE devices...
(scan)found:Bean d03972d34ce3
matchind device found
(scan)found:Bean d03972d34ce3
matchind device found
(scan)found:Bean d03972d34ce3
matchind device found
Stop Scanning for BLE devices...
connect bean d03972d34ce3
Ready to handle:
{ name: 'bean',
.... // Just cutting the generic bean info from the println above.
}
firm ready
set color null
Successfully subscribed to Bean serial notifications.
| d03972d34ce3 accell:| x:   -1
| d03972d34ce3 accell:| x:    1 
.... //Infinity

Each time I run this, it picks one of the three beans. (all their lights have lit up at least once, and I've seen each ID)

It never grabs any of the other two. You can see the scan initiate thrice, but each time it picks the same target. Connects to one bean, then functions normally. Is the class sharing params with all its instances? Or am I messing up somewhere?

Thanks,
-Boris

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions