spawn_with_transport

Function spawn_with_transport 

Source
pub(crate) async fn spawn_with_transport(
    path: String,
    transport: EitherTransport,
    mcp_speed: String,
    tx: UnboundedSender<Message>,
    cmd_rx: UnboundedReceiver<RadioCommand>,
    bt_req_tx: Sender<(Option<String>, u32)>,
    bt_resp_rx: Receiver<Result<(String, EitherTransport), String>>,
) -> Result<String, String>
Expand description

Spawn the radio communication task with a pre-opened transport.

Performs initial handshake (identify, enable AI mode, read firmware version and radio type), then spawns a tokio task that:

  1. Polls band state (FQ, SQ, MD, PC, RA, FS) and global state on a timer
  2. Processes AI-pushed BY notifications as a gate for SM reads
  3. Handles user commands (tune, set squelch, MCP write, etc.)

S-meter and busy state are event-driven via AI mode, not polled. This avoids spurious firmware spikes on Band B that occur with direct SM/BY polling.

ยงArguments

  • mcp_speed: "fast" for McpSpeed::Fast (risky), anything else for Safe.
  • tx: channel for sending state updates and errors to the TUI.
  • bt_req_tx / bt_resp_rx: channels for requesting BT reconnect from the main thread (IOBluetooth RFCOMM must be opened on main).
  • cmd_rx: channel for receiving user commands from the TUI.