Module gateway

Module gateway 

Source
Expand description

Integrated D-STAR gateway client for the TH-D75.

Manages the MMDVM session, tracks voice transmissions, decodes slow data messages, and maintains a last-heard list. This is the building block for D-STAR reflector clients — it handles the radio side of the gateway while the user provides the network side.

§Architecture

The TH-D75 in Reflector Terminal Mode acts as an MMDVM modem. This client manages that modem interface:

[Radio] <--MMDVM BT/USB--> [DStarGateway] <--user code--> [Reflector UDP]

The gateway does NOT implement reflector protocols (DExtra/DCS/DPlus) — those are separate concerns. This client provides:

  • Voice frame relay (radio to user, user to radio)
  • D-STAR header management
  • Slow data text message decode/encode
  • Last heard tracking
  • Connection lifecycle

§Design

The DStarGateway owns an mmdvm::AsyncModem via an MmdvmSession. The mmdvm crate’s async shell handles MMDVM framing, periodic GetStatus polling, and TX-buffer slot gating in a spawned task; the gateway consumes the mmdvm::Event stream, translates it into DStarEvents, and forwards TX frames through the handle’s send_dstar_* methods.

Create a gateway with DStarGateway::start, which enters MMDVM mode and initializes D-STAR, and tear it down with DStarGateway::stop, which exits MMDVM mode and returns the Radio for other use.

§Example

use kenwood_thd75::{Radio, DStarGateway, DStarGatewayConfig};
use kenwood_thd75::transport::SerialTransport;

let transport = SerialTransport::open("/dev/cu.usbmodem1234", 115_200)?;
let radio = Radio::connect(transport).await?;

let config = DStarGatewayConfig::new("N0CALL");
let mut gw = DStarGateway::start(radio, config).await.map_err(|(_, e)| e)?;

while let Some(event) = gw.next_event().await? {
    match event {
        kenwood_thd75::DStarEvent::VoiceStart(header) => {
            println!("TX from {} to {}", header.my_call, header.ur_call);
            // Forward header to reflector...
        }
        kenwood_thd75::DStarEvent::VoiceData(frame) => {
            let _ = frame; // Forward AMBE + slow data to reflector...
        }
        kenwood_thd75::DStarEvent::VoiceEnd => {
            // Send EOT to reflector...
        }
        kenwood_thd75::DStarEvent::TextMessage(text) => {
            println!("Slow data message: {text}");
        }
        kenwood_thd75::DStarEvent::StationHeard(entry) => {
            println!("Heard: {}", entry.callsign);
        }
        _ => {}
    }
}

let _radio = gw.stop().await?;

Structs§

DStarGateway
Complete D-STAR gateway client for the TH-D75.
DStarGatewayConfig
Configuration for a DStarGateway session.
LastHeardEntry
Entry in the last-heard list.
ReconnectPolicy
Exponential backoff policy for reflector reconnection.

Enums§

DStarEvent
An event produced by DStarGateway::next_event.