chore: release v0.21.3
This commit is contained in:
@@ -34,8 +34,7 @@ const (
|
||||
// Poll fast so the meters track TX like the amplifier does (the amp's numbers
|
||||
// ride the real-time Flex UDP stream; the tuner is a synchronous TCP poll, so
|
||||
// a slow interval made its SWR/power lag noticeably behind).
|
||||
pollEvery = 400 * time.Millisecond
|
||||
reconnectDelay = 2 * time.Second
|
||||
pollEvery = 400 * time.Millisecond
|
||||
)
|
||||
|
||||
// Channel is the live state of one of the tuner's two RF channels (A / B). The
|
||||
@@ -215,6 +214,17 @@ func (c *Client) Activate(ch int) error {
|
||||
func (c *Client) pollLoop() {
|
||||
t := time.NewTicker(pollEvery)
|
||||
defer t.Stop()
|
||||
// Outage bookkeeping. A dropped link used to be entirely silent: the poll just
|
||||
// set Connected=false and retried, so "did the tuner disconnect, or is the
|
||||
// meter simply reading a gap between syllables?" could not be answered from
|
||||
// the log. Now an outage logs once when it starts and once when it ends, with
|
||||
// how long it lasted.
|
||||
//
|
||||
// Once, not every retry: the poll comes round every 400 ms, and a tuner that
|
||||
// is switched off would otherwise bury the log. These are local to the one
|
||||
// goroutine that polls — ensureConnected has no other caller — so they need no
|
||||
// locking.
|
||||
var downSince time.Time
|
||||
for {
|
||||
select {
|
||||
case <-c.stop:
|
||||
@@ -223,16 +233,28 @@ func (c *Client) pollLoop() {
|
||||
fresh := false
|
||||
if c.needConnect() {
|
||||
if err := c.ensureConnected(); err != nil {
|
||||
if downSince.IsZero() {
|
||||
downSince = time.Now()
|
||||
applog.Printf("tunergenius: link DOWN — cannot reach %s:%d: %v (retrying)", c.host, c.port, err)
|
||||
}
|
||||
c.setStatus(func(s *Status) { s.Connected = false; s.LastError = "dial: " + err.Error() })
|
||||
continue
|
||||
}
|
||||
fresh = true
|
||||
if !downSince.IsZero() {
|
||||
applog.Printf("tunergenius: link RESTORED after %s down", time.Since(downSince).Round(time.Second))
|
||||
downSince = time.Time{}
|
||||
}
|
||||
}
|
||||
// One-shot on a fresh link: learn the hardware variant (3-way vs SO2R).
|
||||
if fresh {
|
||||
_, _ = c.command("info")
|
||||
}
|
||||
if _, err := c.command("status"); err != nil {
|
||||
if downSince.IsZero() {
|
||||
downSince = time.Now()
|
||||
applog.Printf("tunergenius: link DOWN — poll failed: %v", err)
|
||||
}
|
||||
c.dropConn()
|
||||
c.setStatus(func(s *Status) { s.Connected = false; s.LastError = err.Error() })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user