initial commit adding Shure Wireless

This commit is contained in:
sparks-alec
2022-12-29 08:01:09 -05:00
parent 93be649ce2
commit 09f396c853
6 changed files with 193 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File
+111
View File
@@ -0,0 +1,111 @@
const _ = require('lodash');
exports.config = {
defaultName: 'Shure Wireless',
connectionType: 'TCPsocket',
heartbeatInterval: 10000,
heartbeatTimeout: 15000,
defaultPort: 2202,
mayChangePort: false,
searchOptions: {
type: 'UDPsocket',
searchBuffer: Buffer.from([0x25, 0x32, 0x53, 0x52, 0x43, 0x48, 0x0d]),
devicePort: 4352,
listenPort: 4352,
validateResponse(msg, info) {
console.log(msg.toString());
return msg.toString().indexOf('%2ACKN=') >= 0;
},
},
};
let blankChannel = {
chan_name: '?',
batt_bars: '',
batt_charge: '',
batt_cycle: '',
batt_health: '',
batt_run_time: '',
batt_temp_c: '',
batt_temp_f: '',
batt_type: '',
audio_gain: '',
audio_mute: '',
tx_mute_button_status: '',
audio_lvl: 0,
rx_rf_lvl: 0,
};
exports.ready = function ready(device) {
device.data.channels = [
{},
_.clone(blankChannel),
_.clone(blankChannel),
_.clone(blankChannel),
_.clone(blankChannel),
];
};
exports.data = function data(device, message) {
let msgStr = message.toString();
if (!msgStr.startsWith('< ')) {
return;
}
msgStr = msgStr.slice(2).slice(0, -1);
let msgs = msgStr.split('><');
msgs.forEach((msg, i) => {
msg = msg.trim();
let m = msg.split(' ');
// console.log(msg);
let ch = device.data.channels[Number(m[1])];
//console.log(m);
if (m[0] == 'REP') {
if (m[2] == 'CHAN_NAME') {
ch.chan_name = msg.substring(17).slice(0, -2).trim();
} else if (m[2] == 'BATT_RUN_TIME') {
ch.batt_run_time = Number(m[3]);
} else if (m[2] == 'BATT_TEMP_F') {
ch.batt_temp_f = Number(m[3]);
} else if (m[2] == 'BATT_HEALTH') {
ch.batt_health = Number(m[3]);
} else if (m[2] == 'AUDIO_GAIN') {
ch.audio_gain = Number(m[3]);
} else if (m[2] == 'AUDIO_MUTE') {
ch.audio_mute = m[3];
} else if (m[2] == 'TX_MUTE_BUTTON_STATUS') {
ch.tx_mute_button_status = m[3];
} else if (m[2] == 'AUDIO_LVL') {
ch.audio_lvl = Number(m[3]);
} else if (m[2] == 'RX_RF_LVL') {
ch.rx_rf_lvl = Number(m[3]);
} else if (m[2] == 'RF_ANTENNA') {
ch.rf_antenna = m[3];
} else if (m[1] == 'DEVICE_ID') {
let id = msg.substring(15).slice(0, -1).trim();
this.deviceInfoUpdate(device, 'defaultName', id);
} else if (m[1] == 'FW_VER') {
device.data.version = m[2].substring(1);
}
} else if (m[0] == 'SAMPLE') {
ch.rf_antenna = m[3];
ch.rx_rf_lvl = Number(m[4]);
ch.audio_lvl = Number(m[5]);
}
});
device.draw();
};
exports.heartbeat = function heartbeat(device) {
device.send('< GET 0 ALL >');
device.send('< GET MODEL >');
//device.send('< SET 0 METER_RATE 00000 >');
//device.send('< SAMPLE 0 AUDIO_LVL>');
};
+34
View File
@@ -0,0 +1,34 @@
table.channel {
width: 120px;
height: 400px;
background-color: black;
border: gray 1px solid;
border-collapse: collapse;
color: white;
text-align: center;
float: left;
}
table td {
border: #666 1px solid;
}
.chan_name {
width: 100px;
color: #b2ff33 !important;
font-size: 18px;
font-weight: bold;
}
.mute-button {
background-color: #222;
padding: 10px;
margin: 5px;
border-radius: 4px;
}
.mute-button.red {
background-color: red;
}
small {
color: gray;
}
+47
View File
@@ -0,0 +1,47 @@
<header>
<h1><%= listName %></h1>
<h2><%= data.version || "" %></h2>
</header>
<% for(let i=1; i<=4; i++){ %> <% let ch = data.channels[i]; %>
<table class="channel">
<tr>
<td colspan="2"><%= i %></td>
</tr>
<tr>
<td colspan="2" class="chan_name"><%= ch.chan_name %></td>
</tr>
<tr>
<td><%= ch.audio_gain %>db</td>
<td><%= ch.audio_lvl %></td>
</tr>
<tr>
<td colspan="2">
<% if(ch.audio_mute=="ON" || ch.tx_mute_button_status=="PRESSED"){ %>
<div class="mute-button red">
<% if(ch.audio_mute=="ON"){ %>
<span>Receiver Muted</span>
<% } %>
<span></span>
<% if(ch.tx_mute_button_status=="PRESSED"){ %>
<span>TRANSMITTER MUTE PRESSED</span>
<% } %>
</div>
<% }else{ %>
<div class="mute-button">NOT MUTED</div>
<% } %>
</td>
</tr>
<tr>
<td colspan="2"><small>RF Level</small><br /><%= ch.rx_rf_lvl %>dbm</td>
</tr>
<tr>
<td colspan="2">
<br /><small>Time: </small><%= ch.batt_run_time %> <br /><small
>Health: </small
><%= ch.batt_health %> <br /><small>Temp: </small><%= ch.batt_temp_f %>F
</td>
</tr>
</table>
<% } %>
+1 -1
View File
@@ -232,7 +232,7 @@ module.exports.deleteActive = function deleteActive() {
module.exports.changeActiveType = function changeActiveType(newType) {
const device = VIEW.getActiveDevice();
device.type = newType;
device.fields = {};
device.fields = [];
device.plugin = PLUGINS.all[newType];
if (PLUGINS.all[device.type].config.fields) {