Websocket Server icon Websocket Server WebSocket server for ARC: accepts clients, stores messages, runs per-message scripts, tracks connection status, supports debug, needs Windows admin Try it →

ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

#1  

Have a script running in the background (in a loop) checking the connection status with the command IsConnected()... if IsConnected() comes back false then use the ControlCommand Connect() to reconnect...

Check a script for these commands


repeatuntil(1=2)
if(IsConnected=0)
ControlCommand("Connection", Connect0)
sleep(3000) #give a little time to reconnect
endif
sleep(1000) # check interval
endrepeatuntil
#2  

$connected = IsConnected( 0 )
REPEATUNTIL($connected = 1)
  If($connected = 0)
    $Connection=0
  Else
    $Connection = 1
  EndIf
 if($connection = 0)
   ControlCommand("Connection", Connect0)
   $connected = IsConnected( 0 )
   sleep(4000)
 endif
EndRepeatUntil 

This is a bit sloppy but I threw it together just now. Between Rich and this, you should be able to see what is happening. I would put in a monitor script that monitors connection status and other things like maybe temp or whatever else you decide is necessary. Then call this script (or richards) from the monitor script that can loop multiple times.

Author Avatar
United Kingdom
LinkedIn Twitter Google+ YouTube
#4  

Even simpler...


:loop
IF(IsConnected(0) = 0)
  RepeatUntil(IsConnected(0) = 1)
    ControlCommand("Connection", Connect0)
    Sleep(1000)
  EndRepeatUntil
EndIf
Sleep(10000)
Goto(loop)

That should loop forever, check every ten seconds if it's connected, if it isn't it will attempt to connect every second until connected. It should connect within a second if able to, you can reduce the ten second checks to 5 seconds or even every second if you wish. The more frequent the checks the more processing power it'll take though.