You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-27 06:23:53 +01:00
Compare commits
2 Commits
c0d1fee257
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
e14b3f8d11
|
|||
|
42a20330af
|
@@ -185,18 +185,21 @@ function handleData(wss, receivedData, rdsWss) {
|
||||
modifiedData += errorsNew.toString(16).padStart(2, '0');
|
||||
}
|
||||
|
||||
const a = modifiedData.slice(0, 4);
|
||||
const b = modifiedData.slice(4, 8);
|
||||
const c = modifiedData.slice(8, 12);
|
||||
const d = modifiedData.slice(12, 16);
|
||||
const errors = parseInt(modifiedData.slice(-2), 16);
|
||||
rdsWss.clients.forEach((client) => {
|
||||
const errors = parseInt(modifiedData.slice(-2), 16);
|
||||
let data = (((errors & 0xC0) == 0) ? modifiedData.slice(0, 4) : '----');
|
||||
data += (((errors & 0x30) == 0) ? modifiedData.slice(4, 8) : '----');
|
||||
data += (((errors & 0x0C) == 0) ? modifiedData.slice(8, 12) : '----');
|
||||
data += (((errors & 0x03) == 0) ? modifiedData.slice(12, 16) : '----');
|
||||
let data = ((((errors >> 6) & 3) < 3) ? a : '----');
|
||||
data += ((((errors >> 4) & 3) < 3) ? b : '----');
|
||||
data += ((((errors >> 2) & 3) < 3) ? c : '----');
|
||||
data += (((errors & 3) < 3) ? d : '----');
|
||||
|
||||
const newDataString = "G:\r\n" + data + "\r\n\r\n";
|
||||
client.send(newDataString);
|
||||
client.send("G:\r\n" + data + "\r\n\r\n");
|
||||
});
|
||||
|
||||
rdsdec.decodeGroup(parseInt(modifiedData.slice(0, 4), 16), parseInt(modifiedData.slice(4, 8), 16), parseInt(modifiedData.slice(8, 12), 16), parseInt(modifiedData.slice(12, 16), 16));
|
||||
rdsdec.decodeGroup(parseInt(a, 16), parseInt(b, 16), parseInt(c, 16), parseInt(d, 16), errors);
|
||||
legacyRdsPiBuffer = null;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ const pluginsApi = require('./plugins_api');
|
||||
const pjson = require('../package.json');
|
||||
|
||||
const client = new net.Socket();
|
||||
const wss = new WebSocket.Server({ noServer: true, perMessageDeflate: true });
|
||||
const wss = new WebSocket.Server({ noServer: true });
|
||||
const rdsWss = new WebSocket.Server({ noServer: true });
|
||||
const pluginsWss = new WebSocket.Server({ noServer: true, perMessageDeflate: true });
|
||||
|
||||
@@ -46,7 +46,7 @@ const terminalWidth = readline.createInterface({
|
||||
}).output.columns;
|
||||
|
||||
console.log('\x1b[32m' + figlet.textSync("FM-DX Webserver"));
|
||||
console.log('\x1b[32m\x1b[2mby Noobish @ \x1b[4mFMDX.org\x1b[0m');
|
||||
console.log('\x1b[32m\x1b[2mby Noobish @ \x1b[4mFMDX.org + KubaPro010\x1b[0m');
|
||||
console.log("v" + pjson.version)
|
||||
console.log('\x1b[90m' + '─'.repeat(terminalWidth - 1) + '\x1b[0m');
|
||||
|
||||
@@ -458,10 +458,10 @@ wss.on('connection', (ws, request) => {
|
||||
}
|
||||
|
||||
if (tunerLockTracker.has(ws)) {
|
||||
logInfo(`User who locked the tuner left. Unlocking the tuner.`);
|
||||
output.write('wT0\n')
|
||||
tunerLockTracker.delete(ws);
|
||||
serverConfig.publicTuner = true;
|
||||
logInfo(`User who locked the tuner left. Unlocking the tuner.`);
|
||||
output.write('wT0\n')
|
||||
tunerLockTracker.delete(ws);
|
||||
serverConfig.publicTuner = true;
|
||||
}
|
||||
|
||||
if (currentUsers === 0 && serverConfig.enableDefaultFreq === true &&
|
||||
|
||||
@@ -36,9 +36,9 @@ class RDSDecoder {
|
||||
}
|
||||
|
||||
decodeGroup(blockA, blockB, blockC, blockD, error) {
|
||||
const a_error = (error & 0xC0) >> 6;
|
||||
const b_error = (error & 0x30) >> 4;
|
||||
const c_error = (error & 0xc) >> 2;
|
||||
const a_error = (error >> 6) & 3;
|
||||
const b_error = (error >> 4) & 3;
|
||||
const c_error = (error >> 2) & 3;
|
||||
const d_error = error & 3;
|
||||
|
||||
if(this.last_pi_error > a_error) {
|
||||
@@ -46,7 +46,7 @@ class RDSDecoder {
|
||||
this.last_pi_error = a_error;
|
||||
}
|
||||
|
||||
if(b_error != 0) return; // B chooses what group this is, if this has errors, we are screwed
|
||||
if(b_error !== 0) return; // B chooses what group this is, if this has errors, we are screwed
|
||||
|
||||
const group = (blockB >> 12) & 0xF;
|
||||
const version = (blockB >> 11) & 0x1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Libraries / Imports */
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { logDebug, logError, logInfo, logWarn } = require('./console');
|
||||
const { logError, logInfo } = require('./console');
|
||||
|
||||
let configName = 'config';
|
||||
|
||||
@@ -135,9 +135,7 @@ function addMissingFields(target, source) {
|
||||
if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) {
|
||||
if (!target[key]) target[key] = {}; // Create missing object
|
||||
addMissingFields(target[key], source[key]); // Recursively add missing fields
|
||||
} else {
|
||||
if (target[key] === undefined) target[key] = source[key]; // Add missing fields only
|
||||
}
|
||||
} else if(target[key] === undefined) target[key] = source[key]; // Add missing fields only
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ function getStateForCoordinates(lat, lon) {
|
||||
*/
|
||||
function validPsCompare(rdsPs, stationPs) {
|
||||
if (typeof stationPs !== 'string' || typeof rdsPs !== 'string') {
|
||||
consoleCmd.logError(`Invalid TX values. stationPs: ${stationPs}, rdsPs: ${rdsPs}`);
|
||||
consoleCmd.logDebug(`Invalid TX values. stationPs: ${stationPs}, rdsPs: ${rdsPs}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -257,15 +257,6 @@ async function fetchTx(freq, piCode, rdsPs) {
|
||||
stations: [station]
|
||||
}));
|
||||
|
||||
if (filteredLocations.length > 1) {
|
||||
const extraFilteredLocations = filteredLocations.map(locData => ({
|
||||
...locData,
|
||||
stations: locData.stations.filter(station => (station.ps.toLowerCase() === rdsPs.replace(/ /g, '_').toLowerCase()))
|
||||
})).filter(locData => locData.stations.length > 0);
|
||||
|
||||
if (extraFilteredLocations.length > 0) filteredLocations = extraFilteredLocations;
|
||||
}
|
||||
|
||||
// Only check PS if we have more than one match.
|
||||
if (filteredLocations.length > 1) {
|
||||
filteredLocations = filteredLocations.map(locData => ({
|
||||
@@ -273,6 +264,15 @@ async function fetchTx(freq, piCode, rdsPs) {
|
||||
stations: locData.stations.filter(station => validPsCompare(rdsPs, station.ps))
|
||||
})).filter(locData => locData.stations.length > 0);
|
||||
}
|
||||
|
||||
if (filteredLocations.length > 1) {
|
||||
const extraFilteredLocations = filteredLocations.map(locData => ({
|
||||
...locData,
|
||||
stations: locData.stations.filter(station => (station.ps?.toLowerCase() === rdsPs.replace(/ /g, '_').toLowerCase()))
|
||||
})).filter(locData => locData.stations.length > 0);
|
||||
|
||||
if (extraFilteredLocations.length > 0) filteredLocations = extraFilteredLocations;
|
||||
}
|
||||
|
||||
for (let loc of filteredLocations) {
|
||||
loc = Object.assign(loc, loc.stations[0]);
|
||||
|
||||
Reference in New Issue
Block a user