diff --git a/onkyo-api/internal/pkg/eiscp/client.go b/onkyo-api/internal/pkg/eiscp/client.go index f728940..00cfc86 100644 --- a/onkyo-api/internal/pkg/eiscp/client.go +++ b/onkyo-api/internal/pkg/eiscp/client.go @@ -23,12 +23,12 @@ func NewEISCPClient(host, port string) (*EISCPClient, error) { Conn: conn, responseQueue: make(chan string, 100), } - go client.readResponses() + go client.listen() return client, nil } // Constatnly puts incoming data into responseQueue -func (c *EISCPClient) readResponses() { +func (c *EISCPClient) listen() { buf := make([]byte, 1024) for { n, err := c.Conn.Read(buf) @@ -128,7 +128,7 @@ func (c *EISCPClient) SetInputSelector(input string) error { return c.sendCommand("SLI" + code) } -func (c *EISCPClient) QueryCurrentInput() (string, error) { +func (c *EISCPClient) QueryInputSelector() (string, error) { response, err := c.sendReceiveCommand("SLIQSTN") if err != nil { return "", err @@ -144,7 +144,7 @@ func (c *EISCPClient) QueryCurrentInput() (string, error) { return name, nil } -func (c *EISCPClient) QueryCurrentVolume() (int, error) { +func (c *EISCPClient) QueryVolume() (int, error) { response, err := c.sendReceiveCommand("MVLQSTN") if err != nil { return 0, err @@ -160,7 +160,7 @@ func (c *EISCPClient) QueryCurrentVolume() (int, error) { return int(result), nil } -func (c *EISCPClient) QueryCurrentSubwooferLevel() (int, error) { +func (c *EISCPClient) QuerySubwooferLevel() (int, error) { response, err := c.sendReceiveCommand("SWLQSTN") if err != nil { return 0, err diff --git a/onkyo-api/main.go b/onkyo-api/main.go index ef33f73..32c7ce7 100644 --- a/onkyo-api/main.go +++ b/onkyo-api/main.go @@ -115,7 +115,7 @@ func (s *Server) powerOff(w http.ResponseWriter, r *http.Request) { // Volume handlers func (s *Server) getVolume(w http.ResponseWriter, r *http.Request) { - volume, err := s.client.QueryCurrentVolume() + volume, err := s.client.QueryVolume() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -161,7 +161,7 @@ func (s *Server) setVolume(w http.ResponseWriter, r *http.Request) { // Subwoofer handlers func (s *Server) getSubwoofer(w http.ResponseWriter, r *http.Request) { - subwoofer, err := s.client.QueryCurrentSubwooferLevel() + subwoofer, err := s.client.QuerySubwooferLevel() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -189,7 +189,7 @@ func (s *Server) setSubwoofer(w http.ResponseWriter, r *http.Request) { // Input handlers func (s *Server) getInput(w http.ResponseWriter, r *http.Request) { - input, err := s.client.QueryCurrentInput() + input, err := s.client.QueryInputSelector() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -212,17 +212,17 @@ func (s *Server) setInput(w http.ResponseWriter, r *http.Request) { // Profile handlers func (s *Server) getProfile(w http.ResponseWriter, r *http.Request) { - currentInput, err := s.client.QueryCurrentInput() + currentInput, err := s.client.QueryInputSelector() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - currentVolume, err := s.client.QueryCurrentVolume() + currentVolume, err := s.client.QueryVolume() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - currentSubwoofer, err := s.client.QueryCurrentSubwooferLevel() + currentSubwoofer, err := s.client.QuerySubwooferLevel() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return