From 7ddd2a653313963fb3424146b8214750d8db67db Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Mon, 6 Dec 2021 21:07:37 -0600 Subject: [PATCH] try a keep alive? --- content/novastar.qplug | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/content/novastar.qplug b/content/novastar.qplug index 2bbf31a..371e00a 100644 --- a/content/novastar.qplug +++ b/content/novastar.qplug @@ -722,6 +722,13 @@ if (Controls) then end end + function sendKeepAlive(timer) + print("Sending Keep Alive") + sendCommand(NovaStar.Commands.Connect) + + end + + function hex_dump (str) local len = string.len( str ) local dump = "" @@ -746,9 +753,15 @@ if (Controls) then return dump .. hex .. string.rep( " ", 8 - len % 8 ) .. asc end + keepAliveTimer = Timer.New() + keepAliveTimer.EventHandler = sendKeepAlive + + NovaStar.socket.Connected = function() print("TCP Connection Established to NovaStar @ " .. Properties['IP Address'].Value) sendCommand(NovaStar.Commands.Connect) + keepAliveTimer:Start(2) + end NovaStar.socket.Reconnect = function() @@ -771,15 +784,18 @@ if (Controls) then NovaStar.socket.Closed = function() NovaStar.setStatus(2,"Connection closed by NovaStar") + keepAliveTimer:Stop() end NovaStar.socket.Error = function(sock, err) print("TCP Socket Error: ", err) NovaStar.setStatus(2,"Communication error with NovaStar") + keepAliveTimer:Stop() end NovaStar.socket.Timeout = function(sock, err) NovaStar.setStatus(2,"Timeout in connection to NovaStar") + keepAliveTimer:Stop() end if Properties['Model'].Value ~= '' then