K3 Remote Connector by N3OC Version 4.6.6
-----------------------------------------

K3 Remote Connector is a simple Visual Basic (VB6 SP6) program to allow you to remote an N1MM-wired footswitch, CAT connection and audio connection over the internet (or your local LAN) and optionally, a remote VFO knob. The footswitch itself must be wired to an RS-232 port as described in the N1MM+ interfacing section:

https://n1mmwp.hamdocs.com/setup/interfacing/#hooking-up-a-footswitch

Remote VFO - The remote VFO must be attached to another com port and be capable of sending Elecraft (Kenwood) CAT commands at 38400 baud (baud rate is hard-coded for now so you must run your K3 CAT at 38400 to use the remote VFO functionality). A Contour Shuttle jog wheel is also supported and this device acts as a Windows keyboard so no com port is needed. The jog wheel is configured with its own software and config file information and setup instructions are installed in the K3 Remote Connector program directory.

Remote Audio - K3 Remote Connector works with either Mumble or Sonobus audio. It will work with any Mumble server. I have a Mumble server dedicated to this remote station running at n3oc.dyndns.org and it is set as the default Mumble server. You can change it if needed (or if my server is not available). See section in the User Guide (Help, User Guide menu) for more information on using and setting up the Mumble audio connection. New in version 4.4 and beyond it can also work with Sonobus. Sonobus has some advantages including a peer-to-peer (no server) connection, stereo audio for SO2R, local sidetone, and it has mobile device apps. The installer will install Mumble and/or Sonobus on your PC and the Microsoft VC++ redistributables required to run Mumble if you select those options during install. You can always run install again and add those audio options if you find you need them later.

Shuttle Jog Wheel - Version 3.0 and beyond allows a Contour ShuttlePro or ShuttleXpress jog wheel to be used when configured to send keys F16-F24. See below for the F-key definitions the Shuttle driver must be set for. A pre-configured Shuttle driver file to import into your shuttle driver is available on my web site and is copied to the installation directory. Those filed are K3 Remote Connector.pref and a spreadsheet. See the spreadsheet for instructions on how to configure the Shuttle Contour software to make sure the keyboard definitions are present for F16-F24 for BOTH when K3 Remote Connector has the focus, and when it does not. The keyboard definitions have to be entered TWICE, for both situations. One can be imported, the other has to be added manually.

VB6 only supports com1-com16, so your footswitch & VFO port needs to be com1-com16 to use this program. The remote station N1MM end can use any port, the port limitation is only for the actual footswitch/VFO port or the virtual serial port at the station end that talks to this app, and the virtual serial port for the CAT connection at the remote station end. Any port the app talks to needs to be 1-16. Any virtual port that other apps talk to can be outside of that range.

The program can be used standalone or remote. You can use the footswitch as a PTT source, or click the PTT button with a mouse (or touchscreen) or you can use the spacebar as a PTT. Normally you would use the footswitch as the keyboard and mouse would be busy interfacing with the logging program.

The remote end needs a virtual serial port pair to connect the remote instance of this program to N1MM. You will need to install VSPE (or other virtual port software like com0com) and create a virtual serial port pair. Then connect one end of the pair to the remote instance of K3 Remote Connector and connect the other end to N1MM as described in the N1MM configurator, CW/Other, Footswitch section:

https://n1mmwp.hamdocs.com/setup/the-configurer/#cw-other-serial-port

VSPE can be downloaded here, and only needs to be installed on the remote station end, not on the user end. VSPE is free for x86 (32-bit) OS PCs, and there is a small charge for x64 (64-bit) OS PCs:

http://www.eterlogic.com/Products.VSPE.html

Com0com should also work (but is not tested) and is free.

On the first run, you will be prompted to select an operating mode (remote operator or remote station), a operating mode (remote operator or remote station), and prompted again to select a com port. Note that the operating mode and network mode are set independently, meaning the network server can be the operator and the client be the station, or visa-versa. This is important if you cannot forward the TCP port this program uses at one end or the other. Whichever end you can do port forwarding needs to be the server, and if you cannot forward at one site, it needs to be the client. You MUST be able to forward the TCP port at one end or the other. The default TCP port is 9877, you should use the port forwarding section in your router to forward that external port to the local LAN IP address of the server PC.

