mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-07-31 17:29:19 +02:00
Merge branch 'main' of https://github.com/NoobishSVK/fm-dx-webserver
This commit is contained in:
+25
-3
@@ -352,9 +352,31 @@ function handleData(wss, receivedData, rdsWss) {
|
|||||||
modifiedData += errorsNew.toString(16).padStart(2, '0');
|
modifiedData += errorsNew.toString(16).padStart(2, '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
rdsWss.clients.forEach((client) => { // Send to /rds endpoint via WebSocket
|
rdsWss.clients.forEach((client) => {
|
||||||
client.send(modifiedData);
|
let dataString = modifiedData.toString();
|
||||||
});
|
let lastTwoChars = dataString.slice(-2);
|
||||||
|
let lastByteValue = parseInt(lastTwoChars, 16);
|
||||||
|
|
||||||
|
let truncatedString = dataString.slice(0, -2);
|
||||||
|
|
||||||
|
if ((lastByteValue & 0x03) !== 0) {
|
||||||
|
truncatedString = truncatedString.slice(0, 4) + '----' + truncatedString.slice(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((lastByteValue & 0x30) !== 0) {
|
||||||
|
truncatedString = truncatedString.slice(0, 8) + '----' + truncatedString.slice(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((lastByteValue & 0x0C) !== 0) {
|
||||||
|
truncatedString = truncatedString.slice(0, 12) + '----';
|
||||||
|
}
|
||||||
|
|
||||||
|
let newDataString = "G:\r\n" + truncatedString + "\r\n\r\n";
|
||||||
|
|
||||||
|
let finalBuffer = Buffer.from(newDataString, 'utf-8');
|
||||||
|
|
||||||
|
client.send(finalBuffer);
|
||||||
|
});
|
||||||
|
|
||||||
rdsparser.parse_string(rds, modifiedData);
|
rdsparser.parse_string(rds, modifiedData);
|
||||||
legacyRdsPiBuffer = null;
|
legacyRdsPiBuffer = null;
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ function checkEs() {
|
|||||||
|
|
||||||
if (now - esSwitchCache.lastCheck < esFetchInterval) {
|
if (now - esSwitchCache.lastCheck < esFetchInterval) {
|
||||||
esSwitch = esSwitchCache.esSwitch;
|
esSwitch = esSwitchCache.esSwitch;
|
||||||
} else {
|
} else if (serverConfig.identification.lat > 20) {
|
||||||
esSwitchCache.lastCheck = now;
|
esSwitchCache.lastCheck = now;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
|
|||||||
Reference in New Issue
Block a user