1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

toasts, freq bugfixes, ui changes

This commit is contained in:
NoobishSVK
2024-09-11 23:48:46 +02:00
parent 3ea9b8cb82
commit 5261f95dfe
13 changed files with 134 additions and 27 deletions

View File

@@ -109,7 +109,8 @@ const callbacks = {
), 'callback_af*'),
ecc: koffi.register(rds => (
value = rdsparser.get_ecc(rds)
value = rdsparser.get_ecc(rds),
dataToSend.ecc = value
), 'callback_ecc*'),
country: koffi.register(rds => (
@@ -218,6 +219,7 @@ var dataToSend = {
ta: 0,
ms: -1,
pty: 0,
ecc: null,
af: [],
rt0: '',
rt1: '',

View File

@@ -4,6 +4,7 @@ const router = express.Router();
const fs = require('fs');
const { SerialPort } = require('serialport')
const path = require('path');
const https = require('https');
// File Imports
const { parseAudioDevice } = require('./stream/parser');
@@ -124,7 +125,7 @@ router.get('/setup', (req, res) => {
});
router.get('/rds', (req, res) => {
res.send('Please connect using a WebSocket compatible app to obtain RDS stream.');
res.send('Please c onnect using a WebSocket compatible app to obtain RDS stream.');
});
router.get('/rdsspy', (req, res) => {
@@ -258,5 +259,63 @@ router.get('/ping', (req, res) => {
res.send('pong');
});
router.get('/log_fmlist', (req, res) => {
const clientIp = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
const postData = JSON.stringify({
station: {
freq: dataHandler.dataToSend.freq,
pi: dataHandler.dataToSend.pi,
id: dataHandler.dataToSend.txInfo.id,
rds_ps: dataHandler.dataToSend.ps,
signal: dataHandler.dataToSend.sig,
tp: dataHandler.dataToSend.tp,
ta: dataHandler.dataToSend.ta,
af_list: dataHandler.dataToSend.af,
},
server: {
uuid: serverConfig.identification.token,
latitude: serverConfig.identification.lat,
longitude: serverConfig.identification.lon,
address: serverConfig.identification.proxyIp.length > 1 ? serverConfig.identification.proxyIp : ('Matches request IP with port ' + serverConfig.webserver.port),
webserver_name: serverConfig.identification.tunerName,
},
client: {
request_ip: clientIp
},
log_msg: `PS: ${dataHandler.dataToSend.ps}, PI: ${dataHandler.dataToSend.pi}, Signal: ${dataHandler.dataToSend.sig.toFixed(0)} dBf`
});
const options = {
hostname: 'api.fmlist.org',
path: '/fmdx.org/slog.php',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': postData.length,
}
};
const request = https.request(options, (response) => {
let data = '';
response.on('data', (chunk) => { // Collect the response data
data += chunk;
});
response.on('end', () => {
res.status(200).send(data);
});
});
request.on('error', (error) => {
console.error('Error sending POST request:', error);
res.status(500).send(error);
});
request.write(postData);
request.end();
});
module.exports = router;

View File

@@ -61,7 +61,8 @@ function processData(data, piCode, rdsPs) {
if (esMode && (distance.distanceKm > 500)) {
weightDistance = Math.abs(distance.distanceKm-1500);
}
const score = (10*Math.log10(station.erp*1000)) / weightDistance; // Calculate score
let erp = (station.erp && station.erp > 0) ? station.erp : 1;
const score = (10*Math.log10(erp*1000)) / weightDistance; // Calculate score
if (score > maxScore) {
maxScore = score;
txAzimuth = distance.azimuth;
@@ -78,7 +79,7 @@ function processData(data, piCode, rdsPs) {
return {
station: matchingStation.station.replace("R.", "Radio "),
pol: matchingStation.pol.toUpperCase(),
erp: matchingStation.erp,
erp: (matchingStation.erp && matchingStation.erp > 0) ? matchingStation.erp : '?',
city: matchingCity.name,
itu: matchingCity.itu,
distance: maxDistance.toFixed(0),