IMPORTANT NOTE: There is now a Remote Connector Server running at n3oc.dyndns.org that can be used to run both the remote operator and remote station endpoints as clients avoiding the need for any port forwarding. This means you have the choice of:

	1. 	connecting the remote operator and remote station endpoints to each other
		directly, one as a network client and the other as a network server,
		and port forwarding IS required at the remote server end

	2.	connecting both the remote operator and remote station endpoints to
		a cloud server running Remote Server Connector (at n3oc.dyndns.org)
		in which case both run in the client mode and port forwarding IS NOT
		required - one endpoint uses port 9877 and the other endpoint uses
		port 9878 - currently only one remote user at a time is supported

There is a slight chance you may need visual basic runtime 6.0 installed to use this (VB6 is older depreciated software and has been replaced by .NET, but is still usable for simple tasks like this). Try it first without it, because the runtime modules are included with Windows 10 & Windows 11. If you have XP you will probably need to install VBRun60.exe.

K3 Remote Connector will install the latest VB6 controls with all the security updates in them (the originals had issues) and will register them on your PC in either the system32 or sysWOW64 directories.

Uninstall will cleanly remove everything leaving no trace of this on your system. It will leave the VB6 controls behind because you may have other programs that are already using them. If not, there is no harm leaving them behind.

A program updater has been added. Click Help, Check for Program Update to check for a new version. Please note the N3OC webserver is self-hosted and not very fast. It will take a couple minutes to download the program update, be patient.

Please see the change log for any changes.

Brian N3OC
n3oc.brian@gmail.com


Change log
----------

4.6.6 - fixed an issue where form location would be off screen (negative screen position) if Windows crashes or the app is torn down without a clean exit

4.6.5 - corrected initial update site registry key to n3oc.dyndns.org

4.6.4 - trapped RTE 380 when no MIDI device found, updated updater to version 1.0.2

4.6.3 - replace MD5 has library with a better, faster one. The original one made mistakes on larger file sizes

4.6.2 - bump to version to test updater, no code changes

4.6.1 - minor changes to updater code, shows status message in program window caption better (less blocking) and updater determines file names programmatically.

4.6.0 - added support for CTR2-MIDI controller as a VFO knob. Added autoconnect 1st MIDI device. Changed registry key names to use App.EXEName instead of text strings. Added program updater to Help, Check for Program Updates menu.

4.5.2 - fixed some code bugs concerning menu caption labels of com ports. When you change operator modes, the menu captions of the com ports change from REMOTE OPERATOR: FS and VFO ports to REMOTE STATION: PTT and CAT ports.

4.5.1 - added copyright messages to immediate window and Help, About menu. Fixed runtime error on a first run that had a typo on a variable name during form load and trapped another error for a variable not set on first run.

4.5.0 - adds a button on the audio setup window to check for a Symmetric NAT. A symmetric NAT will prevent Sonobus from running without port forwarding, so this button gives a way to test for that. See the Help, User Guide for more information. Changed the Help, About menu to use the project variables for version number instead of being hard-coded. Updated Help, User Guide to add Sonobus, its setup and recommended Sonobus settings. Added punch-check-gui.exe to the program directory to be used to check for Symmetric NAT when using Sonobus. Updated code to show existing registry value when using menus that allow changing setup values (for example debounce timer, RTTYY offset value, polling timer, etc.). Some housekeeping changes to connection port and port2 variables.

4.42 - adds command line options to the Sonobus audio menu. You can now specify the Sonobus group, user name, password, and if you want Sonobus to run headless (not visible). (If you run Sonobus headless, you have to use the task manager to stop it, working on improving this, consider running it headless as experimental for now.) Changes menu and form text labels depending on mode for clarity. Code efficiency updates to incoming network commands and CAT data.

4.41 - bug fixes, finally fixed the pesky re-connect issue where when a client disconnected, the TCP socket would get stuck in TIME_WAIT for four minutes and you would have to wait to re-connect. K3 RC now properly picks a random local port to use which allows it to re-connect immediately and the original port in TIME_WAIT status times out normally as it is supposed to. Also added a browse button for the exe file location for Audio transport, which adds a new control, ComDlg32.ocx.

4.4 - adds Sonobus as a choice for transporting remote audio. Sonobus does not support starting with command-line parameters, so you need to set up and test Sonobus separately first, and check the option to auto-reconnect to last group, then Footswitch Connector can be used to launch Sonobus at each end.

4.3 - adds new RTTY menu options to define a RTTY offset (usually -2.1 khz) for use when using AFSK RTTY on LSB. This is used in conjunction with the N1MM+ logger AutoTRXUPdate setting in the Digital Interface window. Check that option in N1MM+, and enable the RTTY offset in K3 Remote Connector so that K3 Remote Connector will display the real RTTY frequency instead of the K3 dial frequency. This setting is stored in the registry and will stay on until de-selected in the RTTY menu. Also fixed window title inconsistencies
when started, changed via menu, or autoconnect was used.

