Jump to content
C4 Forums | Control4

DriverWorks - OnConnectionStatusChanged


DLM

Recommended Posts

Hi everyone,

I'm trying to improve OnConnectionStatusChanged (driver for a alarm system) but have some questions.

 

1- When I shut down the power of the alarm system (not control4) and power it on again the driver only makes login* command when I touch the screen, why does that happen?

 

2- When I unplug Ethernet cable (from alarm system not Control4) and plug it back the driver runs commands entered while unplugged. Who can I make this not to happen so that the driver only executes commands entered after is back online?

 

3- In "Network Tools" from Composer, either when I unplug Ethernet cable (from alarm system not Control4) or shut down power of the alarm system (not control4) the Security system device is always "Online". Only when I reconnect the Ethernet cable or put power back on the system supposedly goes OFFLINE (and ONLINE immediately after, so fast that only can see it because of commands appearing on Lua window in Composer, in "Network Tools" always appears as "Online").

 

With the questions above what I'm trying to do is::

- Get a message identifying if alarm power is off or Ethernet cable unplugged.

- Add a timer to test connection every 5 seconds (necessary?)
- Add a timer, when connection is offline, to try to reconnect every 10 seconds.

 

This is what I coded:

function OnConnectionStatusChanged(idBinding, nPort, strStatus)  if (idBinding == 6001) then    if (strStatus == "ONLINE") then    -- Connection was successful.    C4:SendToNetwork(6001, 1002, tohex("03") .. "LI1234" .. tohex("0D"))    C4:SendToProxy(5001, "DISPLAY_TEXT", "<text>System ONLINE</text>")   else    -- OFFLINE...    if (strStatus == "OFFLINE") then    -- Try to reconnect...    C4:NetDisconnect(6001, 1002)    C4:NetConnect(6001, 1002)    end    end  endend

Login command is sent with:

C4:SendToNetwork(6001, 1002, tohex("03") .. "LI1234" .. tohex("0D"))

Best regards to all :)

post-135486-0-21217600-1407948261_thumb.

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.