Simple library for sending and receiving sACN (E1.31) lighting data. It is not the full E1.31 protocol, but should be close enough for most projects.
This library supports
- Multiple network interfaces
- Multicast and Unicast
- ETC Net4 (coming soon)
npm install stagehack-sacn
const ACNSender = require('stagehack-sACN').Sender;
ACNSender.Start([options]);
var universe = new ACNSender.Universe([universe], [priority]);
interfaces
: Array of IPv4 network interfaces on the device to send from. ex:['192.168.0.40, 10.0.0.5']
cid
: 16-character UUID to represent this device. ex:"036b2d4932174812"
source
: Plaintext name of this device. ex:"Tim's MacBook Pro"
type
:"unicast"
or"multicast"
. Defaults to"multicast"
if neither is provided
universe
: Default:1
priority
: Default:100
const ACNSender = require('stagehack-sACN').Sender;
ACNSender.Start({
interfaces: ["192.168.0.40"]
});
var sender = new ACNSender.Universe(1, 100);
sender.on("ready", function(){
// send as an array
this.send([255, 0, 0, 255]);
// or send as key-value pairs
this.send({
4: 255,
11: 150,
301: 155
});
});
Sender also provides sender.getPossibleInterfaces()
which returns a list of all IPv4 network interfaces on the device. Useful for populating a dropdown or other UI.
Sync is essentially the same as the sender, except that instead of sending something like color data it just sends a signal for everything to update. Most systems won't require this and will just update when they get new information from the Sender
.
const ACNSync = require('stagehack-sACN').Sync;
ACNSync.Start([options]);
var universe = new ACNSync.Universe([universe], [priority]);
interfaces
: Array of IPv4 network interfaces on the device to send from. ex:['192.168.0.40, 10.0.0.5']
cid
: 16-character UUID to represent this device. ex:"036b2d4932174812"
source
: Plaintext name of this device. ex:"Tim's MacBook Pro"
type
:"unicast"
or"multicast"
. Defaults to"multicast"
if neither is provided
universe
: Default:1
priority
: Default:100
const ACNSync = require('stagehack-sACN').Sender;
ACNSync.Start({
interfaces: ["192.168.0.40"]
});
var sync = new ACNSync.Universe(1, 100);
sync.on("ready", function(){
// send as an array
this.send([255, 0, 0, 255]);
// or send as key-value pairs
this.send({
4: 255,
11: 150,
301: 155
});
});
const ACNReceiver = require('stagehack-sACN').Receiver;
ACNReceiver.Start();
var universe = new ACNReceiver.Universe([universe]);
universe
: Default:1
const ACNReceiver = require('./../stagehack-sACN').Receiver;
ACNReceiver.Start();
var receiver = new ACNReceiver.Universe(1);
receiver.on("packet", function(packet){
console.log(packet.getSlots());
});
Setters:
setUniverse
: sets the UniversesetPriority
: sets the PrioritysetCID
: sets the CIDsetSource
: sets the SourcesetSlots
: sets the Slots
Getters:
getUniverse
: gets the UniversegetPriority
: gets the PrioritygetCID
: gets the CIDgetSource
: gets the SourcegetSlots
: gets current Slots (length 1-512)getSequence
: gets current SequencegetBuffer
: returns a Buffer of the complete sACN Packet
- Add "allReady" event for when all Senders/Receivers are ready
- Implement Net4