Aller au contenu
PatrickVH

net.TCPSocket

Recommended Posts

bonjour,

 

dans je HC2 j'ai ce code que je dois traduire en quickapp pour HC3.

Quelq'un peut m'aider svp?

local ip = "192.168.1.35" -- ip address
local port = 20000 -- this is the standard port for tcp connections
 
-- Put Actuator (Light or Wall Socket) ON
function GetTcp(cmd)  
  -- construct the string to send
  local stringtosend = cmd .. string.char(10)
  --open the socket
  local tcpSocket = Net.FTcpSocket(ip, port)
  --set the read timeout
  tcpSocket:setReadTimeout(2*1000)
  --send the command
  local bytes, errorCode = tcpSocket:write(stringtosend)
  -- Transform "result" in character chain
 
  return tcpSocket:read() or string.char()
end
 
-- Write "on" command to actuator + server ack
local res = GetTcp("*1*1*25##")
if res == "*#*1##" then
  fibaro:debug("100")
else
  fibaro:debug("Error: " .. res)
end
Modifié par PatrickVH

Partager ce message


Lien à poster
Partager sur d’autres sites

×