4.21-4.23 - minor bug fixes, handle K3 CAT responses better to avoid missing CAT response when winsock reply is split between two packets, added all modes to display on form, re-arranged assignment of Shuttle buttons 1-5 (now Mode Up, A/B, A>B, Split and PTT)

4.2 - changes the way the Contour Shuttle VFO wheel interacts with K3 Remote Connector. Previously, to use the jog wheel, K3 Remote Connector had to have the focus. This was a problem because normally VNC would have the focus for logging, and to use the remote VFO you would have to click in to the K3 Remote Connector window to give it the focus, and then click back to VNC to resume logging.

Now, keystrokes are intercepted at the OS level using user32.dll, so the VFO will work when VNC has the focus. This also means K3 Remote Connector now has behaviors similar to a keystroke logger, which are considered malware in some circumstances. Hopefully no security software will flag this as malicious behavior. I can assure you the keystrokes are only used to send CAT commands to the K3 and nothing else. If you have concerns with this, just shut down K3 Remote Connector before transacting any other business on your PC. My source code is on my web site if anyone wants to check this out.

Note that spacebar PTT only works when K3 Remote Connector has the focus. I was not able to move it to any window having the focus because the spacebar is often used in other programs. Use the footswitch for SSB PTT, it works no matter what has the focus. Or switch to K3 Remote Connector for PTT and back to VNC for logging (not practical).

4.1 - implements a heartbeat between client and server to help detecting when the network connection is down. The Microsoft Active-X winsock control does not always properly detect an abnormal network connection loss and implementing a heartbeat between the client and server ensures that the link going down is detected. When the link goes down, a server will return to listening status for a client. A heartbeat is sent every five seconds, and missing six consecutive heartbeats (30 seconds) will disconnect a client and reset a server to listening status.

4.02 - minor bug fix to fix problem where disconnecting caused the local port to go into TIME_WAIT status preventing reconnection for a couple minutes until the port timed out. You can now disconnect and reconnect immediately. This version is also ready to use the Remote Connector Server (hosted at n3oc.dyndns.org) to connect both the remote operator end and the remote station end as clients avoiding the need for any port forwarding at either end.

4.01 - minor bug fixes: implements a software debounce on an external footswitch on the remote operator end (switch contacts are noisy and com ports are very fast and they see that), adds a new menu item to define the PTT debounce value for the footswitch (0-100ms, suggested 10-40ms), fixes a problem where Mumble would not launch remotely unless remote footswitch was enabled in the menu, fixes a problem where PTT and Split indictor lights did not work at remote end after a CAT poll.

4.0 - Renames everything to K3 Remote Connector (instead of Footswitch Connector). Adds audio support using the Mumble client and installs Mumble and the Microsoft redistributables required to run it on your PC. Mumble needs to run at each end (with a different username for both) and be connected to a Mumble server in order to pass audio. Use the Config Audio window to enter the Mumble parameters and click the Start Audio button to launch Mumble at each end.

3.3 - Version 3.3 adds two-way communications for the K3 CAT commands. The result
of any K3 CAT command is returned to the remote operator end of the link to verify
the command was received at the remote station end. Previously, the command was
just sent and any response was ignored. Enable polling and polling interval in
the Options menu if you want to poll the remote station CAT connection. Display
fields were added to the form for VFO frequency, mode, PTT and split indicators.

3.2 - Version 3.2 upgrades the network connection from clear to AES-256 encryption.
The program will start with a default encryption key of ChangeMe and you can change
this to your own key at each end in the Options, Change Encryption Key menu.

3.1 - Version 3.1 adds the ability to enable or disable the footswitch feature. This will allow Footswitch Connector just to be used for remote VFO if desired, without a footswitch. If the remote VFO is a Contour Shuttle, then no com ports would be required at the remote operator end as the Shuttle is a keyboard and does not use com ports. A com port to Win4k3 would still be required at the remote station end for the CAT connection to Win4k3.

To clarify this, a remote footswitch requires a com port at each end, one for the actual footswitch at the remote operator end (wired as per the N1MM interfacing guide), and one for the PTT cable at the remote station end (wired as per N1MM interfacing guide). VFO however, only requires a com port at the remote station end for the CAT connection to Win4k3 if the VFO type is a Contour Shuttle, because the Shuttle functions as a keyboard. If the VFO type is a WR9R remote VFO, which is an RS-232 device, then a com port is required at each end. 

