You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-26 22:13:53 +01:00
Merge pull request #147 from AmateurAudioDude/update/v1.3.8-setup-options
Update/v1.3.8 setup options
This commit is contained in:
@@ -96,6 +96,7 @@ require('./plugins');
|
|||||||
|
|
||||||
let currentUsers = 0;
|
let currentUsers = 0;
|
||||||
let serialport;
|
let serialport;
|
||||||
|
let timeoutAntenna;
|
||||||
|
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
const sessionMiddleware = session({
|
const sessionMiddleware = session({
|
||||||
@@ -164,7 +165,7 @@ if (serverConfig.xdrd.wirelessConnection === false) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
serialport.write('Q0\n');
|
serialport.write('Q0\n');
|
||||||
serialport.write('M0\n');
|
serialport.write('M0\n');
|
||||||
serialport.write('Z0\n');
|
serialport.write(`Z${serverConfig.antennaStartup}\n`); // Antenna on startup
|
||||||
|
|
||||||
if (serverConfig.defaultFreq && serverConfig.enableDefaultFreq === true) {
|
if (serverConfig.defaultFreq && serverConfig.enableDefaultFreq === true) {
|
||||||
serialport.write('T' + Math.round(serverConfig.defaultFreq * 1000) + '\n');
|
serialport.write('T' + Math.round(serverConfig.defaultFreq * 1000) + '\n');
|
||||||
@@ -181,7 +182,20 @@ if (serverConfig.xdrd.wirelessConnection === false) {
|
|||||||
serialport.write('F-1\n');
|
serialport.write('F-1\n');
|
||||||
serialport.write('W0\n');
|
serialport.write('W0\n');
|
||||||
serverConfig.webserver.rdsMode ? serialport.write('D1\n') : serialport.write('D0\n');
|
serverConfig.webserver.rdsMode ? serialport.write('D1\n') : serialport.write('D0\n');
|
||||||
serialport.write('G00\n');
|
// cEQ and iMS combinations
|
||||||
|
if (serverConfig.ceqStartup === "0" && serverConfig.imsStartup === "0") {
|
||||||
|
serialport.write("G00\n"); // Both Disabled
|
||||||
|
} else if (serverConfig.ceqStartup === "1" && serverConfig.imsStartup === "0") {
|
||||||
|
serialport.write(`G10\n`);
|
||||||
|
} else if (serverConfig.ceqStartup === "0" && serverConfig.imsStartup === "1") {
|
||||||
|
serialport.write(`G01\n`);
|
||||||
|
} else if (serverConfig.ceqStartup === "1" && serverConfig.imsStartup === "1") {
|
||||||
|
serialport.write("G11\n"); // Both Enabled
|
||||||
|
}
|
||||||
|
// Handle stereo mode
|
||||||
|
if (serverConfig.stereoStartup === "1") {
|
||||||
|
serialport.write("B1\n"); // Mono
|
||||||
|
}
|
||||||
serverConfig.audio.startupVolume
|
serverConfig.audio.startupVolume
|
||||||
? serialport.write('Y' + (serverConfig.audio.startupVolume * 100).toFixed(0) + '\n')
|
? serialport.write('Y' + (serverConfig.audio.startupVolume * 100).toFixed(0) + '\n')
|
||||||
: serialport.write('Y100\n');
|
: serialport.write('Y100\n');
|
||||||
@@ -390,6 +404,8 @@ wss.on('connection', (ws, request) => {
|
|||||||
currentUsers++;
|
currentUsers++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (timeoutAntenna) clearTimeout(timeoutAntenna);
|
||||||
|
|
||||||
helpers.handleConnect(clientIp, currentUsers, ws, (result) => {
|
helpers.handleConnect(clientIp, currentUsers, ws, (result) => {
|
||||||
if (result === "User banned") {
|
if (result === "User banned") {
|
||||||
ws.close(1008, 'Banned IP');
|
ws.close(1008, 'Banned IP');
|
||||||
@@ -487,8 +503,46 @@ wss.on('connection', (ws, request) => {
|
|||||||
|
|
||||||
if (currentUsers === 0) {
|
if (currentUsers === 0) {
|
||||||
storage.connectedUsers = [];
|
storage.connectedUsers = [];
|
||||||
output.write('W0\n');
|
|
||||||
output.write('B0\n');
|
if (serverConfig.bwAutoNoUsers === "1") {
|
||||||
|
output.write("W0\n"); // Auto BW 'Enabled'
|
||||||
|
}
|
||||||
|
|
||||||
|
// cEQ and iMS combinations
|
||||||
|
if (serverConfig.ceqNoUsers === "1" && serverConfig.imsNoUsers === "1") {
|
||||||
|
output.write("G00\n"); // Both Disabled
|
||||||
|
} else if (serverConfig.ceqNoUsers === "1" && serverConfig.imsNoUsers === "0") {
|
||||||
|
output.write(`G0${dataHandler.dataToSend.ims}\n`);
|
||||||
|
} else if (serverConfig.ceqNoUsers === "0" && serverConfig.imsNoUsers === "1") {
|
||||||
|
output.write(`G${dataHandler.dataToSend.eq}0\n`);
|
||||||
|
} else if (serverConfig.ceqNoUsers === "2" && serverConfig.imsNoUsers === "0") {
|
||||||
|
output.write(`G1${dataHandler.dataToSend.ims}\n`);
|
||||||
|
} else if (serverConfig.ceqNoUsers === "0" && serverConfig.imsNoUsers === "2") {
|
||||||
|
output.write(`G${dataHandler.dataToSend.eq}1\n`);
|
||||||
|
} else if (serverConfig.ceqNoUsers === "2" && serverConfig.imsNoUsers === "2") {
|
||||||
|
output.write("G11\n"); // Both Enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle stereo mode
|
||||||
|
if (serverConfig.stereoNoUsers === "1") {
|
||||||
|
output.write("B0\n");
|
||||||
|
} else if (serverConfig.stereoNoUsers === "2") {
|
||||||
|
output.write("B1\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle Antenna selection
|
||||||
|
if (timeoutAntenna) clearTimeout(timeoutAntenna);
|
||||||
|
timeoutAntenna = setTimeout(() => {
|
||||||
|
if (serverConfig.antennaNoUsers === "1") {
|
||||||
|
output.write("Z0\n");
|
||||||
|
} else if (serverConfig.antennaNoUsers === "2") {
|
||||||
|
output.write("Z1\n");
|
||||||
|
} else if (serverConfig.antennaNoUsers === "3") {
|
||||||
|
output.write("Z2\n");
|
||||||
|
} else if (serverConfig.antennaNoUsers === "4") {
|
||||||
|
output.write("Z3\n");
|
||||||
|
}
|
||||||
|
}, serverConfig.antennaNoUsersDelay ? 15000 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tunerLockTracker.has(ws)) {
|
if (tunerLockTracker.has(ws)) {
|
||||||
|
|||||||
@@ -106,7 +106,18 @@ let serverConfig = {
|
|||||||
autoShutdown: false,
|
autoShutdown: false,
|
||||||
enableDefaultFreq: false,
|
enableDefaultFreq: false,
|
||||||
defaultFreq: "87.5",
|
defaultFreq: "87.5",
|
||||||
bwSwitch: false
|
bwSwitch: false,
|
||||||
|
bwAutoStartup: "0",
|
||||||
|
bwAutoNoUsers: "0",
|
||||||
|
ceqStartup: "0",
|
||||||
|
ceqNoUsers: "0",
|
||||||
|
imsStartup: "0",
|
||||||
|
imsNoUsers: "0",
|
||||||
|
stereoStartup: "0",
|
||||||
|
stereoNoUsers: "0",
|
||||||
|
antennaStartup: "0",
|
||||||
|
antennaNoUsers: "0",
|
||||||
|
antennaNoUsersDelay: false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function to add missing fields without overwriting existing values
|
// Function to add missing fields without overwriting existing values
|
||||||
|
|||||||
133
web/setup.ejs
133
web/setup.ejs
@@ -39,6 +39,9 @@
|
|||||||
<li role="tab" data-panel="users" tabindex="0">
|
<li role="tab" data-panel="users" tabindex="0">
|
||||||
<a href="#" role="tab" tabindex="-1" aria-controls="users"><i class="fa-solid fa-fw fa-user"></i> User management</a>
|
<a href="#" role="tab" tabindex="-1" aria-controls="users"><i class="fa-solid fa-fw fa-user"></i> User management</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li role="tab" data-panel="startup" tabindex="0">
|
||||||
|
<a href="#" role="tab" tabindex="-1" aria-controls="startup"><i class="fa-solid fa-fw fa-plug"></i> Startup</a>
|
||||||
|
</li>
|
||||||
<li role="tab" data-panel="extras" tabindex="0">
|
<li role="tab" data-panel="extras" tabindex="0">
|
||||||
<a href="#" role="tab" tabindex="-1" aria-controls="extras"><i class="fa-solid fa-fw fa-star"></i> Extras</a>
|
<a href="#" role="tab" tabindex="-1" aria-controls="extras"><i class="fa-solid fa-fw fa-star"></i> Extras</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -218,18 +221,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-50 p-bottom-20">
|
<div class="panel-50 p-bottom-20">
|
||||||
<h3>Experimental</h3>
|
<h3>Experimental</h3>
|
||||||
<p>If you use an USB audio card on Linux, enabling this option might fix your audio issues.</p>
|
<p>If you use a USB audio card on Linux, enabling this option might fix your audio issues.</p>
|
||||||
<%- include('_components', {component: 'checkbox', cssClass: '', label: 'ALSA Software mode', id: 'audio-softwareMode'}) %>
|
<%- include('_components', {component: 'checkbox', cssClass: '', label: 'ALSA Software mode', id: 'audio-softwareMode'}) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<div class="panel-50 p-bottom-20">
|
<div class="panel-50 p-bottom-20 bottom-20">
|
||||||
<h3>FFmpeg</h3>
|
<h3>FFmpeg</h3>
|
||||||
<p>Legacy option for Linux / macOS that could resolve audio issues, but will consume additional CPU and RAM usage.</p>
|
<p>Legacy option for Linux / macOS that could resolve audio issues, but will consume additional CPU and RAM usage.</p>
|
||||||
<%- include('_components', {component: 'checkbox', cssClass: '', label: 'Additional FFmpeg', id: 'audio-ffmpeg'}) %>
|
<%- include('_components', {component: 'checkbox', cssClass: '', label: 'Additional FFmpeg', id: 'audio-ffmpeg'}) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-50 p-botom-20">
|
<div class="panel-50 p-bottom-20 bottom-20">
|
||||||
<h3>Sample rate Offset</h3>
|
<h3>Sample rate offset</h3>
|
||||||
<p>Using a negative value could eliminate audio buffering issues during long periods of listening. <br>
|
<p>Using a negative value could eliminate audio buffering issues during long periods of listening. <br>
|
||||||
However, a value that’s too low might increase the buffer over time.</p>
|
However, a value that’s too low might increase the buffer over time.</p>
|
||||||
<p><input class="panel-33 input-text w-100 auto" type="number" style="min-height: 40px; color: var(--color-text); padding: 10px; padding-left: 10px; box-sizing: border-box; border: 2px solid transparent; font-family: 'Titillium Web', sans-serif;" id="audio-samplerateOffset" min="-10" max="10" step="1" value="0" aria-label="Samplerate offset"></p>
|
<p><input class="panel-33 input-text w-100 auto" type="number" style="min-height: 40px; color: var(--color-text); padding: 10px; padding-left: 10px; box-sizing: border-box; border: 2px solid transparent; font-family: 'Titillium Web', sans-serif;" id="audio-samplerateOffset" min="-10" max="10" step="1" value="0" aria-label="Samplerate offset"></p>
|
||||||
@@ -331,7 +334,7 @@
|
|||||||
|
|
||||||
<%- include('_components', {component: 'text', cssClass: 'w-100', placeholder: '0', label: 'RDS Timeout', id: 'webserver-rdsTimeout'}) %>
|
<%- include('_components', {component: 'text', cssClass: 'w-100', placeholder: '0', label: 'RDS Timeout', id: 'webserver-rdsTimeout'}) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-50 p-bottom-20" style="padding-left: 20px; padding-right: 20px;">
|
<div class="panel-50 p-bottom-20" style="padding-left: 20px; padding-right: 20px; padding-bottom: 80px;">
|
||||||
<h3>Transmitter Search Algorithm</h3>
|
<h3>Transmitter Search Algorithm</h3>
|
||||||
<p>Different modes may help with more accurate transmitter identification depending on your region.</p>
|
<p>Different modes may help with more accurate transmitter identification depending on your region.</p>
|
||||||
<%- include('_components', { component: 'dropdown', id: 'server-tx-id-algo', inputId: 'webserver-txIdAlgorithm', label: 'Transmitter ID Algorithm', cssClass: '', placeholder: 'Algorithm 1',
|
<%- include('_components', { component: 'dropdown', id: 'server-tx-id-algo', inputId: 'webserver-txIdAlgorithm', label: 'Transmitter ID Algorithm', cssClass: '', placeholder: 'Algorithm 1',
|
||||||
@@ -560,6 +563,126 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-full m-0 tab-content no-bg" id="startup" role="tabpanel">
|
||||||
|
<h2>Startup settings</h2>
|
||||||
|
<div class="flex-container">
|
||||||
|
<div class="panel-100-real p-bottom-20" style="z-index: 10; padding-bottom: 120px;">
|
||||||
|
<h3>On startup</h3>
|
||||||
|
<h4>Settings take effect on server launch</h4>
|
||||||
|
<div class="flex-container flex-center p-20">
|
||||||
|
<% if (device === 'tef') { %>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'ceqStartup-dropdown', inputId: 'ceqStartup', label: 'cEQ', cssClass: '', placeholder: 'Disabled',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Disabled' },
|
||||||
|
{ value: '1', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'imsStartup-dropdown', inputId: 'imsStartup', label: 'iMS', cssClass: '', placeholder: 'Disabled',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Disabled' },
|
||||||
|
{ value: '1', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<% } else if (device === 'xdr') { %>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'rfStartup-dropdown', inputId: 'ceqStartup', label: 'RF+', cssClass: '', placeholder: 'Disabled',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Disabled' },
|
||||||
|
{ value: '1', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'ifStartup-dropdown', inputId: 'imsStartup', label: 'IF+', cssClass: '', placeholder: 'Disabled',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Disabled' },
|
||||||
|
{ value: '1', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<% } %>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'stereoStartup-dropdown', inputId: 'stereoStartup', label: 'Stereo Mode', cssClass: '', placeholder: 'Stereo (Default)',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Stereo (Default)' },
|
||||||
|
{ value: '1', label: 'Mono' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
</div>
|
||||||
|
<div class="panel-100-real p-bottom-20 no-bg">
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'antennaStartup-dropdown', inputId: 'antennaStartup', label: 'Antenna', cssClass: '', placeholder: 'Antenna 0 (Default)',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Antenna 0 (Default)' },
|
||||||
|
{ value: '1', label: 'Antenna 1' },
|
||||||
|
{ value: '2', label: 'Antenna 2' },
|
||||||
|
{ value: '3', label: 'Antenna 3' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-container">
|
||||||
|
<div class="panel-100-real p-bottom-20 bottom-20" style="z-index: 9; padding-bottom: 180px;">
|
||||||
|
<h3>On no active users</h3>
|
||||||
|
<h4>Settings take effect immediately after saving</h4>
|
||||||
|
<div class="flex-container flex-center p-20">
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'bwAutoNoUsers-dropdown', inputId: 'bwAutoNoUsers', label: 'Auto BW', cssClass: '', placeholder: 'Unchanged',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Unchanged' },
|
||||||
|
{ value: '1', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<% if (device === 'tef') { %>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'ceqNoUsers-dropdown', inputId: 'ceqNoUsers', label: 'cEQ', cssClass: '', placeholder: 'Unchanged',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Unchanged' },
|
||||||
|
{ value: '1', label: 'Disabled' },
|
||||||
|
{ value: '2', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'imsNoUsers-dropdown', inputId: 'imsNoUsers', label: 'iMS', cssClass: '', placeholder: 'Unchanged',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Unchanged' },
|
||||||
|
{ value: '1', label: 'Disabled' },
|
||||||
|
{ value: '2', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<% } else if (device === 'xdr') { %>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'rfNoUsers-dropdown', inputId: 'ceqNoUsers', label: 'RF+', cssClass: '', placeholder: 'Unchanged',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Unchanged' },
|
||||||
|
{ value: '1', label: 'Disabled' },
|
||||||
|
{ value: '2', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'ifNoUsers-dropdown', inputId: 'imsNoUsers', label: 'IF+', cssClass: '', placeholder: 'Unchanged',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Unchanged' },
|
||||||
|
{ value: '1', label: 'Disabled' },
|
||||||
|
{ value: '2', label: 'Enabled' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
<% } %>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'stereoNoUsers-dropdown', inputId: 'stereoNoUsers', label: 'Stereo Mode', cssClass: '', placeholder: 'Unchanged',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Unchanged' },
|
||||||
|
{ value: '1', label: 'Stereo' },
|
||||||
|
{ value: '2', label: 'Mono' },
|
||||||
|
]
|
||||||
|
}) %><br>
|
||||||
|
</div>
|
||||||
|
<div class="panel-100-real p-bottom-20 no-bg">
|
||||||
|
<%- include('_components', {component: 'checkbox', cssClass: '', label: 'Delayed Antenna Change', id: 'antennaNoUsersDelay'}) %><br>
|
||||||
|
<%- include('_components', { component: 'dropdown', id: 'antennaNoUsers-dropdown', inputId: 'antennaNoUsers', label: 'Antenna', cssClass: '', placeholder: 'Unchanged',
|
||||||
|
options: [
|
||||||
|
{ value: '0', label: 'Unchanged' },
|
||||||
|
{ value: '1', label: 'Antenna 0' },
|
||||||
|
{ value: '2', label: 'Antenna 1' },
|
||||||
|
{ value: '3', label: 'Antenna 2' },
|
||||||
|
{ value: '4', label: 'Antenna 3' },
|
||||||
|
]
|
||||||
|
}) %>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="panel-full m-0 tab-content no-bg" id="extras" role="tabpanel">
|
<div class="panel-full m-0 tab-content no-bg" id="extras" role="tabpanel">
|
||||||
<h2>Extras</h2>
|
<h2>Extras</h2>
|
||||||
<div class="panel-100 p-bottom-20">
|
<div class="panel-100 p-bottom-20">
|
||||||
|
|||||||
Reference in New Issue
Block a user