add yamaha speaker discovery via tcp:50000 and move pollNode to tendrils.go

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-23 22:21:35 -08:00
parent a374b34b18
commit 528f58dca1
4 changed files with 80 additions and 32 deletions

36
yamaha.go Normal file
View File

@@ -0,0 +1,36 @@
package tendrils
import (
"bufio"
"log"
"net"
"regexp"
"time"
)
var yamahaModelRegex = regexp.MustCompile(`PA-Platform:ModelId\s*=\s*0x[0-9a-fA-F]+\(([^)]+)\)`)
func (t *Tendrils) probeYamahaDevice(ip net.IP) string {
conn, err := net.DialTimeout("tcp", net.JoinHostPort(ip.String(), "50000"), 2*time.Second)
if err != nil {
return ""
}
defer conn.Close()
conn.SetReadDeadline(time.Now().Add(2 * time.Second))
scanner := bufio.NewScanner(conn)
for scanner.Scan() {
line := scanner.Text()
if match := yamahaModelRegex.FindStringSubmatch(line); match != nil {
model := match[1]
if t.DebugYamaha {
log.Printf("[yamaha] %s: found model %s", ip, model)
}
t.nodes.Update(nil, nil, []net.IP{ip}, "", model, "yamaha")
return model
}
}
return ""
}