To configure this properly, if the VFO type is Contour Shuttle, uncheck the VFO Enabled option at the remote operator end, and check it at the remote station end. If the VFO type is a WR9R remote VFO, then check it at both ends, and configure the VFO com port the WR9R VFO is connected to at the remote operator end.

Version 3.1 also allows the PTT cable for the footswitch at the remote station end to either use DTR or RTS as the key line. N1MM only supports DTR as a footswitch input, but if you are not using N1MM and using the actual radio PTT cable then you have the option of using either, as is the accepted practice. (Footswitch connector cannot share the K3 CAT cable for PTT, it has to be a separate com port cable.)

3.01 and 3.02 were minor bug fixes to release 3.0

3.0 - Version 3.0 supports using a Contour ShuttlePro or ShuttleXpress jog wheel as
a remote VFO. Note that Footswitch Connector MUST have the focus (be the active window) for the Shuttle to work. This is not always compatible with using the VNC remote desktop, so you will have to click back and forth to use the remote VFO.

When Footswitch Connector has the focus, and the focus is on the PTT button, version 3.0 and beyond test the keycode of the key that is pressed when the focus is the PTT button. (This does not affect mouse clicks, mouse clicks will PTT as normal.)

If the keyboard is used, the PTT is now activated by the space bar being held down. No other keyboard key will PTT the remote operator end.

The Shuttle driver must be set to send the keyboard keys F16-F24 and those keys are tested on the Footswitch Connector's PTT button and are mapped in the Shuttle driver software as follows:

F14 (125) Shuttle left 7 sends DN7; to the K3 (down 5000hz)
F15 (126) Shuttle right 7 sends UP7; to the K3 (up 5000hz)
F16 (127) Shuttle left 4-6 sends DN4; to the K3 (down 1000hz)
F17 (128) Shuttle right 4-6 sends UP4; to the K3 (up 1000hz)
F18 (129) Shuttle left 1-3 sends DN8; to the K3 (down 100hz)
F19 (130) Shuttle right 1-3 sends UP8; to the K3 (up 100hz)
F20 (131) Shuttle jog left sends DN1; to the K3 (down 10hz)
F21 (132) Shuttle jog right sends UP1; to the K3 (up 10hz)
F22 (133) Shuttle button 4 sends MD3;BW0040; to the K3 (CW, BW 400)
F23 (134) Shuttle button 3 sends MD1;BW0270; to the K3 (LSB, BW 2.7)
F24 (135) Shuttle button 2 sends MD2;BW0270; to the K3 (USB, BW 2.7)

2.1 - Slight tweak to better software debounce the hardwired footswitch keying the DSR on and off. Also reversed the DSR fill colors so PTT would be red and no PTT would be green.

2.0 - Added capability to connect a remote VFO knob to the radio CAT port. This requires using Win4k3 at the remote end and defining another CAT AUX port and a virtual serial port pair to bridge it to the radio CAT stream in Win4k3. At the Remote Operator end, define the VFO Com port and connect a compatible VFO knob to your PC on that port. The VFO knob must send Elecraft (Kenwood) CAT commands. At the Remote Station end, define the serial port pair using the same VFO Port menu, and create a serial port pair and connect the other end to one of the 6 available AUX ports in the 3rd Party SW tab.

1.0 - Initial release. Known issues: occasionally the PTT does hang. This is very rare. If it does, just tap the PTT again to get it to dekey. Worst case, the timeout timer will dekey it in the timeout timer value (default is 30 seconds). Also, if you disconnect the client you need to wait a minute or so for the TCP stack on the client end to clear out before you reconnect. This is not normally an issue, and only shows up if you try to disconnect and reconnect immediately. Give it a minute. I am working on this minor bug.

KNOWN ISSUES
------------

1. PTT timeout does not work properly when holding the spacebar as the PTT source. It will just de-key and re-key. PTT timeout does work properly when using a footswitch, the Contour Shuttle PTT button, or by mouse click on the screen PTT button.

2. Taskbar animation works if the program is run from the desktop or a documents folder, but Windows directory security does not allow taskbar animation if the program is run from its normal install directory in Program Files. I may get rid of taskbar animation due to this, but for now it is still there, just does not work in the taskbar (but does work on the program window's miniature icon).

3. When closing Sonobus remotely, Sonobus presents an are you sure you want to quit dialog, preventing it being closed remotely without some local intervention (clicking on Quit).

