Files
bpq_gui/README.md
T

196 lines
20 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# BPQ Console
A local web dashboard for BPQ32: node status, BBS, Winlink, forwarding, chat, traffic monitor, contact journal, station map and an amber Telnet terminal. Callsigns, aliases, locator and ports come from your station configuration. Node.js backend with no external npm dependencies; HTML/CSS/JavaScript frontend.
## Requirements
- Windows and Windows PowerShell 5.1 or later.
- Node.js 20 or later. A portable `node.exe` can be selected with `-NodeExe`.
- BPQ32 installed and running, with `HTTPPORT` configured in its Telnet driver.
- A Telnet `USER` with the `sysop` role. The panel accepts the selected sysop account; its password stays in `BPQ32.cfg`.
- Optional: BPQMail for BBS/Winlink, BPQChat and `TCPPORT` for chat, `FBBPORT` for the monitor. The terminal only needs `TCPPORT`.
Service detection recognises the `BBS` and `CHAT` application command names, case-insensitively. Those applications must actually be running to use their pages. The installer does not install BPQ, configure a modem, change radio frequencies or create forwarding partners.
## Install
Clone or download and extract the project into a writable folder. Start BPQ first. Open PowerShell in the project folder and run a read-only check:
```powershell
.\Install.ps1 -CheckOnly
```
If your normal PowerShell policy blocks local scripts, after reviewing the files you can run them with a policy limited to that process:
```powershell
powershell.exe -NoProfile -ExecutionPolicy RemoteSigned -File .\Install.ps1 -CheckOnly
```
This does not change your user or machine execution policy. Downloaded files may still require unblocking after review; organisation Group Policy remains authoritative.
Install and start:
```powershell
.\Install.ps1
```
Open **http://127.0.0.1:8090** and sign in with the selected BPQ Telnet sysop account. No `npm install` or build step is required.
Detection uses an explicit `-BpqRoot`, `BPQ_ROOT`, the previously saved data folder, `%APPDATA%\BPQ32`, or the folders of running BPQ processes. The HTTP check must identify BPQ before any configuration is written. `-CheckOnly` never saves configuration, starts the panel, registers a task or changes the firewall, even if other switches are present.
Explicit settings:
```powershell
.\Install.ps1 -BpqRoot 'D:\Radio\BPQ data' -Port 8095 -HttpPort 8080 -RadioPort 3 -SysopUser 'admin' -ForwardPeer 'N1TEST'
```
| Option | Purpose |
| --- | --- |
| `-BpqRoot` | Folder containing `BPQ32.cfg`, not necessarily the program installation folder. |
| `-Port` | Web panel port, 1024–65535; default 8090 on first install. |
| `-HttpPort` | BPQ HTTP port; defaults to the Telnet driver setting. Must differ from the panel port. |
| `-RadioPort` | Existing BPQ radio port number. The first is selected initially; multiple modems produce a warning. |
| `-SysopUser` | Existing sysop user; defaults to the first on initial installation. |
| `-ForwardPeer` | Existing BBS forwarding partner for the dashboard shortcut. No partner is created automatically. |
| `-CmsPeer` | Existing CMS forwarding profile; defaults to `RMS`. |
| `-NodeExe` | Full path to a Node.js 20+ `node.exe`. Saved for future startup. |
| `-VaraLogPath` | Optional local `VARAHF.log` used by the journal. A running local VARA log is detected when available. |
| `-EnableRadioCAT` / `-DisableRadioCAT` | Explicitly enable/disable Winlink radio tuning through BPQ. No tuning test or transmission is performed. |
| `-Restart` | Restart this project's web panel after installation/update. Does not restart BPQ or VARA. |
Without a selected forwarding partner the dashboard shortcut is disabled. The Forwarding page can still show and start other configured partners.
## Updates and local settings
Reinstalling for the same BPQ data folder preserves custom settings, including the panel port, CMS profile, VARA options and Winlink CAT opt-in. Changed configuration is backed up as `console.config.json.<timestamp>.backup`, then saved atomically. An unchanged configuration is not rewritten. Invalid JSON, missing selected ports/users or invalid explicit profiles stop installation with an error.
If you select a different station folder, station-specific selections are detected again. If the selected modem changes, CAT opt-in is cleared unless explicitly enabled. Use a separate project folder for each station so journals, caches and recovery state remain separate.
After updating the project:
```powershell
.\Install.ps1 -CheckOnly
.\Install.ps1 -Restart
```
For a normal start or restart without rerunning detection:
```powershell
.\Start-Console.ps1
.\Start-Console.ps1 -Restart
```
Startup checks the port, Node version and the new server's `/health` response. It reports failures instead of claiming success when Node exits. An existing panel on another port is not duplicated. Changed settings require a restart. A Winlink radio session awaiting profile restoration blocks `-Restart`; let that session finish first. Restarting the panel closes its browser/Telnet sessions.
Environment overrides: `BPQ_ROOT` selects the BPQ data folder; `BPQ_CONSOLE_PORT` selects the panel port; `BPQ_CONSOLE_CONFIG` selects a different local JSON configuration file. Install and startup scripts respect these overrides. Use the standard `console.config.json` without temporary environment overrides when registering automatic startup.
Station greetings, ASCII banners, radio schedules, routing and Winlink availability reports remain local BPQ settings. The installer does not overwrite them. Personal BPQ configuration and credentials are not part of this repository.
## Automatic startup and LAN
```powershell
# Start at this Windows user's logon
.\Install.ps1 -AutoStart
# Optional access from the local subnet; requires an administrator shell
.\Install.ps1 -EnableLAN
```
`-AutoStart` registers **BPQ-WebConsole** for the current user, with interactive logon and limited privileges. It uses the saved Node path and process-scoped `RemoteSigned` execution policy. Windows policy may restrict task registration. Remove the task to disable automatic startup. BPQ must have its own startup arrangement.
`-EnableLAN` creates a firewall rule for the selected Node executable and panel port, restricted to the **Private** profile and **LocalSubnet**. Existing rules are replaced only after the new rule is created successfully. From another computer use the BPQ PC's private IPv4 address and panel port. The panel accepts loopback and private IPv4 hosts, not arbitrary DNS hostnames or public addresses.
This is an administrative panel for a trusted PC/LAN, using HTTP. Do not expose it directly to the Internet. Authentication uses HttpOnly/SameSite cookies and writes require Origin/CSRF checks. Configuration, logs, mail files, station locations and runtime caches are excluded from Git.
## Modems and telemetry
VARA is optional. PACTOR, ARDOP, KISS and other BPQ ports show the information their driver exposes; missing data remains unavailable. VARA-specific controls are disabled for other drivers.
**TRAFFICO BPQ** derives TX/RX bit/s from BPQ byte-counter changes, rather than claiming to show the negotiated modem bitrate. The VARA CPU chart only applies to a local VARA process. Remote VARA CPU usage cannot be measured locally. Optional VARA bitrate diagnostics listen on loopback UDP 18514; change `varaSyslogPort` in local configuration if needed. The VARA version must emit bitrate records with CommandsLog enabled. The panel does not open a second VARA TCP control connection.
## BBS, mail and attachments
BBS and Winlink provide folders, search, composition, replies, deletion and B2 attachments, with the message list above the reader. Delete marks a message `K` in BPQ and does not recall mail already delivered elsewhere. The panel uses BPQ's interfaces for writes, never edits `DIRMES.SYS` or `.mes` files directly.
Image, PDF and text attachments have previews and downloads. HTML/SVG are treated as text. Multipart 7plus files are reconstructed from the original message bytes when all parts and CRC checks are valid. Matching uses sender, filename, size, part count, block size and 7plus timestamp, not just the subject. Missing/damaged parts prevent downloading a false result. COR/ERR repair is not implemented. Limits: 32 MB per reconstructed file, 255 parts, 2 MB per scanned message and a 64 MB memory cache. Reference format: [7PLUS 2.25 source](https://ponce.cc/slackware/sources/repo/7pl225sr.zip).
Concurrent readers share in-flight BPQ requests. Dashboard counters and Winlink avoid loading timestamp metadata for every bulletin. The first full BBS listing can take longer on a large archive while exact BPQ timestamps are loaded; subsequent reads reuse the timestamp cache.
Dates use the browser timezone. Arrival notifications distinguish downloaded bulletins and incoming mail from messages you composed; the first load does not announce old messages as new. Sound requires a browser gesture.
## Winlink Internet and radio
Winlink requires `CMS=1`, the BBS application and a configured CMS forwarding profile. **Sync Internet** starts that profile; it does not create a gateway or forwarding configuration.
**Sync Radio** opens the [official public Winlink gateway directory](https://cms.winlink.org:444/GatewayChannels.aspx), without an API key. Search callsign/locator/location, filter by band and opening hours, and sort by distance, callsign or frequency. The modem family selects the directory mode. Cache: 15 minutes; manual refresh is throttled to once per minute. Calls require a directory no older than 30 minutes, an open UTC schedule and a report within six hours. A report does not guarantee reachability or a clear channel. Distance is geographical, not a propagation prediction; VOACAP is not required.
Displayed frequencies are **USB dial**, calculated as the published centre frequency minus 1500 Hz. Verify this offset against your modem setup. Scheduling is UTC; report timestamps use the browser timezone.
Radio connection requires a supported HF modem, available telemetry and working BPQ `RADIO` CAT control. Enable this deliberately:
```powershell
.\Install.ps1 -EnableRadioCAT -Restart
```
Selecting a row does not transmit. **Connetti e sincronizza** explicitly starts the selected gateway. Busy modem/BBS sessions block startup and the panel does not override a busy channel. The CMS profile must normally use `RMS` or `C port CMS` as its Internet script.
Before changing that profile, the panel backs up `BPQMail.cfg` under `BPQMailChat/Backup-winlink-radio-*`. It temporarily disables the profile timer, sets an ATTACH/RADIO/CONNECT script and enables compressed B2 personal mail. Once BPQ streams are idle, it restores the original profile. `winlink-radio.session.json` retains recovery state across panel restarts. Concurrent manual profile edits suspend automatic restoration and expose a restore button. Keep the panel running during the exchange. The initial status confirms a request to BPQ; results and counts come from logs.
## Forwarding, chat and terminal
The home modem card shows the configured `RADIO` scan frequencies, mode, dwell time and current channel. With a compatible local scan controller, checkboxes include/exclude channels (at least one must remain selected). **Sospendi TX** stops the BPQ radio ports and closes radio sessions; **Riprendi radio** reopens them and restores scanning. Internet mail/chat remain available. The panel blocks new radio forwarding while paused or while a change is being applied. These controls change local listening; `WL2KREPORT` channel publication remains separately configured in BPQ.
Rig controls are optional and read-only when no fresh controller acknowledgement is available. Configure local `radioControl` with `rig`, absolute `requestFile` and `statusFile` paths. The panel writes `{revision,enabled:["7050000-USB"],txSuspended:false}`; IDs are integer Hz plus mode, derived from the actual BPQ scan list. The controller must validate requests, wait for radio sessions before changing scan frequencies, apply changes and publish fresh `{at,frequency,txSuspended,appliedRevision,error}` status. Only matching `appliedRevision` confirms completion. The station's controller backs up `BPQ32.cfg`, preserves disabled entries as `; CONSOLE-OFF ...`, reloads rig control and confirms CAT readiness. The installer does not guess CAT/PTT commands or enable this write interface for unknown hardware; supply a compatible controller for that station.
The Winlink radio directory also downloads **PUBLIC Packet** channels when a UZ7HO/KISS/AX.25 port is present. Band filters include VHF (2 m), UHF (70 cm), both, and all bands. Packet channels use the published FM frequency exactly; the 1500 Hz USB offset applies only to HF channels. The channel details show the selected local port. Unsupported packet speeds stay visible with an explanation and cannot be selected; local support defaults to 1200 baud.
Optional `winlinkRadio.packetPort` selects a specific local packet port and `winlinkRadio.packetBaud` declares its configured speed. These settings do not reprogram a TNC: its modem, audio and PTT must already be set up. The current packet client limits selection to 144–146 MHz and 430–440 MHz. Shared-radio installations may configure `winlinkRadio.packetController` with the same request/status file handshake described below. Their controller must acknowledge the requested frequency and keep the modem active while attached/connected. Internet forwarding is temporarily suspended and restored with the same recovery mechanism as HF radio sync. Directory downloads use Internet; the selected mail exchange uses radio.
To publish a local packet gateway, configure BPQ's native `WL2KREPORT` on the packet port (before its `CONFIG` block), using mode `PKT1200`, the exact FM frequency in Hz, the RMS application's callsign, locator and actual UTC hours. BPQ must expose its RMS application on that port. The panel does not publish gateways itself. Reload BPQ after editing and verify the public directory after its next report; saving a line alone does not confirm publication. See the [official BPQ reporting documentation](https://www.cantab.net/users/john.wiseman/Documents/WL2KReporting.html).
**Forwarding** shows configured partners in a compact table. Click a row (or Enter/Space) to expand routing rules, scripts, schedules, queue counts and recent exchanges. Only one row opens at a time; focus survives refresh. Sync buttons are authenticated, serialised and protected against duplicate requests, active sessions and modem use. The next attempt is a log-based estimate; BPQ owns the real timer. Sensitive script commands are masked. Rules remain editable in BPQ.
Optional `manualForwardingRoutes` in local `console.config.json` adds alternate radio paths to an existing BBS partner, without duplicating its queue or creating an automatic schedule:
```json
"manualForwardingRoutes": [
{"id":"N0TEST-VHF","label":"N0TEST · VHF","peer":"N0TEST","port":3,"frequencyMHz":144.825,"mode":"DATA-FM","connectCall":"N0TEST-8"}
]
```
Use your partner's published frequency/callsign and a configured radio port. The button temporarily disables that partner's automatic timer and immediate forwarding, starts an ATTACH/RADIO/CONNECT script, then restores its original profile when BBS streams are idle. The panel saves a backup under `BPQMailChat/Backup-manual-forwarding-*` and recovery state in `manual-forwarding.session.json`; keep it running during the exchange. The normal path's schedule and all routing rules are preserved. Merely listing or expanding the path never calls the station.
Stations with an external scan controller may additionally supply absolute `controller.requestFile` and `controller.statusFile` paths. The panel writes `{id,frequencyMHz,expiresAt}` (90-second reservation); the controller must acknowledge the same `manualRequestId`, `phase:"vhf"`, matching MHz `frequency` and fresh ISO `at`. The selected BPQ port must report `Connected to TNC` and `1200bd` before forwarding starts. The controller must hold the frequency while attached/connected and release it after expiry or `expiresAt:0`. This handshake is intended for a locally configured packet scan controller; it is not installed automatically for other stations.
**Chat** uses the selected sysop's shared session, with rooms, connected users, peer links and private messages. **Monitor** uses BPQTermTCP, with port/direction filters and TXT export. They retain up to 300 chat events and 1000 monitor frames, and disconnect after two minutes without polling.
**Terminale** opens a real Telnet session to the local BPQ `TCPPORT`, automatically authenticating without returning login credentials to the browser. It has amber phosphor styling, scanlines, selectable text and a cursor that respects reduced-motion settings. Enter sends one command; Up/Down browse history. Pulisci clears the screen, Salva testo downloads it, and Disconnetti closes the socket. Scrolling upwards pauses following; the bottom button resumes it.
Each web login has its own terminal/socket and in-memory transcript. Logout/expiry closes it; so do 90 seconds without terminal polling or 15 minutes without commands. Limits: 1000 characters per command, 200,000 output characters and 100 history entries. It is a BPQ line terminal, not a full-screen VT100 or binary YAPP client. Remote HTML and ANSI controls are not executed.
## Journal and map
The journal reconstructs up to 30 days and 5000 sessions from BPQ BBS, Chat and CMSAccess logs, with optional VARA log enrichment. It shows service, direction, transport, outcome, recorded frequency, duration, SNR, attempts, counters and events; filters and CSV export apply to the visible records. Missing/rotated/incomplete logs may prevent reconstructing older contacts. Data is not invented; unknown transport is explained in details. Credential challenges, mail bodies and chat conversations are not exposed in journal events.
The local map uses [Natural Earth](https://www.naturalearthdata.com/about/terms-of-use/) geometry without external tiles or API keys. Your position comes from BPQ's locator. Save remote Maidenhead locators supplied by stations in `station-locations.json` (4, 6 or 8 characters). Points represent locator centres; stations sharing a locator share the point, without artificial displacement. Click a point or trace for callsign, time and contact details. Wheel zoom, drag, zoom buttons and fit-to-network are supported. Traces join stations, not propagation paths or NET/ROM hops. Stations without known locators remain unplotted.
## Verification and troubleshooting
```powershell
npm test
# Or, without npm:
node --test
```
Tests cover protocol parsing, mail/attachments, journal, gateway validation, profile restoration, generic station detection and installer behaviour. Windows tests exercise the PowerShell wrappers in temporary folders, including paths with spaces/apostrophes, duplicate starts, restart and startup failure. They do not create scheduled tasks or firewall rules.
- **BPQ unreachable:** start BPQ and check its Telnet `HTTPPORT`; rerun `-CheckOnly`.
- **Missing service:** check the matching application/port and that BPQMail/BPQChat is running.
- **Wrong modem/sysop after BPQ changes:** rerun installation with the appropriate selection.
- **Port already in use:** choose a different `-Port`; do not reuse BPQ's HTTP port.
- **Changed settings:** use `Start-Console.ps1 -Restart` when no radio profile restoration is pending.
- **Startup fails:** inspect local `server-error.log`. A failed start is not reported as success.
- **Script/task policy blocks execution:** review the files and your Windows policy; organisation restrictions cannot be overridden by the installer.
Third-party PDF.js, font and CMap licences are retained under `public/vendor/pdfjs`; map attribution is in `public/WORLD-MAP-LICENSE.txt`.