Latter instances of beanio.Board appear to get ignored.
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
Your code looks correct. This is likely a bug with state being kept somewhere in one of the modules. I currently have only one bean so this a bit difficult to test. I should have access to another in about a week.
Ill try to play around with bean-io and ble-bean locally to see if I notice anything. No guarantees that Ill understand all of it though.
Sorry to bug, just checking in if you were able to secure another bean? If not I have a bunch here and can possibly help with testing, although I know that wouldn't be an ideal work flow.
Thanks