GMA Rig Connector v4.6 for Windows
==================================

Welcome to the GMA Rig Connector!

The connector links GMA Spider and GMA RigTest to your amateur radio
transceiver. Clicking a spot frequency provides CAT/QSY control
(frequency and operating mode). Since v4.5: CW transmission from
GMA Spider through the local connector.

What's new in v4.6
------------------
- Select CW keying with cw_method = hamlib or rts in config.json.
- RTS keying for radios without Hamlib send_morse support (suitable
  wiring/keying hardware required).
- CW transmission via Hamlib from GMA Spider (click a CW badge).
- Local CW test page: http://127.0.0.1:8088/cw-test
- CW access from explicitly allowed GMA website origins.
- Local-only HTTP listener on 127.0.0.1:8088.
- Existing CAT/QSY functionality is retained.

Requirements
------------
- Windows 10 or 11, Windows PowerShell 5.1
- Hamlib 4.7 or later
- Hamlib-supported transceiver with a working CAT connection
- cw_method=hamlib requires Hamlib send_morse support from the radio.
  CAT support alone does not guarantee CW text transmission.
- cw_method=rts requires an accessible RTS line and suitable CW keying
  hardware; an optocoupler-isolated interface may be necessary.

Installing / upgrading from v4.3 through v4.5
----------------------------------------
1. Stop the running connector.
2. Copy the v4.6 script as start-server.ps1 into the connector
   folder (back up the previous version).
3. Back up config.json and add cw_method: "hamlib" or "rts".
4. Open PowerShell in that folder and run:

   powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\start-server.ps1

5. Leave the PowerShell window open while using the connector.

IMPORTANT: Older batch launchers may still start an older script.
Until those launchers have been updated, use the command above.
The existing folder name gmarig-v4.3 may be retained temporarily.

Configuration
-------------
The active config.json is read on startup. Copy a radio-specific
example to config.json and restart the connector when changing radios.
Example files include:
- config-template.json
- config-xiegu-x6100.json
- config-xiegu-x9100.json
- config-yaesu-ftdx1200-serial.json

Version 4.6 uses the flat JSON configuration structure, e.g.:
  "connection": "serial",
  "cw_method": "hamlib"

CW keying methods:
  "hamlib": Send CW text using Hamlib send_morse; e.g. Yaesu FTDX1200
            (Hamlib 1034, COM5, 4800 baud, SCU-17).
  "rts":    Key CW via the serial port's RTS control line; e.g. Xiegu
            X6100 (Hamlib 3087, COM19, 19200 baud).
            RTS must actually be connected to CW keying hardware;
            CAT alone is not enough. X6100 RTS operation still needs
            on-air/hardware verification.

Both methods continue to use Hamlib for CAT/QSY. A nested rigctld-style
JSON file is not compatible with this flat serial configuration.

For Yaesu FTDX1200 QSY, frequency -> short delay -> mode is useful
(order=freq-first, delay_after_freq=250), if supported by your config.

Testing
-------
CAT/QSY: https://www.gma.rocks/rigtest/
Local CW: http://127.0.0.1:8088/cw-test
CW in Spider: https://www.gma.rocks/spider/

In Spider, click a CW badge to open the CW panel. F2 through F8,
editable macros, and free-text CW are available.
Placeholders: &hiscall, &mycall, &name, &rst, and &ref.
The operator name is retrieved from the GMA Locator API when available.
*NONE or an empty operator field means no name is transmitted.
The '9 as N' option converts 599 to 5NN for transmission only;
the logged RST remains unchanged.
Macros and the option are stored in the local browser profile.


CW keying interfaces and construction references
------------------------------------------------
Radios such as the Yaesu FT-817, FT-818 and FT-857 need a suitable external keying
interface between serial RTS and the radio's KEY jack. Galvanic
isolation with an optocoupler is recommended. Do NOT connect RTS
directly to the KEY jack: check voltage levels, polarity, pinout and
permitted keying current in the radio manual. Test with a meter before
connecting the radio. The USB-to-serial adapter must expose RTS.
CAT control and the CW KEY input are different connections.

Further reading (external sources; verify compatibility with your radio):

1. F4EZC: Opto-isolated PTT/CW interface (French):
   https://geip.qrvradio.fr/Divers/Interface_opto_PTT.pdf
2. FUNKAMATEUR 08/2007: Simple CW keying via RS232 (German),
   from printed page 871. Note: the article keys CW using DTR;
   adapt the control input for RTS operation with this connector.
   https://www.worldradiohistory.com/INTERNATIONAL/FunkAmateur/FunkAmateur-2007-08.pdf
3. DO2PHS: Understanding and building a CW keying interface (German).
   Uses FLDigi/audio keying rather than direct RTS:
   https://do2phs.de/index.php/projekte/ltspice-fldigi-cw-keying-interface-verstehen-und-bauen
4. Elektor 07-08/2014: Opto-isolated PTT/CW interface,
   from printed page 26 (English):
   https://radio-hobby.org/uploads/journal/ElektorElectronics/2014/elektor_07-08.pdf
5. N1MM Logger+: Interfacing and serial CW/PTT keying (English):
   https://n1mmwp.hamdocs.com/setup/interfacing/

These are references, not a guarantee that any circuit can be connected
unchanged to every transceiver.

Safety
------
- First test using a dummy load and low power.
- CW sends real RF: review macro text before transmitting.
- Hamlib does not provide reliable CW abort for the tested FTDX1200;
  keep transmissions short.
- Do not expose local port 8088 to the Internet.
- Run only one connector instance at a time.

Troubleshooting
---------------
Port 8088 busy: Stop the existing connector instance specifically.
Windows HTTP.sys may report PID 4 as the listener. Never terminate
PID 4; identify the actual PowerShell connector by its command line.

CAT failure: Check COM port, baud rate, Hamlib model, and connection.
CW failure with hamlib: Verify Hamlib send_morse support, CW mode,
and the local CW test page.
CW failure with rts: Check cw_method, COM port, RTS wiring and the
external keying interface. A CAT connection is not a KEY jack.

Disclaimer / No warranty
------------------------
All information, circuit diagrams, construction instructions and
software are provided AS IS, WITHOUT WARRANTY OF ANY KIND. This also
applies to third-party circuits and instructions linked in this document.
Building, connecting and operating any hardware or software is entirely
at your own risk. Check the pinout, voltage levels, polarity and
permitted keying current for your specific radio before connecting it.
To the extent permitted by applicable law, no liability is accepted for
damage to transceivers, computers, interfaces or other equipment, or
for consequential damages.

73 de DL4MFM
