From fac8d821bc83f36466a150f0e4a2619c94571994 Mon Sep 17 00:00:00 2001 From: Florian Thienel Date: Sun, 7 Feb 2021 13:39:02 +0100 Subject: [PATCH] improve code documentation --- README.md | 15 +++++++++-- client/client.go | 21 ++++++++++++--- client/consts.go | 8 +++--- client/device.go | 14 ++++++++-- client/message.go | 6 ++++- client/notify.go | 67 ++++++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 116 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b271577..f8cd381 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ # TCI Go Client Library -This is a client library for Expert Electronic's [TCI protocol](https://github.com/maksimus1210/TCI) written in Go. It comes with a simple CLI client application that allows to send single commands to the TCI server and to monitor incoming TCI messages. +This is a client library for Expert Electronic's [TCI protocol](https://github.com/maksimus1210/TCI) written in Go. The currently supported version of TCI is 1.4. -Currently, there is no support for IQ data. +The library comes with a simple CLI client application that allows to some simple things and is mainly ment as example on how to use this library: + +* monitor incoming TCI message +* send text as CW +* generate and transmit a one- or two-tone-signal for simple measurements ## Some Details About TCI @@ -10,6 +14,8 @@ Things that I did not find in the TCI reference document and that may be useful * TCI is based on a websocket connection. Commands are send as text messages, IQ data is send as binary messages. * When you send a command you need to wait until the server confirms it by returning your command in response, before you can send the next command. +* The binary messages come in little-endian byte order. +* Audio data always comes in stereo, even the tx audio. ## Build @@ -29,6 +35,11 @@ go install github.com/ftl/tci For more information about how to use the CLI client application, simply run the command `tci --help`. +## Disclaimer + +I am in no association with [Expert Electronics](https://eesdr.com) of any form. I develop this library on my own, in my free time, for my own leisure. I hope the +time invested will also help others. I am not liable for anything that happens to you or your equipment through the use of this software. That said - have fun! + ## License This software is published under the [MIT License](https://www.tldrlegal.com/l/mit). diff --git a/client/client.go b/client/client.go index 7357ae2..230cd14 100644 --- a/client/client.go +++ b/client/client.go @@ -1,3 +1,6 @@ +/* +The package client provides a client implementation for the TCI protocol. +*/ package client import ( @@ -15,10 +18,10 @@ import ( // DefaultPort of TCI const DefaultPort = 40001 -// DefaultTimeout is the defaultduration to wait for a reply to a command. +// DefaultTimeout is the default duration to wait for the reply of a command. var DefaultTimeout = time.Duration(50 * time.Millisecond) -// ErrTimeout indicates a timeout while waiting for a reply to command. +// ErrTimeout indicates a timeout while waiting for the reply of a command. var ErrTimeout = errors.New("timeout") // ErrNotConnected indicates that there is currently no TCI connection available. @@ -84,7 +87,8 @@ func newClient(host *net.TCPAddr, listeners []interface{}) *Client { return result } -// Open a connection to the given host +// Open a connection to the given host. The given listeners are notified about any incoming message. +// Open returns as soon as the READY; message was received. func Open(host *net.TCPAddr, listeners ...interface{}) (*Client, error) { client := newClient(host, listeners) err := client.connect() @@ -95,6 +99,11 @@ func Open(host *net.TCPAddr, listeners ...interface{}) (*Client, error) { return client, nil } +// KeepOpen opens a connection to the given host and tries to keep an open connection by automatically +// trying to reconnect when an established connection is lost (after the given grace period). The given +// listeners are notified about any incoming message. +// KeepOpen returns immediately. If you want to know when the connection is available, add a ConnectionListener to the +// list of listeners. func KeepOpen(host *net.TCPAddr, retryInterval time.Duration, listeners ...interface{}) *Client { client := newClient(host, listeners) go func() { @@ -271,6 +280,7 @@ func (c *Client) writeLoop(conn clientConn, incoming <-chan Message) { } } +// Ready handles the READY; message coming from the TCI host. Should not be called from outside! func (c *Client) Ready() { select { case <-c.ready: @@ -279,6 +289,7 @@ func (c *Client) Ready() { } } +// Connected indicates if there is currently a TCI connection established. func (c *Client) Connected() bool { if c.disconnectChan == nil { return false @@ -291,6 +302,8 @@ func (c *Client) Connected() bool { } } +// Disconnect the TCI connection. If this client was created using KeepOpen, the automatic +// retry stops and the client stays disconnected. func (c *Client) Disconnect() { // When the connection was disconnected from the outside, we keep it closed. select { @@ -310,6 +323,7 @@ func (c *Client) Disconnect() { } } +// WhenDisconnected calls the given function when the client gets disconnected. func (c *Client) WhenDisconnected(f func()) { if c.disconnectChan == nil { f() @@ -339,6 +353,7 @@ func (c *Client) command(cmd string, args ...interface{}) (Message, error) { } // SendTXAudio sends the given samples as reply to a TXChrono message. +// The samples need to be in stereo, i.e. channel 1 and channel 2 interleaved. func (c *Client) SendTXAudio(trx int, sampleRate AudioSampleRate, samples []float32) error { msg, err := NewTXAudioMessage(trx, sampleRate, samples) if err != nil { diff --git a/client/consts.go b/client/consts.go index e14c8fe..89f2497 100644 --- a/client/consts.go +++ b/client/consts.go @@ -2,7 +2,7 @@ package client import "fmt" -// VFO represents a VFO in TCI. +// VFO represents a VFO in TCI. In the TCI documentation the VFOs area also named "channel". type VFO int // All available VFOs in TCI. @@ -14,7 +14,7 @@ const ( // Mode represents the modulation type of a TRX. type Mode string -// All available modes in TCI. +// All modes acvailable in TCI. const ( ModeAM = Mode("am") ModeSAM = Mode("sam") @@ -40,7 +40,7 @@ const ( SignalSourceVAC = SignalSource("vac") ) -// IQSampleRate represents the sample rate for IQ data in Hz. +// IQSampleRate represents the sample rate for IQ data in samples per second. type IQSampleRate int // All available sample rates for IQ data. @@ -50,7 +50,7 @@ const ( IQSampleRate192k = IQSampleRate(192000) ) -// AudioSampleRate represents the sample rate for audio data in Hz. +// AudioSampleRate represents the sample rate for audio data in samples per second. type AudioSampleRate int // All available sample rates for audio data. diff --git a/client/device.go b/client/device.go index d4233d0..dc76265 100644 --- a/client/device.go +++ b/client/device.go @@ -1,7 +1,9 @@ package client +// DeviceInfo contains the basic information about the SunSDR device which are transmitted when the TCI connection is established. +// This information cannot be requested through TCI, so it is automatically collected by the client and provided through this type. type DeviceInfo struct { - Name string + DeviceName string ProtocolName string ProtocolVersion string MinVFOFrequency int @@ -14,37 +16,45 @@ type DeviceInfo struct { Modes []Mode } +// SetDeviceName handles the DEVICE message. func (d *DeviceInfo) SetDeviceName(name string) { - d.Name = name + d.DeviceName = name } +// SetProtocol handles the PROTOCOL message. func (d *DeviceInfo) SetProtocol(name string, version string) { d.ProtocolName = name d.ProtocolVersion = version } +// SetVFOLimits handles the VFO_LIMITS message. func (d *DeviceInfo) SetVFOLimits(min int, max int) { d.MinVFOFrequency = min d.MaxVFOFrequency = max } +// SetIFLimits handles the IF_LIMITS message. func (d *DeviceInfo) SetIFLimits(min int, max int) { d.MinIFFrequency = min d.MaxIFFrequency = max } +// SetTRXCount handles the TRX_COUNT message. func (d *DeviceInfo) SetTRXCount(count int) { d.TRXCount = count } +// SetChannelCount handles the CHANNEL_COUNT message. func (d *DeviceInfo) SetChannelCount(count int) { d.ChannelCount = count } +// SetRXOnly handles the RECEIVE_ONLY message. func (d *DeviceInfo) SetRXOnly(value bool) { d.RXOnly = value } +// SetModes handles the MODULATIONS_LIST message. func (d *DeviceInfo) SetModes(modes []Mode) { d.Modes = modes } diff --git a/client/message.go b/client/message.go index fb1bc05..425a492 100644 --- a/client/message.go +++ b/client/message.go @@ -11,7 +11,7 @@ import ( var messageExp = regexp.MustCompile(`(?P[A-Za-z_]+)(:(?P[A-Za-z0-9-.]+(,[A-Za-z0-9-.]+)*))?;`) -// ParseMessage parses the given string as a TCI message. +// ParseMessage interprets the given string as a TCI message. func ParseTextMessage(s string) (Message, error) { matches := messageExp.FindStringSubmatch(s) if len(matches) == 0 { @@ -117,6 +117,7 @@ func (m Message) ToFloat(i int) (float64, error) { } // NewTXAudioMessage returns a binary message of type TXAudioStream that contains the given samples. +// The binary message can directly be send through a websocket connection to the TCI server. func NewTXAudioMessage(trx int, sampleRate AudioSampleRate, samples []float32) ([]byte, error) { msg := &encodedBinaryMessage{ TRX: uint32(trx), @@ -184,6 +185,7 @@ type encodedBinaryMessage struct { Reserved [9]uint32 } +// BinaryMessage represents a binary message that is exchanged between the TCI server and a client. type BinaryMessage struct { TRX int SampleRate int @@ -195,8 +197,10 @@ type BinaryMessage struct { Data []float32 } +// BinaryMessageType represents the type of a BinaryMessage type BinaryMessageType uint32 +// All message types available in TCI. const ( IQStreamMessage BinaryMessageType = iota RXAudioStreamMessage diff --git a/client/notify.go b/client/notify.go index c7bf2ca..9115f0e 100644 --- a/client/notify.go +++ b/client/notify.go @@ -33,6 +33,7 @@ func (n *notifier) notifyLoop() { } } +// Notify registers the given listener. The listener is then notified about incoming messages. func (n *notifier) Notify(listener interface{}) { n.listeners = append(n.listeners, listener) } @@ -163,6 +164,7 @@ func (n *notifier) handleIncomingMessage(msg Message) { } } +// MessageListener is notified when any text message is received from the TCI server. type MessageListener interface { Message(msg Message) } @@ -175,6 +177,7 @@ func (n *notifier) emitMessage(msg Message) { } } +// A VFOLimitsListener is notified when a VFO_LIMITS message is received from the TCI server. type VFOLimitsListener interface { SetVFOLimits(min, max int) } @@ -196,6 +199,7 @@ func (n *notifier) emitVFOLimits(msg Message) error { return nil } +// An IFLimitsListener is notified when an IF_LIMITS message is received from the TCI server. type IFLimitsListener interface { SetIFLimits(min, max int) } @@ -217,6 +221,7 @@ func (n *notifier) emitIFLimits(msg Message) error { return nil } +// A TRXCountListener is notified when a TRX_COUNT message is received from the TCI server. type TRXCountListener interface { SetTRXCount(count int) } @@ -234,6 +239,7 @@ func (n *notifier) emitTRXCount(msg Message) error { return nil } +// A ChannelCountListener is notified when a CHANNEL_COUNT message is received from the TCI server. type ChannelCountListener interface { SetChannelCount(count int) } @@ -251,6 +257,7 @@ func (n *notifier) emitChannelCount(msg Message) error { return nil } +// A DeviceNameListener is notified when a DEVICE message is received from the TCI server. type DeviceNameListener interface { SetDeviceName(name string) } @@ -268,6 +275,7 @@ func (n *notifier) emitDeviceName(msg Message) error { return nil } +// A RXOnlyListener is notified when a RECEIVE_ONLY message is received from the TCI server. type RXOnlyListener interface { SetRXOnly(value bool) } @@ -285,6 +293,7 @@ func (n *notifier) emitRXOnly(msg Message) error { return nil } +// A ModesListener is notified when a MODULATIONS_LIST message is received from the TCI server. type ModesListener interface { SetModes(modes []Mode) } @@ -302,6 +311,7 @@ func (n *notifier) emitModes(msg Message) error { return nil } +// A TXEnableListener is notified when a TX_ENABLE message is received from the TCI server. type TXEnableListener interface { SetTXEnable(trx int, enabled bool) } @@ -323,6 +333,7 @@ func (n *notifier) emitTXEnable(msg Message) error { return nil } +// A ReadyListener is notified when a READY message is received from the TCI server. type ReadyListener interface { Ready() } @@ -336,6 +347,7 @@ func (n *notifier) emitReady(Message) error { return nil } +// A TXFootswitchListener is notified when a TX_FOOTSWITCH message is received from the TCI server. type TXFootswitchListener interface { SetTXFootswitch(trx int, pressed bool) } @@ -357,6 +369,7 @@ func (n *notifier) emitTXFootswitch(msg Message) error { return nil } +// A StartListener is notified when a START message is received from the TCI server. type StartListener interface { Start() } @@ -370,6 +383,7 @@ func (n *notifier) emitStart(Message) error { return nil } +// A StopListener is notified when a STOP message is received from the TCI server. type StopListener interface { Stop() } @@ -383,6 +397,7 @@ func (n *notifier) emitStop(Message) error { return nil } +// A DDSListener is notified when a DDS message is received from the TCI server. type DDSListener interface { SetDDS(trx int, frequency int) } @@ -404,6 +419,7 @@ func (n *notifier) emitDDS(msg Message) error { return nil } +// An IFListener is notified when an IF_LIMITS message is received from the TCI server. type IFListener interface { SetIF(trx int, vfo VFO, frequency int) } @@ -429,6 +445,7 @@ func (n *notifier) emitIF(msg Message) error { return nil } +// A RITEnableListener is notified when a RIT_ENABLE message is received from the TCI server. type RITEnableListener interface { SetRITEnable(trx int, enabled bool) } @@ -450,6 +467,7 @@ func (n *notifier) emitRITEnable(msg Message) error { return nil } +// A ModeListener is notified when a MODULATION message is received from the TCI server. type ModeListener interface { SetMode(trx int, mode Mode) } @@ -471,6 +489,7 @@ func (n *notifier) emitMode(msg Message) error { return nil } +// A RXEnableListener is notified when a RX_ENABLE message is received from the TCI server. type RXEnableListener interface { SetRXEnable(trx int, enabled bool) } @@ -492,6 +511,7 @@ func (n *notifier) emitRXEnable(msg Message) error { return nil } +// A XITEnableListener is notified when a XIT_ENABLE message is received from the TCI server. type XITEnableListener interface { SetXITEnable(trx int, enabled bool) } @@ -513,6 +533,7 @@ func (n *notifier) emitXITEnable(msg Message) error { return nil } +// A SplitEnableListener is notified when a SPLIT_ENABLE message is received from the TCI server. type SplitEnableListener interface { SetSplitEnable(trx int, enabled bool) } @@ -534,6 +555,7 @@ func (n *notifier) emitSplitEnable(msg Message) error { return nil } +// A RITOffsetListener is notified when a RIT_OFFSET message is received from the TCI server. type RITOffsetListener interface { SetRITOffset(trx int, offset int) } @@ -555,6 +577,7 @@ func (n *notifier) emitRITOffset(msg Message) error { return nil } +// A XITOffsetListener is notified when a XIT_OFFSET message is received from the TCI server. type XITOffsetListener interface { SetXITOffset(trx int, offset int) } @@ -576,6 +599,7 @@ func (n *notifier) emitXITOffset(msg Message) error { return nil } +// A RXChannelEnableListener is notified when a RX_CHANNEL_ENABLE message is received from the TCI server. type RXChannelEnableListener interface { SetRXChannelEnable(trx int, vfo VFO, enabled bool) } @@ -601,6 +625,7 @@ func (n *notifier) emitRXChannelEnable(msg Message) error { return nil } +// A RXFilterBandListener is notified when a RX_FILTER_BAND message is received from the TCI server. type RXFilterBandListener interface { SetRXFilterBand(trx int, min, max int) } @@ -626,6 +651,7 @@ func (n *notifier) emitRXFilterBand(msg Message) error { return nil } +// A RXSMeterListener is notified when a RX_SMETER message is received from the TCI server. type RXSMeterListener interface { SetRXSMeter(trx int, vfo VFO, level int) } @@ -651,6 +677,7 @@ func (n *notifier) emitRXSMeter(msg Message) error { return nil } +// A CWMacrosSpeedListener is notified when a CW_MACROS_SPEED message is received from the TCI server. type CWMacrosSpeedListener interface { SetCWMacrosSpeed(wpm int) } @@ -668,6 +695,7 @@ func (n *notifier) emitCWMacrosSpeed(msg Message) error { return nil } +// A CWMacrosDelayListener is notified when a CW_MACROS_DELAY message is received from the TCI server. type CWMacrosDelayListener interface { SetCWMacrosDelay(delay int) } @@ -685,6 +713,7 @@ func (n *notifier) emitCWMacrosDelay(msg Message) error { return nil } +// A TXListener is notified when a TRX message is received from the TCI server. type TXListener interface { SetTX(trx int, enabled bool) } @@ -706,6 +735,7 @@ func (n *notifier) emitTX(msg Message) error { return nil } +// A TuneListener is notified when a TUNE message is received from the TCI server. type TuneListener interface { SetTune(trx int, enabled bool) } @@ -727,6 +757,7 @@ func (n *notifier) emitTune(msg Message) error { return nil } +// A DriveListener is notified when a DRIVE message is received from the TCI server. type DriveListener interface { SetDrive(percent int) } @@ -744,6 +775,7 @@ func (n *notifier) emitDrive(msg Message) error { return nil } +// A TuneDriveListener is notified when a TUNE_DRIVE message is received from the TCI server. type TuneDriveListener interface { SetTuneDrive(percent int) } @@ -761,6 +793,7 @@ func (n *notifier) emitTuneDrive(msg Message) error { return nil } +// A StartIQListener is notified when a IQ_START message is received from the TCI server. type StartIQListener interface { StartIQ(trx int) } @@ -778,6 +811,7 @@ func (n *notifier) emitStartIQ(msg Message) error { return nil } +// A StopIQListener is notified when a IQ_STOP message is received from the TCI server. type StopIQListener interface { StopIQ(trx int) } @@ -795,6 +829,7 @@ func (n *notifier) emitStopIQ(msg Message) error { return nil } +// A IQSampleRateListener is notified when a IQ_SAMPLERATE message is received from the TCI server. type IQSampleRateListener interface { SetIQSampleRate(sampleRate IQSampleRate) } @@ -812,6 +847,7 @@ func (n *notifier) emitIQSampleRate(msg Message) error { return nil } +// A StartAudioListener is notified when a AUDIO_START message is received from the TCI server. type StartAudioListener interface { StartAudio(trx int) } @@ -829,6 +865,7 @@ func (n *notifier) emitStartAudio(msg Message) error { return nil } +// A StopAudioListener is notified when a AUDIO_STOP message is received from the TCI server. type StopAudioListener interface { StopAudio(trx int) } @@ -846,6 +883,7 @@ func (n *notifier) emitStopAudio(msg Message) error { return nil } +// A AudioSampleRateListener is notified when a AUDIO_SAMPLERATE message is received from the TCI server. type AudioSampleRateListener interface { SetAudioSampleRate(sampleRate AudioSampleRate) } @@ -863,6 +901,7 @@ func (n *notifier) emitAudioSampleRate(msg Message) error { return nil } +// A ProtocolListener is notified when a PROTOCOL message is received from the TCI server. type ProtocolListener interface { SetProtocol(name string, version string) } @@ -884,6 +923,7 @@ func (n *notifier) emitProtocol(msg Message) error { return nil } +// A TXPowerListener is notified when a TX_POWER message is received from the TCI server. type TXPowerListener interface { SetTXPower(watts float64) } @@ -901,6 +941,7 @@ func (n *notifier) emitTXPower(msg Message) error { return nil } +// A TXSWRListener is notified when a TX_SWR message is received from the TCI server. type TXSWRListener interface { SetTXSWR(ratio float64) } @@ -918,6 +959,7 @@ func (n *notifier) emitTXSWR(msg Message) error { return nil } +// A VolumeListener is notified when a VOLUME message is received from the TCI server. type VolumeListener interface { SetVolume(dB int) } @@ -935,7 +977,8 @@ func (n *notifier) emitVolume(msg Message) error { return nil } -type SquelchListener interface { +// A SquelchEnableListener is notified when a SQL_ENABLE message is received from the TCI server. +type SquelchEnableListener interface { SetSquelchEnable(trx int, enabled bool) } @@ -949,13 +992,14 @@ func (n *notifier) emitSquelchEnable(msg Message) error { return err } for _, l := range n.listeners { - if listener, ok := l.(SquelchListener); ok { + if listener, ok := l.(SquelchEnableListener); ok { listener.SetSquelchEnable(trx, enabled) } } return nil } +// A SquelchLevelListener is notified when a SQL_LEVEL message is received from the TCI server. type SquelchLevelListener interface { SetSquelchLevel(dB int) } @@ -973,6 +1017,7 @@ func (n *notifier) emitSquelchLevel(msg Message) error { return nil } +// A VFOFrequencyListener is notified when a VFO message is received from the TCI server. type VFOFrequencyListener interface { SetVFOFrequency(trx int, vfo VFO, frequency int) } @@ -998,6 +1043,7 @@ func (n *notifier) emitVFOFrequency(msg Message) error { return nil } +// A AppFocusListener is notified when a APP_FOCUS message is received from the TCI server. type AppFocusListener interface { SetAppFocus(focussed bool) } @@ -1015,6 +1061,7 @@ func (n *notifier) emitAppFocus(msg Message) error { return nil } +// A MuteListener is notified when a MUTE message is received from the TCI server. type MuteListener interface { SetMute(muted bool) } @@ -1032,6 +1079,7 @@ func (n *notifier) emitMute(msg Message) error { return nil } +// A RXMuteListener is notified when a RX_MUTE message is received from the TCI server. type RXMuteListener interface { SetRXMute(trx int, muted bool) } @@ -1053,6 +1101,7 @@ func (n *notifier) emitRXMute(msg Message) error { return nil } +// A CTCSSEnableListener is notified when a CTCSS_ENABLE message is received from the TCI server. type CTCSSEnableListener interface { SetCTCSSEnable(trx int, enabled bool) } @@ -1074,6 +1123,7 @@ func (n *notifier) emitCTCSSEnable(msg Message) error { return nil } +// A CTCSSModeListener is notified when a CTCSS_MODE message is received from the TCI server. type CTCSSModeListener interface { SetCTCSSMode(trx int, mode CTCSSMode) } @@ -1095,6 +1145,7 @@ func (n *notifier) emitCTCSSMode(msg Message) error { return nil } +// A CTCSSRXToneListener is notified when a CTCSS_RX_TONE message is received from the TCI server. type CTCSSRXToneListener interface { SetCTCSSRXTone(trx int, tone CTCSSTone) } @@ -1116,6 +1167,7 @@ func (n *notifier) emitCTCSSRXTone(msg Message) error { return nil } +// A CTCSSTXToneListener is notified when a CTCSS_TX_TONE message is received from the TCI server. type CTCSSTXToneListener interface { SetCTCSSTXTone(trx int, tone CTCSSTone) } @@ -1137,6 +1189,7 @@ func (n *notifier) emitCTCSSTXTone(msg Message) error { return nil } +// A CTCSSLevelListener is notified when a CTCSS_LEVEL message is received from the TCI server. type CTCSSLevelListener interface { SetCTCSSLevel(trx int, percent int) } @@ -1158,6 +1211,7 @@ func (n *notifier) emitCTCSSLevel(msg Message) error { return nil } +// A ECoderSwitchRXListener is notified when a EXODER_SWITCH_RX message is received from the TCI server. type ECoderSwitchRXListener interface { SetECoderSwitchRX(ecoder int, trx int) } @@ -1179,6 +1233,7 @@ func (n *notifier) emitECoderSwitchRX(msg Message) error { return nil } +// A ECoderSwitchChannelListener is notified when a ECODER_SWITCH_CHANNEL message is received from the TCI server. type ECoderSwitchChannelListener interface { SetECoderSwitchChannel(ecoder int, vfo VFO) } @@ -1200,6 +1255,7 @@ func (n *notifier) emitECoderSwitchChannel(msg Message) error { return nil } +// A RXVolumeListener is notified when a RX_VOLUME message is received from the TCI server. type RXVolumeListener interface { SetRXVolume(trx int, vfo VFO, dB int) } @@ -1225,6 +1281,7 @@ func (n *notifier) emitRXVolume(msg Message) error { return nil } +// A RXBalanceListener is notified when a RX_BALANCE message is received from the TCI server. type RXBalanceListener interface { SetRXBalance(trx int, vfo VFO, dB int) } @@ -1268,6 +1325,7 @@ func (n *notifier) handleIncomingBinaryMessage(msg BinaryMessage) { } } +// A BinaryMessageListener is notified when any binary message (IQ data, audio data, or tx chrono) is received from the TCI server. type BinaryMessageListener interface { BinaryMessage(msg BinaryMessage) } @@ -1280,6 +1338,7 @@ func (n *notifier) emitBinaryMessage(msg BinaryMessage) { } } +// A IQDataListener is notified when IQ data is received from the TCI server. type IQDataListener interface { IQData(trx int, sampleRate IQSampleRate, data []float32) } @@ -1292,8 +1351,9 @@ func (n *notifier) emitIQData(msg BinaryMessage) { } } +// A RXAudioListener is notified when RX audio data is received from the TCI server. type RXAudioListener interface { - RXAudio(trx int, sampleRate AudioSampleRate, data []float32) + RXAudio(trx int, sampleRate AudioSampleRate, samples []float32) } func (n *notifier) emitRXAudio(msg BinaryMessage) { @@ -1304,6 +1364,7 @@ func (n *notifier) emitRXAudio(msg BinaryMessage) { } } +// A TXChronoListener is notified when a TX chrono message is received from the TCI server. type TXChronoListener interface { TXChrono(trx int, sampleRate AudioSampleRate, requestedSampleCount uint32) }