# TermTCP CLI

A terminal TCP client for BPQ32 packet radio nodes, written in C with an ncurses TUI. Connects via BPQTermTCP protocol, displays split output/monitor panes, and supports real-time RF frame monitoring with port filtering.

## Features

- ncurses TUI with split output and monitor panes
- BPQ packet radio node support (BPQTermTCP protocol)
- RF monitor with per-port and frame-type filtering
- Auto-populates port names from the BPQ server on connect
- Scrollable output and monitor windows with history
- Input history (Up/Down arrows)
- Session logging to timestamped files
- Multiple host configuration with quick connect
- Unicode box-drawing borders on all menus

## Dependencies

- GCC
- ncurses (wide character support — `libncursesw6`)

### Install dependencies on Debian/Ubuntu

```bash
sudo apt install gcc libncurses-dev
```

## Build

```bash
make -f Makefile_CLI
```

The binary is `./termtcp`.

### Other make targets

```
make -f Makefile_CLI clean     # Remove build artifacts
make -f Makefile_CLI debug     # Build with debug symbols
make -f Makefile_CLI install   # Install to /usr/local/bin/
```

### Manual compile

```bash
gcc -Wall -Wextra -O2 -std=gnu99 -D_XOPEN_SOURCE_EXTENDED \
    -o termtcp termtcp_cli.c -lm -lncursesw
```

## Configuration

On first run, `~/.termtcprc` is created automatically. Edit it to add BPQ nodes:

```ini
[Host0]
Host=10.0.2.7
Port=17023
Username=kb8pmy
Password=yourpassword
Name=Home Node

[Host1]
Host=10.121.15.68
Port=17023
Username=kb8pmy
Password=yourpassword
Name=Water Tower
```

Port names and monitor settings are also saved here automatically.

## Usage

```bash
./termtcp
```

### Key bindings

| Key | Action |
|-----|--------|
| Ctrl+A | Open menu |
| Ctrl+A C | Connect |
| Ctrl+A D | Disconnect |
| Ctrl+A O | Config / host editor |
| Ctrl+A M | Monitor options |
| Ctrl+A L | Toggle session log |
| Ctrl+A H | Help |
| Ctrl+A Q | Quit |
| Up / Down | Input history |
| PgUp / PgDn | Scroll output window |
| Home / End | Scroll monitor window |
| Enter | Send line to server |

### Monitor options (Ctrl+A M)

- Toggle TX, supervisor, nodes, and UI-only filtering
- Toggle monitor pane visibility
- Select which RF ports to monitor (Tab to switch to port selection)

Port names are auto-populated from the BPQ server when you connect.

## BPQ Protocol Notes

- Connects using BPQTermTCP protocol (same as QtTermTCP)
- Sends trace options on connect to enable RF monitoring
- Port list is requested automatically via P8=1 parameter
- Monitor frames delimited by `0xFF` / `0xFE` byte markers
- NODES broadcasts filtered client-side via `>NODES` detection in AX.25 header

## Version

Current: **0.0.53**
