Let the config choose protocol 2 or 3, and fall back for one session only.

The default stays v2. A reflector that refuses that version and names the other gets one session of it, then the station announces the configured protocol again.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-22 16:28:42 +02:00
co-authored by Cursor
parent 3533b97d00
commit 2c621d4b7f
21 changed files with 361 additions and 82 deletions
+35 -8
View File
@@ -5,7 +5,6 @@ const configError = document.getElementById("config-error");
const authKey = document.getElementById("authKey");
const authToggle = document.getElementById("auth-toggle");
const configHeight = 680;
let savedSize = null;
let configLoading = false;
let sizeToken = 0;
@@ -31,18 +30,39 @@ function runtime() {
return window.runtime || null;
}
function growWindow() {
function fitConfigWindow() {
const rt = runtime();
if (!rt || !rt.WindowGetSize || !rt.WindowSetSize) {
return;
}
const token = ++sizeToken;
rt.WindowGetSize().then(function (size) {
requestAnimationFrame(function () {
if (token !== sizeToken || config.hidden) {
return;
}
savedSize = size;
rt.WindowSetSize(Math.max(size.w, 420), Math.max(size.h, configHeight));
rt.WindowGetSize().then(function (size) {
if (token !== sizeToken || config.hidden || !size) {
return;
}
if (!savedSize) {
savedSize = size;
}
const needed = Math.ceil(configForm.getBoundingClientRect().height) + 32;
const width = Math.max(size.w, 420);
const applied = rt.WindowSetSize(width, needed);
const after = applied && applied.then ? applied.then(function () {
return rt.WindowGetSize();
}) : Promise.resolve(null);
return after.then(function (now) {
if (!now || token !== sizeToken || config.hidden) {
return;
}
const extra = Math.ceil(document.documentElement.scrollHeight - window.innerHeight);
if (extra > 1) {
rt.WindowSetSize(now.w, now.h + extra);
}
});
});
});
}
@@ -60,6 +80,9 @@ function restoreWindow() {
function showError(message) {
configError.hidden = !message;
configError.textContent = message || "";
if (!config.hidden) {
fitConfigWindow();
}
}
function fillForm(form) {
@@ -68,6 +91,7 @@ function fillForm(form) {
document.getElementById("callsign-field").value = form.callsign || "";
authKey.value = form.authKey || "";
document.getElementById("talkGroup").value = String(form.talkGroup || 0);
document.getElementById("protocol-field").value = form.protocol === "v3" ? "v3" : "v2";
document.getElementById("certificateDir").value = form.certificateDir || "";
document.getElementById("enableLogging").checked = !!form.enableLogging;
document.getElementById("logFile").value = form.logFile || "";
@@ -82,6 +106,7 @@ function readForm() {
callsign: document.getElementById("callsign-field").value,
authKey: authKey.value,
talkGroup: numberValue("talkGroup"),
protocol: document.getElementById("protocol-field").value,
certificateDir: document.getElementById("certificateDir").value,
enableLogging: document.getElementById("enableLogging").checked,
logFile: document.getElementById("logFile").value
@@ -111,9 +136,9 @@ function showConfig() {
return;
}
fillForm(cfg.form || {});
showError(cfg.error);
config.hidden = false;
growWindow();
document.body.classList.add("config-open");
showError(cfg.error);
}).catch(function () {}).then(function () {
configLoading = false;
});
@@ -121,7 +146,9 @@ function showConfig() {
function hideConfig() {
config.hidden = true;
showError("");
document.body.classList.remove("config-open");
configError.hidden = true;
configError.textContent = "";
restoreWindow();
}