KISS File Transfer WebSockets Gateway Documentation

This program serves as a WebSockets and raw TCP gateway for KISS data. It establishes a connection to an underlying device—using either a serial port or a TCP connection—reads KISS-framed data, and then:

Table of Contents

Overview

The WebSockets Gateway is designed to integrate with a KISS TNC device. It opens a connection to the device using either a serial port or a TCP connection, reads data framed using the KISS protocol, and:

Installation & Build

To build the WebSockets Gateway, ensure you have Go installed. Then compile the program using:

go build -o websockets websockets.go
  

Command‑Line Options

The table below lists all available command‑line options along with their descriptions and default values:

Flag Description Default Value
-connection Type of connection to the device. Must be either serial or tcp. none
-serial-port Device file for the serial connection (e.g. /dev/ttyUSB0 or COM3). Required when using a serial connection. empty
-baud Baud rate for the serial connection. 115200
-host TCP host or IP to connect to when -connection is set to tcp. empty
-port TCP port to connect to when -connection is set to tcp. 0
-listen-ip IP address on which to bind the HTTP server (serving both the Socket.IO endpoint and static files). 0.0.0.0
-listen-port Port on which to bind the HTTP server. The raw TCP server will bind on this port + 1. 5000
-debug Enable verbose debug logging. false
-tcp-read-deadline For TCP-based TNC connections, specifies the read deadline in seconds. If no data is received within this period (default is 600 seconds), the connection is considered stalled and a reconnect is triggered. 600
-web-root Path to the HTML files which will be served from the built in web server. Usually you would want to point to where the web based application lives. Defaults to current working directory. .

Examples

Example 1: Using a Serial Connection

This command opens a serial connection to the device on /dev/ttyUSB0 with a baud rate of 115200, and starts the HTTP server on port 5000 (with raw TCP on port 5001). Specifies /home/web/html as the web root.

go run websockets.go -connection=serial -serial-port=/dev/ttyUSB0 -baud=115200 -web-root /home/web/html
  

Example 2: Using a TCP Connection with Default Read Deadline

This command connects to the device over TCP at 192.168.1.50:8000 and starts the HTTP server on port 5000. It uses the default read deadline of 600 seconds. If no data is received within 600 seconds, the gateway will reconnect to the device.

go run websockets.go -connection=tcp -host=192.168.1.50 -port=8000
  

Example 3: Using a TCP Connection with a Custom Read Deadline

This command connects to the device over TCP at 192.168.1.50:8000 but sets the read deadline to 300 seconds.

go run websockets.go -connection=tcp -host=192.168.1.50 -port=8000 -tcp-read-deadline=300
  

Example 4: Custom HTTP Server Binding

This command runs the gateway with a TCP connection to the device, but binds the HTTP server to IP 127.0.0.1 on port 8080 (with raw TCP listening on port 8081):

go run websockets.go -connection=tcp -host=192.168.1.50 -port=8000 -listen-ip=127.0.0.1 -listen-port=8080
  

Example 5: Enabling Debug Logging

To enable verbose output for troubleshooting, use the -debug flag:

go run websockets.go -connection=serial -serial-port=COM3 -baud=115200 -debug
  

Additional Notes

Contact & Support

For further questions, suggestions, or to report issues, please contact the project maintainer or visit the project's repository.