Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Question

Posted

Hi All,

So I have been trying to get a TCPSocket connection to my Anthem receiver using the code below.

Each time I try to connect it returns "connection refused"

The odd thing is - when I go to the Command Prompt on the same laptop I can use telnet using the same details without an issue.

 

Any ideas?

 

Thanks

 

 

QA Code:

 

 

local host = "10.0.0.40"
local port = 14900
 
function QuickApp:onInit()
    self:debug("onInit")
    self:connect()
    self:debug("onInit - connect()")
end
 
function QuickApp:onDataReceived(data)
    self:debug("onDataReceived")
    self:debug("onDataReceived", data)
end
 
function QuickApp:waitForResponseFunction()
  self.sock:read({ -- reading a data package from the socket
      success = function(data)
        self:onDataReceived(data) -- handling of received data
        self:waitForResponseFunction() -- looping of data readout
      end,
      error = function() -- a function that will be called in case of an error when trying to receive data, e.g. disconnecting a socket
        self:debug("response error")
        self.sock:close() -- socket closed
        --fibaro.setTimeout(5000, function() self:connect() end) -- re-connection attempt (every 5s)
      end
    })
end
 
function QuickApp:connect()
    self:debug("connect() - HOST: " .. host .. " PORT: " .. port)
    self.sock = net.TCPSocket() -- creation of a TCPSocket instance
    self:debug("CONNECT() - self.sock = net.TCPSocket()")
    self.sock:connect(host, port, { -- connection to the device with the specified IP and port
      success = function() -- the function will be triggered if the connection is correct
        self:debug("connected")
        self:send("SOCKET IS - " , self.sock)
        self:waitForResponseFunction() -- launching a data readout "loop"
      end,
      error = function(err) -- a function that will be triggered in case of an incorrect connection, e.g. timeout
        self:debug("connection error:",err)
        self.sock:close() -- closing the socket
        self:debug("socket closed")
        --fibaro.setTimeout(5000, function() self:connect() end) -- re-connection attempt (every 5s)
      end,
    })
    self:debug("connect() - connecting")
 
end
 
function QuickApp:onDisconnect()
    self:debug("Anthem onDisconnect");
    self.sock:close()
end
 
 
 
 
 
[10.07.2024] [16:21:25] [DEBUG] [QUICKAPP282]: onInit
[10.07.2024] [16:21:25] [DEBUG] [QUICKAPP282]: connect() - HOST: 10.0.0.40 PORT: 14900
[10.07.2024] [16:21:25] [DEBUG] [QUICKAPP282]: CONNECT() - self.sock = net.TCPSocket()
[10.07.2024] [16:21:25] [DEBUG] [QUICKAPP282]: connect() - connecting
[10.07.2024] [16:21:25] [DEBUG] [QUICKAPP282]: onInit - connect()
[10.07.2024] [16:21:25] [DEBUG] [QUICKAPP282]: connection error: Connection refused
[10.07.2024] [16:21:25] [DEBUG] [QUICKAPP282]: socket closed
 
 
 
 
 
 
C:\Users\anth_>telnet 10.0.0.40 14900
 

Please login or register to see this image.

/monthly_2024_07/image.png.c00c9f4d0a3a21a7e2a3614084156a80.png" />
 
Z1VOL?;  is the query and Z1VOL-40; is the response from the amplifier.

1 answer to this question

Recommended Posts

  • 0
  • Inquirer
  • Posted

    All,

    To close this out I have found the issue I was having.

    The Anthem AVR actually has two IP addresses - 1 for the AVR and the other for the PlayFi function. By setting the AVR IP under network settings (and in the router for a static IP) you need to make sure its the right MAC address and different from the PlayFi IP.

    No works well - just about to publish my first QA to the forum!

     

    Anth

    • Like 2

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...