Files
mayhem-firmware/firmware/application
Sarah Rose bf5ea0a004 Add KISS TNC external app for APRS RX/TX over USB serial (#3078)
* Add KISS TNC external app for APRS RX/TX over USB serial

Adds a KISS TNC (Terminal Node Controller) app that bridges APRS
packets between the HackRF radio and a connected PC over USB CDC
serial using the KISS protocol.

Features:
- APRS receive at 144.390 MHz (configurable), decoding packets via
  the existing APRS RX baseband (PAPR.bin)
- Received AX.25 frames forwarded to host as KISS-framed data over
  USB serial
- KISS frames received from host transmitted as AFSK audio using the
  existing AFSK TX baseband (PAFT.bin)
- Clean RX->TX->RX baseband switching with proper timing delays
- USB connection status indicator with periodic refresh
- Compatible with standard KISS TNC clients (Xastir, APRSISCE/32,
  Dire Wolf, etc.)

Firmware changes required to support the external app:
- baseband_api.cpp: mark set_aprs() __attribute__((used)) so it is
  retained by the linker for external app use
- protocols/ax25: add make_frame_from_raw() to build NRZI bitstream
  from raw AX.25 bytes, marked __attribute__((used))
- usb_serial_host_to_device: add kiss_raw_handler hook to route
  incoming USB bytes directly to a registered callback, bypassing
  the shell; marked __attribute__((used))
- baseband/proc_aprsrx: add constructor that auto-configures at
  1200 baud so external apps do not need to call set_aprs() at init

* Address PR review: generic RAII USB handler, fix TX cutoff and buffer overflow

- Replace KISS-specific set_kiss_raw_handler() in shared USB code with a
  generic UsbSerialInputHandler RAII class; any app can now register a
  handler via the ctor and it auto-clears in the dtor — no app-specific
  'if' checks in shared code, no __attribute__((used)) needed
- Remove __attribute__((used)) from set_aprs() — it is referenced directly
  by ui_aprs_rx.cpp so it will never be dead-stripped
- Fix send_kiss_frame() buffer overflow: per-byte bounds check prevents
  2-byte escape sequences from writing past the end of the output buffer
- Replace fillOBuffer(TIME_INFINITE) with chOQWriteTimeout(TIME_IMMEDIATE)
  to drop bytes instead of blocking the event loop
- Remove chThdSleepMilliseconds() calls from start_tx() and finish_tx()
- Fix TX cutoff bug: call start_tx() directly from process_kiss_frame()
  instead of deferring via tx_pending_ flag (deferral caused kiss_idx_
  to be 0 by the time start_tx() fired, producing an empty frame)

* Move USB write into UsbSerialInputHandler class

Add a write() method to UsbSerialInputHandler so all USB I/O
(both input callback and output) is encapsulated in the class.
KISS TNC now uses usb_input_handler_->write() instead of calling
chOQWriteTimeout(&SUSBD1.oqueue, ...) directly, keeping raw USB
details out of app code.

* Address PR review: remove auto-configure from APRSRxProcessor, add timeout param to write()

- Remove default_config from APRSRxProcessor() constructor; baseband should
  start unconfigured and wait for APRSRxConfigureMessage from the app side
  (already sent via baseband::set_aprs() in KISS TNC and APRS RX app)
- Remove stray #include "stdio.h" from proc_aprsrx.cpp
- Add systime_t timeout parameter with default TIME_IMMEDIATE to
  UsbSerialInputHandler::write() so callers can choose blocking behaviour
2026-03-10 10:40:27 +01:00
..
2026-03-08 13:39:53 +13:00
2026-03-08 13:39:53 +13:00
2026-01-08 10:34:05 +01:00
2023-05-19 08:16:05 +12:00
2026-02-23 21:37:03 +01:00
2023-10-02 20:19:22 +02:00
2023-10-02 20:19:22 +02:00
2025-12-14 11:26:21 +01:00
2025-12-14 11:26:21 +01:00
2026-02-19 14:33:01 +01:00
2023-07-14 18:46:39 -07:00
2026-02-24 11:23:41 +01:00
2026-02-24 11:23:41 +01:00
2025-12-14 11:26:21 +01:00
2024-11-22 09:54:34 +01:00
2026-02-24 11:23:41 +01:00
2025-04-11 10:46:04 +00:00
2023-12-17 17:20:35 +01:00
2024-11-08 11:46:27 +01:00
2024-11-08 11:46:27 +01:00
2023-06-17 22:01:46 +02:00
2026-02-24 11:23:41 +01:00
2026-01-30 17:18:13 +01:00
2023-05-19 08:16:05 +12:00
2026-02-12 12:41:12 +01:00
2026-01-16 09:57:45 +01:00
2026-01-16 09:57:45 +01:00
2023-05-19 08:16:05 +12:00
2026-02-24 11:23:41 +01:00
2024-11-19 17:16:37 +01:00
2024-11-19 17:16:37 +01:00
2026-03-08 13:39:53 +13:00
2026-02-24 11:23:41 +01:00
2023-08-02 21:59:26 +02:00
2026-03-08 13:39:53 +13:00
2025-11-26 19:13:21 +01:00
2025-11-26 19:13:21 +01:00
2023-05-19 08:16:05 +12:00
2023-05-19 08:16:05 +12:00
2026-02-24 11:23:41 +01:00
2026-02-24 11:23:41 +01:00
2025-09-01 11:50:46 +02:00
2026-02-24 11:23:41 +01:00
2024-11-22 09:54:34 +01:00
2024-11-22 09:54:34 +01:00
2023-05-19 08:16:05 +12:00
2026-02-19 14:33:01 +01:00
2026-02-19 14:33:01 +01:00
2023-12-17 17:20:35 +01:00
2023-12-17 17:20:35 +01:00
2026-02-24 11:23:41 +01:00
2026-02-24 11:23:41 +01:00
2024-11-08 11:46:27 +01:00
2023-05-19 08:16:05 +12:00