mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Emit Az/Ele - when working SAT - via Websocket
This commit is contained in:
@@ -509,6 +509,54 @@ $(document).ready(function() {
|
||||
// Expose sendQSOViaWebSocket globally so it can be called from qso.js
|
||||
window.sendQSOViaWebSocket = sendQSOViaWebSocket;
|
||||
|
||||
/**
|
||||
* Send real-time satellite position (azimuth/elevation) via WebSocket
|
||||
* Only sends when using WebSocket CAT and working satellite
|
||||
* @param {string} satName - Satellite name
|
||||
* @param {number} azimuth - Antenna azimuth in decimal degrees
|
||||
* @param {number} elevation - Antenna elevation in decimal degrees
|
||||
* @returns {boolean} - true if sent via WebSocket, false otherwise
|
||||
*/
|
||||
function sendSatellitePositionViaWebSocket(satName, azimuth, elevation) {
|
||||
// Only send if WebSocket is connected and enabled
|
||||
if (!websocket || !websocketEnabled || websocket.readyState !== WebSocket.OPEN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only send for WebSocket radio ('ws')
|
||||
if ($(".radios option:selected").val() != 'ws') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only send if satellite name is provided
|
||||
if (!satName || satName === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// Prepare satellite position message with standard format
|
||||
const satMessage = {
|
||||
type: 'satellite_position',
|
||||
timestamp: new Date().toISOString(),
|
||||
data: {
|
||||
sat_name: satName,
|
||||
azimuth: azimuth,
|
||||
elevation: elevation
|
||||
}
|
||||
};
|
||||
|
||||
// Send via WebSocket
|
||||
websocket.send(JSON.stringify(satMessage));
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.warn('Failed to send satellite position via WebSocket:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Expose sendSatellitePositionViaWebSocket globally so it can be called from qso.js
|
||||
window.sendSatellitePositionViaWebSocket = sendSatellitePositionViaWebSocket;
|
||||
|
||||
/**
|
||||
* Display radio status in the UI
|
||||
* @param {string} state - One of 'success', 'error', 'timeout', 'not_logged_in'
|
||||
|
||||
@@ -981,6 +981,14 @@ function start_az_ele_ticker(tle) {
|
||||
let el=(satellite.radiansToDegrees(lookAngles.elevation).toFixed(2));
|
||||
$("#ant_az").val(parseFloat(az).toFixed(1));
|
||||
$("#ant_el").val(parseFloat(el).toFixed(1));
|
||||
|
||||
// Send real-time azimuth/elevation via WebSocket if using WebSocket CAT and working satellite
|
||||
if (typeof sendSatellitePositionViaWebSocket === 'function') {
|
||||
var satName = $("#sat_name").val();
|
||||
if (satName && satName !== '') {
|
||||
sendSatellitePositionViaWebSocket(satName, parseFloat(az).toFixed(1), parseFloat(el).toFixed(1));
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
$("#ant_az").val('');
|
||||
$("#ant_el").val('');
|
||||
|
||||
Reference in New Issue
Block a user