Compare commits

...

5 Commits

Author SHA1 Message Date
sparks-alec d377df5803 styles for tiny viewports 2023-05-24 01:19:01 -04:00
sparks-alec 1eea4bf342 handle objects better 2023-05-24 01:18:36 -04:00
sparks-alec d3bd8cc88e confirm OCA device is d&b 2023-05-24 00:23:33 -04:00
sparks-alec 76e0a6a87a add basic hostname validation for bonjour devices 2023-05-24 00:22:00 -04:00
sparks-alec 50ccd0bb5a initial d&b commit 2023-05-23 23:37:25 -04:00
9 changed files with 713 additions and 9 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File
+441
View File
@@ -0,0 +1,441 @@
exports.config = {
defaultName: 'd&b Amps',
connectionType: 'TCPsocket',
defaultPort: 30013,
mayChangePort: false,
heartbeatInterval: 1000,
heartbeatTimeout: 5000,
searchOptions: {
type: 'Bonjour',
bonjourName: 'oca',
validateResponse(msg, info) {
return msg.includes('d&b audiotechnik');
},
},
};
exports.ready = function ready(_device) {
const device = _device;
device.data.oca = structuredClone(OCAStructure);
device.data.ocaKeys = Object.keys(device.data.oca);
device.data.ocaIDs = [];
for (let i = 0; i < device.data.ocaKeys.length; i++) {
const key = device.data.oca[device.data.ocaKeys[i]];
key.parameters = [0];
device.data.ocaIDs[i] = key;
ocaCommandRequest(i, key.target, key.method, device);
ocaSubscriptionRequest(i, key.target, key.method, device);
}
};
exports.data = function data(_device, _buffer) {
const device = _device;
if (_buffer[0] === 0x3b && _buffer[1] === 0 && _buffer[2] === 1) {
let start = 0;
while (start < _buffer.length - 3) {
const messageLength = _buffer.readInt32BE(start + 3) + 1;
const message = _buffer.slice(start, start + messageLength);
const messageType = message[7];
if (messageType === 0x04) {
// keep-alive message
} else if (messageType === 0x02) {
// console.log('NOTIFICATION!!');
console.log(message.slice(33));
} else if (messageType === 0x03) {
const messageHandle = _buffer.readInt32BE(start + 14);
const paramCount = message[19];
if (paramCount) {
let paramsStart = 20;
const ocaObj = device.data.ocaIDs[messageHandle];
ocaObj.parameters = [];
while (paramsStart < message.length) {
let paramLength = 0;
let param;
if (ocaObj.format === 'int16' || ocaObj.format === 'float' || ocaObj.format === 'int32') {
paramLength = 2;
param = message.slice(paramsStart, paramsStart + paramLength + 2);
} else if (ocaObj.format === 'int8') {
paramLength = 1;
param = message.slice(paramsStart, paramsStart + paramLength);
} else if (ocaObj.format === 'stringArray') {
const nextBreak = message.indexOf(0x00, paramsStart + 1);
if (nextBreak < 0) {
break;
}
paramLength = nextBreak - paramsStart + 1;
param = message.slice(paramsStart - 1, paramsStart + paramLength - 1).toString();
} else {
paramLength = message.readInt16BE(20);
param = message.slice(paramsStart + 2, paramsStart + 2 + paramLength);
}
if (ocaObj.format === 'string') {
ocaObj.parameters.push(param.toString());
} else if (ocaObj.format === 'stringArray') {
ocaObj.parameters.push(param.toString());
} else if (ocaObj.format === 'float') {
ocaObj.parameters.push(param.readFloatBE(0));
} else if (ocaObj.format === 'int16') {
ocaObj.parameters.push(param.readInt16BE(0));
} else if (ocaObj.format === 'int8') {
ocaObj.parameters.push(param.readInt8(0));
} else if (ocaObj.format === 'int32') {
ocaObj.parameters.push(param.readInt32BE(0));
} else {
ocaObj.parameters.push(param);
}
this.deviceInfoUpdate(device, 'status', 'ok');
paramsStart += paramLength + 2;
}
}
device.draw();
}
start += messageLength;
}
}
};
exports.heartbeat = function heartbeat(device) {
device.send(Buffer.from('3b00010000000b0400010001', 'hex'));
};
function ocaCommandRequest(handle, target, method, device) {
const buf = Buffer.from('3b00010000001a01000100000011AAAAAAAABBBBBBBBCCCCCCCC00', 'hex');
buf.writeInt32BE(handle, 14); // handle
buf.writeInt32BE(target, 18); // target
buf.writeInt32BE(method, 22); // method
device.send(buf);
return buf;
}
function ocaSubscriptionRequest(handle, target, method, device) {
const buf = Buffer.from(
'3b00010000002f01000100000026000000ae00000004000300010510008205000100010000041f000100010000010000',
'hex'
);
buf.writeInt32BE(handle, 14); // handle
buf.writeInt32BE(target, 27); // target
device.send(buf);
return buf;
}
const OCAStructure = {
ModelDescription: {
target: 0x1000010d,
method: 0x00050001,
format: 'string',
},
PwrOn: {
target: 0x10000100,
method: 0x00040001,
format: 'int16',
},
SubNet: {
target: 0x10000109,
method: 0x00050001,
format: 'int32',
},
DeviceId: {
target: 0x10000108,
method: 0x00050001,
format: 'int32',
},
DeviceType: {
target: 0x10000034,
method: 0x00050001,
format: 'string',
},
FirmwareRevision: {
target: 0x10000031,
method: 0x00050001,
format: 'string',
},
ChannelNameA: {
target: 0x10008215,
method: 0x00050001,
format: 'string',
},
ChannelNameB: {
target: 0x10010215,
method: 0x00050001,
format: 'string',
},
ChannelNameC: {
target: 0x10018215,
method: 0x00050001,
format: 'string',
},
ChannelNameD: {
target: 0x10020215,
method: 0x00050001,
format: 'string',
},
DelayA: {
target: 0x10008207,
method: 0x00050001,
format: 'float',
},
DelayB: {
target: 0x10010207,
method: 0x00050001,
format: 'float',
},
DelayC: {
target: 0x10018207,
method: 0x00050001,
format: 'float',
},
DelayD: {
target: 0x10020207,
method: 0x00050001,
format: 'float',
},
InputEnable1A: {
target: 0x10008220,
method: 0x00040001,
format: 'int16',
},
InputEnable2A: {
target: 0x10008221,
method: 0x00040001,
format: 'int16',
},
InputEnable3A: {
target: 0x10008222,
method: 0x00040001,
format: 'int16',
},
InputEnable4A: {
target: 0x10008223,
method: 0x00040001,
format: 'int16',
},
InputEnable5A: {
target: 0x10008224,
method: 0x00040001,
format: 'int16',
},
InputEnable6A: {
target: 0x10008225,
method: 0x00040001,
format: 'int16',
},
InputEnable7A: {
target: 0x10008226,
method: 0x00040001,
format: 'int16',
},
InputEnable8A: {
target: 0x10008227,
method: 0x00040001,
format: 'int16',
},
InputEnable1B: {
target: 0x10010220,
method: 0x00040001,
format: 'int16',
},
InputEnable2B: {
target: 0x10010221,
method: 0x00040001,
format: 'int16',
},
InputEnable3B: {
target: 0x10010222,
method: 0x00040001,
format: 'int16',
},
InputEnable4B: {
target: 0x10010223,
method: 0x00040001,
format: 'int16',
},
InputEnable5B: {
target: 0x10010224,
method: 0x00040001,
format: 'int16',
},
InputEnable6B: {
target: 0x10010225,
method: 0x00040001,
format: 'int16',
},
InputEnable7B: {
target: 0x10010226,
method: 0x00040001,
format: 'int16',
},
InputEnable8B: {
target: 0x10010227,
method: 0x00040001,
format: 'int16',
},
InputEnable1C: {
target: 0x10018220,
method: 0x00040001,
format: 'int16',
},
InputEnable2C: {
target: 0x10018221,
method: 0x00040001,
format: 'int16',
},
InputEnable3C: {
target: 0x10018222,
method: 0x00040001,
format: 'int16',
},
InputEnable4C: {
target: 0x10018223,
method: 0x00040001,
format: 'int16',
},
InputEnable5C: {
target: 0x10018224,
method: 0x00040001,
format: 'int16',
},
InputEnable6C: {
target: 0x10018225,
method: 0x00040001,
format: 'int16',
},
InputEnable7C: {
target: 0x10018226,
method: 0x00040001,
format: 'int16',
},
InputEnable8C: {
target: 0x10018227,
method: 0x00040001,
format: 'int16',
},
InputEnable1D: {
target: 0x10020220,
method: 0x00040001,
format: 'int16',
},
InputEnable2D: {
target: 0x10020221,
method: 0x00040001,
format: 'int16',
},
InputEnable3D: {
target: 0x10020222,
method: 0x00040001,
format: 'int16',
},
InputEnable4D: {
target: 0x10020223,
method: 0x00040001,
format: 'int16',
},
InputEnable5D: {
target: 0x10020224,
method: 0x00040001,
format: 'int16',
},
InputEnable6D: {
target: 0x10020225,
method: 0x00040001,
format: 'int16',
},
InputEnable7D: {
target: 0x10020226,
method: 0x00040001,
format: 'int16',
},
InputEnable8D: {
target: 0x10020227,
method: 0x00040001,
format: 'int16',
},
InputGainA: {
target: 0x10008206,
method: 0x00040001,
format: 'float',
},
InputGainB: {
target: 0x10010206,
method: 0x00040001,
format: 'float',
},
InputGainC: {
target: 0x10018206,
method: 0x00040001,
format: 'float',
},
InputGainD: {
target: 0x10020206,
method: 0x00040001,
format: 'float',
},
SpeakerIDA: {
target: 0x10008214,
method: 0x00040001,
format: 'int16',
},
SpeakerIDB: {
target: 0x10010214,
method: 0x00040001,
format: 'int16',
},
SpeakerIDC: {
target: 0x10018214,
method: 0x00040001,
format: 'int16',
},
SpeakerIDD: {
target: 0x10020214,
method: 0x00040001,
format: 'int16',
},
SpeakerIDList: {
target: 0x10010214,
method: 0x00040005,
format: 'stringArray',
},
OutputMode: {
target: 0x10000111,
method: 0x00040001,
format: 'int16',
},
OutputModeList: {
target: 0x10000111,
method: 0x00040005,
format: 'stringArray',
},
MuteA: {
target: 0x10008205,
method: 0x00040001,
format: 'int8',
},
MuteB: {
target: 0x10010205,
method: 0x00040001,
format: 'int8',
},
MuteC: {
target: 0x10018205,
method: 0x00040001,
format: 'int8',
},
MuteD: {
target: 0x10020205,
method: 0x00040001,
format: 'int8',
},
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.
+108
View File
@@ -0,0 +1,108 @@
table {
color: white;
background-color: #323232;
font-size: 14px;
}
.button {
padding: 4px;
height: 65px;
border-radius: 4px;
position: relative;
text-align: right;
margin: 2px;
box-sizing: border-box;
overflow: hidden;
white-space: nowrap;
}
.light-button {
background: linear-gradient(0deg, #484848, #737373);
outline: black 2px outset;
border-top: #8b8b8b 2px solid;
border-left: #8b8b8b 2px solid;
min-width: 100px;
}
.dark-button {
background: linear-gradient(0deg, #0e0e0e, #282828);
outline: #737373 2px solid;
text-overflow: ellipsis;
white-space: nowrap;
}
.mute {
text-align: center;
background-image: url('muteicon-on.png'), linear-gradient(0deg, #484848, #737373);
background-position: 52px 13px, 0px 0px;
background-repeat: no-repeat;
}
.gain-box {
background-color: #272727;
height: 60px;
width: 65px;
margin: 2px;
border: #656565 2px solid;
outline: #111111 2px solid;
text-align: right;
}
.gain-head {
box-sizing: border-box;
height: 12px;
width: 100%;
background: #686868;
border: #1a1a1a 2px solid;
outline: #656565 2px solid;
margin-bottom: 27px;
}
.gain-box span {
padding: 4px;
}
h3 {
margin: 7px 0px 3px;
margin-left: 12px;
text-align: left;
font-weight: normal;
font-size: 22px;
}
h4 {
text-align: left;
font-size: 16px;
margin: 0px;
}
.channel-input {
position: absolute;
left: 9px;
top: 27px;
border-right: white 1px solid;
padding-right: 40px;
text-align: left;
line-height: 14px;
}
.channel-delay {
position: absolute;
left: 170px;
top: 40px;
}
.power-1 {
background: linear-gradient(0deg, #5a8127, #789b50);
border: #506937 1px solid;
}
.indicate-1 {
background: #00ff00;
border: black 2px inset;
}
.mute-1 {
border-top: #772b26 2px solid;
border-left: #772b26 2px solid;
background-image: url('muteicon-mute.png'), linear-gradient(0deg, #b52714, #c4473e);
}
@media screen and (min-width: 0px) and (max-width: 450px) {
.hide-medium {
display: none;
}
}
@media screen and (min-width: 0px) and (max-width: 300px) {
.hide-small {
display: none;
}
}
+141
View File
@@ -0,0 +1,141 @@
<header>
<h1><%= listName %></h1>
<h2><%= data.oca.FirmwareRevision.parameters[0] %></h2>
</header>
<table>
<tr>
<td>
<div class="button dark-button indicate-<%=data.oca.PwrOn.parameters[0]%>"></div>
</td>
<td width="250px" class="hide-small">
<div class="button dark-button">
<h4><%= data.oca.ModelDescription.parameters[0] %></h4><br>
<span class="hide-medium"><%= data.oca.OutputModeList.parameters[data.oca.OutputMode.parameters[0]+1] %></span>
</div>
</td>
<td class="hide-medium">
<div class="button dark-button">
<h4>ID</h4><br>
<%= data.oca.SubNet.parameters[0] %>.<%= data.oca.DeviceId.parameters[0].toString().padStart(2, '0') %>
</div>
</td>
<td width="95px"><div class="button dark-button power-<%=data.oca.PwrOn.parameters[0]%>"><h4>Power</h4><br>On</div></td>
</tr>
<tr>
<td></td>
<td class="hide-small">
<div class="button light-button">
<h4><%= data.oca.ChannelNameA.parameters[0] %></h4>
<div class="channel-input">
Input<br>
<% if(data.oca.InputEnable1A.parameters[0]){ %> A1 <% } %>
<% if(data.oca.InputEnable2A.parameters[0]){ %> A2 <% } %>
<% if(data.oca.InputEnable3A.parameters[0]){ %> A3 <% } %>
<% if(data.oca.InputEnable4A.parameters[0]){ %> A4 <% } %>
<% if(data.oca.InputEnable5A.parameters[0]){ %> D1 <% } %>
<% if(data.oca.InputEnable6A.parameters[0]){ %> D2 <% } %>
<% if(data.oca.InputEnable7A.parameters[0]){ %> D3 <% } %>
<% if(data.oca.InputEnable8A.parameters[0]){ %> D4 <% } %>
</div>
<div class="channel-delay">
<%= data.oca.DelayA.parameters[0].toFixed(1) %>ms
</div>
</div>
</td>
<td class="hide-medium">
<div class="gain-box">
<div class="gain-head"></div>
<span><%= data.oca.InputGainA.parameters[0].toFixed(1) %>db</span>
</div>
</td>
<td><div class="button light-button mute mute-<%=data.oca.MuteA.parameters[0]%>"><h3>A</h3><%= data.oca.SpeakerIDList.parameters[data.oca.SpeakerIDA.parameters[0]] %></div></td>
</tr>
<tr>
<td></td>
<td class="hide-small">
<div class="button light-button">
<h4><%= data.oca.ChannelNameB.parameters[0] %></h4>
<div class="channel-input">
Input<br>
<% if(data.oca.InputEnable1B.parameters[0]){ %> A1 <% } %>
<% if(data.oca.InputEnable2B.parameters[0]){ %> A2 <% } %>
<% if(data.oca.InputEnable3B.parameters[0]){ %> A3 <% } %>
<% if(data.oca.InputEnable4B.parameters[0]){ %> A4 <% } %>
<% if(data.oca.InputEnable5B.parameters[0]){ %> D1 <% } %>
<% if(data.oca.InputEnable6B.parameters[0]){ %> D2 <% } %>
<% if(data.oca.InputEnable7B.parameters[0]){ %> D3 <% } %>
<% if(data.oca.InputEnable8B.parameters[0]){ %> D4 <% } %>
</div>
<div class="channel-delay">
<%= data.oca.DelayB.parameters[0].toFixed(1) %>ms
</div>
</div>
</td>
<td class="hide-medium">
<div class="gain-box">
<div class="gain-head"></div>
<span><%= data.oca.InputGainB.parameters[0].toFixed(1) %>db</span>
</div>
</td>
<td><div class="button light-button mute mute-<%=data.oca.MuteB.parameters[0]%>"><h3>B</h3><%= data.oca.SpeakerIDList.parameters[data.oca.SpeakerIDB.parameters[0]] %></div></td>
</tr>
<tr>
<td></td>
<td class="hide-small">
<div class="button light-button">
<h4><%= data.oca.ChannelNameC.parameters[0] %></h4>
<div class="channel-input">
Input<br>
<% if(data.oca.InputEnable1C.parameters[0]){ %> A1 <% } %>
<% if(data.oca.InputEnable2C.parameters[0]){ %> A2 <% } %>
<% if(data.oca.InputEnable3C.parameters[0]){ %> A3 <% } %>
<% if(data.oca.InputEnable4C.parameters[0]){ %> A4 <% } %>
<% if(data.oca.InputEnable5C.parameters[0]){ %> D1 <% } %>
<% if(data.oca.InputEnable6C.parameters[0]){ %> D2 <% } %>
<% if(data.oca.InputEnable7C.parameters[0]){ %> D3 <% } %>
<% if(data.oca.InputEnable8C.parameters[0]){ %> D4 <% } %>
</div>
<div class="channel-delay">
<%= data.oca.DelayC.parameters[0].toFixed(1) %>ms
</div>
</div>
</td>
<td class="hide-medium">
<div class="gain-box">
<div class="gain-head"></div>
<span><%= data.oca.InputGainC.parameters[0].toFixed(1) %>db</span>
</div>
</td>
<td><div class="button light-button mute mute-<%=data.oca.MuteC.parameters[0]%>"><h3>C</h3><%= data.oca.SpeakerIDList.parameters[data.oca.SpeakerIDC.parameters[0]] %></div></td>
</tr>
<tr>
<td></td>
<td class="hide-small">
<div class="button light-button">
<h4><%= data.oca.ChannelNameD.parameters[0] %></h4>
<div class="channel-input">
Input<br>
<% if(data.oca.InputEnable1D.parameters[0]){ %> A1 <% } %>
<% if(data.oca.InputEnable2D.parameters[0]){ %> A2 <% } %>
<% if(data.oca.InputEnable3D.parameters[0]){ %> A3 <% } %>
<% if(data.oca.InputEnable4D.parameters[0]){ %> A4 <% } %>
<% if(data.oca.InputEnable5D.parameters[0]){ %> D1 <% } %>
<% if(data.oca.InputEnable6D.parameters[0]){ %> D2 <% } %>
<% if(data.oca.InputEnable7D.parameters[0]){ %> D3 <% } %>
<% if(data.oca.InputEnable8D.parameters[0]){ %> D4 <% } %>
</div>
<div class="channel-delay">
<%= data.oca.DelayD.parameters[0].toFixed(1) %>ms
</div>
</div>
</td>
<td class="hide-medium">
<div class="gain-box">
<div class="gain-head"></div>
<span><%= data.oca.InputGainD.parameters[0].toFixed(1) %>db</span>
</div>
</td>
<td><div class="button light-button mute mute-<%=data.oca.MuteD.parameters[0]%>"><h3>D</h3><%= data.oca.SpeakerIDList.parameters[data.oca.SpeakerIDD.parameters[0]] %></div></td>
</tr>
</table>
+23 -9
View File
@@ -126,15 +126,29 @@ function searchBonjour(pluginType, pluginConfig) {
}
});
DEVICE.registerDevice(
{
type: pluginType,
defaultName: e.name,
port: e.port,
addresses: validAddresses,
},
'fromSearch'
);
if (pluginConfig.searchOptions.validateResponse) {
if (pluginConfig.searchOptions.validateResponse(e.fqdn)) {
DEVICE.registerDevice(
{
type: pluginType,
defaultName: e.name,
port: e.port,
addresses: validAddresses,
},
'fromSearch'
);
}
} else {
DEVICE.registerDevice(
{
type: pluginType,
defaultName: e.name,
port: e.port,
addresses: validAddresses,
},
'fromSearch'
);
}
});
}