PDA

View Full Version : Help to newbie



pfeifer
February 26th, 2008, 01:17 PM
I am italian, and I am sorry for my english.

I have a webserver which is the bridge with the my home automation system (MYhome BTicino). This web server accept 2 type of connection: command and monitor.

I have succesfull made the command connection with socket tcp and sent ASCII command. I will post my Netremote skin.

So. I need to make a monitor connection with girder (or netremte) to the web server and listen the ASCII string sent form webserver to client. The connection have to be always open.

The stepa for make the monitor connection are the follow:

1) Make the connection on 192.168.1.35 port 20000
2) Receive ACK
3) Send the ASCII which identify the monitor connection
4) Receive any ASCII sent from web server and store in NetRemote variable
5) Close the connection when close Netremote or PC running girder

I am very happy if some help me.

I can paid him with hospitality in Italy :-) for holidays.

Thanks

Sandro

pfeifer
March 5th, 2008, 04:41 AM
Solved by himself. This is the solution:



--[[
Scripts in this directory should be at the end of the dependency list, meaning nothing
else may depend on them.

--]]

function mycb(p1,p2)

if ( p2 == gip.CONNECTIONCLOSED ) then
print("Connection Closed")
return
end

if ( p2 == gip.CONNECTIONESTABLISHED ) then
if ( p1 == 0 ) then
print("New Connection")
else
print("New Connection Failed: ", p1)
end

return
end
if p1 ~= "" then
print(p1) -- scrive sul log il messaggio in arrivo
NetRemote.SetVariable('da_girder', p1) --scrive su una variabile di prova

chi = string.sub(p1,1,3) --estrae il chi

if chi == "*1*" then --se luce
if string.len(p1)== 6 then --se ambiente
for n=1,9 do
NetRemote.SetVariable('luce'..string.sub(p1,6,6).. n..'',string.sub(p1,4,4))
end
end
NetRemote.SetVariable('luce'..string.sub(p1,6,7).. '',string.sub(p1,4,4))

end;

end

end

c = gip.Open('192.168.1.35',20000)
c:Callback(2, '##', 1000, mycb)
c:Write('*99*1##')




I am very worry. :-(

Any has help me.

I don't ask more.


Ciao

Sandro