porsager / busylight

node library for busylight
49 stars 17 forks source link

connect loop #31

Open syco opened 1 year ago

syco commented 1 year ago

Hi, I've put together this script to test the light, but I get this output and no light at all:

require('busylight').devices(true);

const bl = require('busylight').get(1);

console.log(bl);

bl.on('disconnected', function (err) {
  console.log("BL disconnected");
  console.log(err);
});

bl.on('connected', function () {
  if (!bl) {
    return console.log('no busylight found');
  }

  bl.defaults({
    keepalive: true, // If the busylight is not kept alive it will turn off after 30 seconds
    color: 'white', // The default color to use for light, blink and pulse
    duration: 100000000, // The duration for a blink or pulse sequence
    rate: 300, // The rate at which to blink or pulse
    degamma: true, // Fix rgb colors to present a better light
    tone: 'Quiet', // Default ring tone
    volume: 0 // Default volume
  });

  console.log("BL connected");
  bl.light('red');
});
$ sudo node exec.js
Busylight {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  options: 1,
  buffer: [
      0,  16,   0, 0,   0, 0, 0, 0, 128, 0, 0,   0,
      0,   0,   0, 0,   0, 0, 0, 0,   0, 0, 0,   0,
      0,   0,   0, 0,   0, 0, 0, 0,   0, 0, 0,   0,
      0,   0,   0, 0,   0, 0, 0, 0,   0, 0, 0,   0,
      0,   0,   0, 0,   0, 0, 0, 0,   0, 0, 0, 255,
    255, 255, 255, 6, 147
  ],
  newProtocol: 10171,
  debug: false,
  connectAttempts: 0,
  getColorArray: [Function (anonymous)],
  _defaults: {
    keepalive: true,
    color: [ 255, 255, 255 ],
    rate: 300,
    degamma: true,
    tone: 'OpenOffice',
    volume: 4
  },
  [Symbol(kCapture)]: false
}
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
BL connected
...
...
...

Any idea why?