package main

// How a Kenwood-dialect radio is reached.
//
// Three transports, and they are genuinely different things rather than three
// spellings of one: a COM port, the same CAT bytes carried over TCP by a serial
// bridge, and the radio's own network protocol — which is a session with its own
// framing and authentication, and is not implemented here.
//
// Kept as an explicit setting rather than inferred from which field an operator
// happened to fill in. The old code preferred a network address whenever one was
// present, which is invisible from the settings page: someone who typed a host
// months ago, then set a COM port, had a radio that never answered and nothing
// on screen to explain it.

const (
	kenwoodLinkUSB    = "usb"    // a COM port
	kenwoodLinkBridge = "bridge" // RS-232 to Ethernet: the same CAT bytes over TCP
	kenwoodLinkNative = "native" // the radio's own network protocol — not supported
)

// kenwoodLinkOr resolves the stored choice, falling back to what an older
// install can be read as: a configured host meant the bridge, because that is
// what the previous code used it for.
func kenwoodLinkOr(link, host string) string {
	switch link {
	case kenwoodLinkUSB, kenwoodLinkBridge, kenwoodLinkNative:
		return link
	}
	if host != "" {
		return kenwoodLinkBridge
	}
	return kenwoodLinkUSB
}
